You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@drill.apache.org by GitBox <gi...@apache.org> on 2022/12/01 21:29:53 UTC

[GitHub] [drill] cgivre commented on a diff in pull request #2713: DRILL-8359: Add mount and unmount command support to the filesystem plugin

cgivre commented on code in PR #2713:
URL: https://github.com/apache/drill/pull/2713#discussion_r1037418363


##########
contrib/storage-splunk/pom.xml:
##########
@@ -42,7 +42,7 @@
     <dependency>
       <groupId>com.splunk</groupId>
       <artifactId>splunk</artifactId>
-      <version>1.9.1</version>
+      <version>1.9.2</version>

Review Comment:
   Do we want to include the Splunk update on this PR?



##########
exec/java-exec/src/main/java/org/apache/drill/exec/store/dfs/FileSystemConfig.java:
##########
@@ -53,18 +53,23 @@ public class FileSystemConfig extends StoragePluginConfig {
   public static final String NAME = "file";
 
   private final String connection;
+  private final String[] mountCommand, unmountCommand;

Review Comment:
   Is there a reason we're using `String[]` and not an `ArrayList` here?



##########
exec/java-exec/src/main/java/org/apache/drill/exec/store/dfs/FileSystemPlugin.java:
##########
@@ -282,4 +286,82 @@ public Set<? extends RelOptRule> getOptimizerRules(OptimizerRulesContext optimiz
   public Configuration getFsConf() {
     return new Configuration(fsConf);
   }
+
+  /**
+   * Runs the configured mount command if the mounted flag is unset
+   * @return true if the configured mount command was executed
+   */
+  private synchronized boolean mount() {
+    String[] mountCmd = config.getMountCommand();
+    if (ArrayUtils.isEmpty(mountCmd)) {
+      return false;
+    }
+    try {
+      Process proc = Runtime.getRuntime().exec(mountCmd);
+      if (proc.waitFor() != 0) {
+        String stderrOutput = IOUtils.toString(proc.getErrorStream(), StandardCharsets.UTF_8);
+        throw new IOException(stderrOutput);
+      }
+      logger.info("The mount command for plugin {} succeeded.", getName());
+      return true;
+    } catch (IOException | InterruptedException e) {
+      logger.error("The mount command for plugin {} failed.", getName(), e);
+      throw UserException.pluginError(e)
+        .message("The mount command for plugin %s failed.", getName())
+        .build(logger);
+    }
+  }
+
+  /**
+   * Runs the configured unmount command if the mounted flag is set
+   * @return true if the configured unmount command was executed
+   */
+  private synchronized boolean unmount() {
+    String[] unmountCmd = config.getUnmountCommand();
+    if (ArrayUtils.isEmpty(unmountCmd)) {

Review Comment:
   See above comment about `String[]` vs `ArrayList<String>`.



-- 
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.

To unsubscribe, e-mail: dev-unsubscribe@drill.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org