arina-ielchiieva commented on a change in pull request #2010: DRILL-7620: Fix
plugin mutability issues
URL: https://github.com/apache/drill/pull/2010#discussion_r387644115
##########
File path:
exec/java-exec/src/main/java/org/apache/drill/exec/store/StoragePluginRegistryImpl.java
##########
@@ -396,41 +407,68 @@ public void put(String name, StoragePluginConfig config)
throws ExecutionSetupEx
moveToEphemeral(oldEntry);
}
- /**
- * If there is an ephemeral plugin of this (name, config), pair,
- * transfer that plugin out of ephemeral storage for reuse. Else
- * create a new handle.
- *
- * @param name plugin name
- * @param config plugin config
- * @return a handle for the plugin which may have been retrieved from
- * ephemeral storage
- */
- private PluginHandle restoreFromEphemeral(String name,
- StoragePluginConfig config) {
+ @Override
+ public void setEnabled(String name, boolean enable) throws
ExecutionSetupException {
- // Benign race condition between check and invalidate.
- PluginHandle ephemeralEntry = ephemeralPlugins.getIfPresent(config);
- if (ephemeralEntry == null ||
!name.equalsIgnoreCase(ephemeralEntry.name())) {
- return createPluginEntry(name, config, PluginType.STORED);
- } else {
+ // Works only with the stored config. (Some odd persistent stores do not
+ // actually serialize the config; they just cache a copy.) If we change
+ // anything, the next request will do a resync to pick up the change.
+ StoragePluginConfig config = pluginStore.get(name);
+ if (config == null) {
+ throw new ExecutionSetupException(
+ "Plugin is undefined: " + name);
+ }
+ if (config.isEnabled() != enable) {
+ config.setEnabled(enable);
+ pluginStore.put(name, config);
+ }
+ }
- // Transfer the instance to a new handle, then invalidate the
- // cache entry. The transfer ensures that the invalidate will
- // not close the plugin instance
- PluginHandle newHandle = ephemeralEntry.transfer(PluginType.STORED);
- ephemeralPlugins.invalidate(config);
- return newHandle;
+ // Configs are obtained from the persistent store. This method is
Review comment:
Please add text in form of java-doc.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services