[ 
https://issues.apache.org/jira/browse/DRILL-6494?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16528442#comment-16528442
 ] 

ASF GitHub Bot commented on DRILL-6494:
---------------------------------------

vdiravka commented on a change in pull request #1345: DRILL-6494: Drill Plugins 
Handler
URL: https://github.com/apache/drill/pull/1345#discussion_r199073271
 
 

 ##########
 File path: 
exec/java-exec/src/main/java/org/apache/drill/exec/store/StoragePluginRegistryImpl.java
 ##########
 @@ -121,71 +117,96 @@ public StoragePlugin load(StoragePluginConfig config) 
throws Exception {
   }
 
   @Override
-  public void init() throws DrillbitStartupException {
+  public void init() {
     availablePlugins = findAvailablePlugins(classpathScan);
 
-    // create registered plugins defined in "storage-plugins.json"
-    plugins.putAll(createPlugins());
-  }
-
-  @SuppressWarnings("resource")
-  private Map<String, StoragePlugin> createPlugins() throws 
DrillbitStartupException {
     try {
-      /*
-       * Check if the storage plugins system table has any entries. If not, 
load the boostrap-storage-plugin file into
-       * the system table.
-       */
+      StoragePlugins pluginsToBeWrittenToPersistenceStore = null;
+      final boolean isPluginsUpdaterEnabled = 
context.getConfig().getBoolean(ExecConstants.STORAGE_PLUGINS_UPDATE);
       if (!pluginSystemTable.getAll().hasNext()) {
-        // bootstrap load the config since no plugins are stored.
-        logger.info("No storage plugin instances configured in persistent 
store, loading bootstrap configuration.");
-        Collection<URL> urls = 
ClassPathScanner.forResource(ExecConstants.BOOTSTRAP_STORAGE_PLUGINS_FILE, 
false);
-        if (urls != null && !urls.isEmpty()) {
-          logger.info("Loading the storage plugin configs from URLs {}.", 
urls);
-          Map<String, URL> pluginURLMap = Maps.newHashMap();
-          for (URL url : urls) {
-            String pluginsData = Resources.toString(url, Charsets.UTF_8);
-            StoragePlugins plugins = 
lpPersistence.getMapper().readValue(pluginsData, StoragePlugins.class);
-            for (Map.Entry<String, StoragePluginConfig> config : plugins) {
-              if (!definePluginConfig(config.getKey(), config.getValue())) {
-                logger.warn("Duplicate plugin instance '{}' defined in [{}, 
{}], ignoring the later one.",
-                    config.getKey(), pluginURLMap.get(config.getKey()), url);
-                continue;
-              }
-              pluginURLMap.put(config.getKey(), url);
-            }
-          }
-        } else {
-          throw new IOException("Failure finding " + 
ExecConstants.BOOTSTRAP_STORAGE_PLUGINS_FILE);
+        // create registered plugins defined in "storage-plugins.json"
+        StoragePlugins bootstrapPlugins = readBootstrapStoragePlugins();
+        if (isPluginsUpdaterEnabled) {
+          StoragePluginsHandler storagePluginsUpdaterService = new 
StoragePluginsUpdater(context);
+          pluginsToBeWrittenToPersistenceStore = 
storagePluginsUpdaterService.updatePlugins(bootstrapPlugins, null);
+        }
+        if (pluginsToBeWrittenToPersistenceStore == null) {
+          pluginsToBeWrittenToPersistenceStore = bootstrapPlugins;
+        }
+      } else {
+        if (isPluginsUpdaterEnabled) {
+          StoragePluginsHandler storagePluginsUpdaterService = new 
StoragePluginsUpdater(context);
+          pluginsToBeWrittenToPersistenceStore = 
storagePluginsUpdaterService.updatePlugins(null, pluginSystemTable);
         }
       }
 
-      Map<String, StoragePlugin> activePlugins = new HashMap<String, 
StoragePlugin>();
-      for (Map.Entry<String, StoragePluginConfig> entry : 
Lists.newArrayList(pluginSystemTable.getAll())) {
-        String name = entry.getKey();
-        StoragePluginConfig config = entry.getValue();
-        if (config.isEnabled()) {
-          try {
-            StoragePlugin plugin = create(name, config);
-            activePlugins.put(name, plugin);
-          } catch (ExecutionSetupException e) {
-            logger.error("Failure while setting up StoragePlugin with name: 
'{}', disabling.", name, e);
-            config.setEnabled(false);
-            pluginSystemTable.put(name, config);
-          }
+      // load plugins to persistence store
 
 Review comment:
   done

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Drill Plugins Handler
> ---------------------
>
>                 Key: DRILL-6494
>                 URL: https://issues.apache.org/jira/browse/DRILL-6494
>             Project: Apache Drill
>          Issue Type: New Feature
>          Components: Tools, Build &amp; Test
>    Affects Versions: 1.13.0
>            Reporter: Vitalii Diravka
>            Assignee: Vitalii Diravka
>            Priority: Major
>              Labels: doc-impacting
>             Fix For: 1.14.0
>
>         Attachments: storage-plugins.conf
>
>
> The new service of updating Drill's plugins configs could be implemented.
> Please find details from design overview document:
> https://docs.google.com/document/d/14JKb2TA8dGnOIE5YT2RImkJ7R0IAYSGjJg8xItL5yMI/edit?usp=sharing



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to