[
https://issues.apache.org/jira/browse/DRILL-8359?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17642177#comment-17642177
]
ASF GitHub Bot commented on DRILL-8359:
---------------------------------------
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>`.
> Add mount and unmount command support to the filesystem plugin
> --------------------------------------------------------------
>
> Key: DRILL-8359
> URL: https://issues.apache.org/jira/browse/DRILL-8359
> Project: Apache Drill
> Issue Type: Improvement
> Components: Storage - File
> Affects Versions: 1.20.2
> Reporter: James Turton
> Assignee: James Turton
> Priority: Minor
> Fix For: 2.0.0
>
>
> This Jira proposes optional mount and unmount commands in the filesystem
> plugin with the goal of enabling the dynamic definition of filesystem mounts
> in the storage configuration. It is mainly anticpiated that network and cloud
> filesystems that have FUSE drivers (sshfs, davfs, rclone, ...) will be used
> in this way but local device mounts and image/loop device mounts (ISO, IMG,
> squashfs, etc.) might also be of interest. Filesystems that can be mounted in
> this way become queryable by Drill cluster without burden of dedicated
> storage plugin development.
> The provided commands are executed in their own processes by the host OS and
> run under the OS user that is running the Drill JVM. The mount command will
> be executed when an enabled plugin is initialised (something that is done
> lazily) and whenever it transitions from disabled to enabled. The provided
> unmount command will be executed whenever a plugin transitions from enabled
> to disabled and when the Drillbit shuts down while the plugin has been
> initialised and is enabled.
> Example using udisks on Linux to mount and unmount an image of an ext4
> filesystem.
> {code:java}
> {
> "type" : "file",
> "connection" : "file:///",
> "mountCommand" : [ "sh", "-c", "udisksctl loop-setup -f /tmp/test.img &&
> udisksctl mount -b /dev/loop0" ],
> "unmountCommand" : [ "sh", "-c", "udisksctl unmount -b /dev/loop0 &&
> udisksctl loop-delete -b /dev/loop0" ],
> "workspaces" : {
> ...{code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)