[
https://issues.apache.org/jira/browse/DRILL-6494?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16531088#comment-16531088
]
ASF GitHub Bot commented on DRILL-6494:
---------------------------------------
arina-ielchiieva commented on a change in pull request #1345: DRILL-6494: Drill
Plugins Handler
URL: https://github.com/apache/drill/pull/1345#discussion_r199741156
##########
File path:
exec/java-exec/src/main/java/org/apache/drill/exec/store/StoragePluginsHandlerService.java
##########
@@ -0,0 +1,197 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.drill.exec.store;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.base.Charsets;
+import com.google.common.io.Resources;
+import com.jasonclawson.jackson.dataformat.hocon.HoconFactory;
+import org.apache.drill.common.config.CommonConstants;
+import org.apache.drill.common.config.LogicalPlanPersistence;
+import org.apache.drill.common.exceptions.DrillRuntimeException;
+import org.apache.drill.common.logical.StoragePluginConfig;
+import org.apache.drill.common.scanner.ClassPathScanner;
+import org.apache.drill.exec.planner.logical.StoragePlugins;
+import org.apache.drill.exec.server.DrillbitContext;
+import org.apache.drill.exec.store.sys.PersistentStore;
+
+import javax.annotation.Nullable;
+import javax.validation.constraints.NotNull;
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+
+import static
org.apache.drill.exec.store.StoragePluginRegistry.ACTION_ON_STORAGE_PLUGINS_OVERRIDE_FILE;
+
+/**
+ * Drill plugins handler, which allows to update storage plugins configs from
the
+ * {@link CommonConstants#STORAGE_PLUGINS_OVERRIDE_CONF} conf file
+ *
+ * TODO: DRILL-6564: It can be improved with configs versioning and service of
creating
+ * {@link CommonConstants#STORAGE_PLUGINS_OVERRIDE_CONF}
+ */
+public class StoragePluginsHandlerService implements StoragePluginsHandler {
+ private static final org.slf4j.Logger logger =
org.slf4j.LoggerFactory.getLogger(StoragePluginsHandlerService.class);
+
+ private final LogicalPlanPersistence hoconLogicalPlanPersistence;
+ private final DrillbitContext context;
+ private URL pluginsOverrideFileUrl;
+
+ public StoragePluginsHandlerService(DrillbitContext context) {
+ this.context = context;
+ this.hoconLogicalPlanPersistence = new
LogicalPlanPersistence(context.getConfig(), context.getClasspathScan(),
+ new ObjectMapper(new HoconFactory()));
+ }
+
+ @Override
+ public void loadPlugins(@NotNull PersistentStore<StoragePluginConfig>
persistentStore,
+ @Nullable StoragePlugins bootstrapPlugins) {
+ // if bootstrapPlugins is not null -- fresh Drill set up
+ StoragePlugins pluginsToBeWrittenToPersistentStore;
+
+ StoragePlugins newPlugins = getNewStoragePlugins();
+
+ if (newPlugins != null) {
+ pluginsToBeWrittenToPersistentStore = new StoragePlugins(new
HashMap<>());
+ Optional.ofNullable(bootstrapPlugins)
+ .ifPresent(pluginsToBeWrittenToPersistentStore::putAll);
+
+ for (Map.Entry<String, StoragePluginConfig> newPlugin : newPlugins) {
+ String pluginName = newPlugin.getKey();
+ StoragePluginConfig oldPluginConfig =
Optional.ofNullable(bootstrapPlugins)
+ .map(plugins -> plugins.getConfig(pluginName))
+ .orElse(persistentStore.get(pluginName));
+ StoragePluginConfig updatedStatusPluginConfig =
updatePluginStatus(oldPluginConfig, newPlugin.getValue());
+ pluginsToBeWrittenToPersistentStore.put(pluginName,
updatedStatusPluginConfig);
+ }
+ } else {
+ pluginsToBeWrittenToPersistentStore = bootstrapPlugins;
+ }
+
+ // load pluginsToBeWrittenToPersistentStore to Persistent Store
+ Optional.ofNullable(pluginsToBeWrittenToPersistentStore)
+ .ifPresent(plugins -> plugins.forEach(plugin ->
persistentStore.put(plugin.getKey(), plugin.getValue())));
+
+ if (newPlugins != null) {
+ PluginsOverrideFileAction finalActionOnPluginsOverrideFile =
Review comment:
Please consider renaming variable to be a little bit more concise,
----------------------------------------------------------------
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:
[email protected]
> 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 & 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)