IGNITE-3163 IGFS: Added working directory support to IgniteHadoopIgfsSecondaryFileSystem. This closes #1030. This closes #1058. This closes #1132.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/b94b0aea Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/b94b0aea Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/b94b0aea Branch: refs/heads/ignite-ssl-hotfix Commit: b94b0aeae4c42b1d35128c6b1de97e3fa318d497 Parents: 23461b8 Author: tledkov-gridgain <tled...@gridgain.com> Authored: Thu Oct 6 10:22:50 2016 +0300 Committer: vozerov-gridgain <voze...@gridgain.com> Committed: Thu Oct 6 10:22:50 2016 +0300 ---------------------------------------------------------------------- .../HadoopBasicFileSystemFactoryDelegate.java | 16 +++++++++++++++- .../HadoopKerberosFileSystemFactoryDelegate.java | 7 ++++++- .../hadoop/impl/igfs/Hadoop1DualAbstractTest.java | 12 +++++++++--- .../HadoopSecondaryFileSystemConfigurationTest.java | 12 ++++++++++++ 4 files changed, 42 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/b94b0aea/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/impl/delegate/HadoopBasicFileSystemFactoryDelegate.java ---------------------------------------------------------------------- diff --git a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/impl/delegate/HadoopBasicFileSystemFactoryDelegate.java b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/impl/delegate/HadoopBasicFileSystemFactoryDelegate.java index a190b14..59488be 100644 --- a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/impl/delegate/HadoopBasicFileSystemFactoryDelegate.java +++ b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/impl/delegate/HadoopBasicFileSystemFactoryDelegate.java @@ -19,6 +19,7 @@ package org.apache.ignite.internal.processors.hadoop.impl.delegate; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileSystem; +import org.apache.hadoop.fs.Path; import org.apache.ignite.IgniteException; import org.apache.ignite.hadoop.fs.BasicHadoopFileSystemFactory; import org.apache.ignite.hadoop.fs.HadoopFileSystemFactory; @@ -52,6 +53,9 @@ public class HadoopBasicFileSystemFactoryDelegate implements HadoopFileSystemFac /** User name mapper. */ private UserNameMapper usrNameMapper; + /** Work directory. */ + protected Path workDir; + /** * Constructor. * @@ -110,7 +114,12 @@ public class HadoopBasicFileSystemFactoryDelegate implements HadoopFileSystemFac * @throws InterruptedException if the current thread is interrupted. */ protected FileSystem create(String usrName) throws IOException, InterruptedException { - return FileSystem.get(fullUri, cfg, usrName); + FileSystem fs = FileSystem.get(fullUri, cfg, usrName); + + if (workDir != null) + fs.setWorkingDirectory(workDir); + + return fs; } /** {@inheritDoc} */ @@ -150,6 +159,11 @@ public class HadoopBasicFileSystemFactoryDelegate implements HadoopFileSystemFac } } + String strWorkDir = fullUri.getPath(); + + if (!"/".equals(strWorkDir)) + workDir = new Path(strWorkDir); + usrNameMapper = proxy0.getUserNameMapper(); if (usrNameMapper != null && usrNameMapper instanceof LifecycleAware) http://git-wip-us.apache.org/repos/asf/ignite/blob/b94b0aea/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/impl/delegate/HadoopKerberosFileSystemFactoryDelegate.java ---------------------------------------------------------------------- diff --git a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/impl/delegate/HadoopKerberosFileSystemFactoryDelegate.java b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/impl/delegate/HadoopKerberosFileSystemFactoryDelegate.java index c71dedb..75093bb 100644 --- a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/impl/delegate/HadoopKerberosFileSystemFactoryDelegate.java +++ b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/impl/delegate/HadoopKerberosFileSystemFactoryDelegate.java @@ -61,7 +61,12 @@ public class HadoopKerberosFileSystemFactoryDelegate extends HadoopBasicFileSyst return proxyUgi.doAs(new PrivilegedExceptionAction<FileSystem>() { @Override public FileSystem run() throws Exception { - return FileSystem.get(fullUri, cfg); + FileSystem fs = FileSystem.get(fullUri, cfg); + + if (workDir != null) + fs.setWorkingDirectory(workDir); + + return fs; } }); } http://git-wip-us.apache.org/repos/asf/ignite/blob/b94b0aea/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/Hadoop1DualAbstractTest.java ---------------------------------------------------------------------- diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/Hadoop1DualAbstractTest.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/Hadoop1DualAbstractTest.java index a585e54..367a406 100644 --- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/Hadoop1DualAbstractTest.java +++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/Hadoop1DualAbstractTest.java @@ -58,6 +58,9 @@ public abstract class Hadoop1DualAbstractTest extends IgfsDualAbstractSelfTest { /** Secondary file system authority. */ private static final String SECONDARY_AUTHORITY = IGFS_NAME + ":" + GRID_NAME + "@127.0.0.1:" + PORT; + /** Secondary file system authority. */ + private static final String SECONDARY_WORKDIR = "workdir/test"; + /** Secondary Fs configuration full path. */ protected String secondaryConfFullPath; @@ -117,13 +120,16 @@ public abstract class Hadoop1DualAbstractTest extends IgfsDualAbstractSelfTest { * @throws IOException On failure. */ protected void prepareConfiguration() throws IOException { - Configuration secondaryConf = HadoopSecondaryFileSystemConfigurationTest.configuration(IGFS_SCHEME, SECONDARY_AUTHORITY, true, true); + Configuration secondaryConf = HadoopSecondaryFileSystemConfigurationTest.configuration(IGFS_SCHEME, + SECONDARY_AUTHORITY, true, true); secondaryConf.setInt("fs.igfs.block.size", 1024); - secondaryConfFullPath = HadoopSecondaryFileSystemConfigurationTest.writeConfiguration(secondaryConf, HadoopSecondaryFileSystemConfigurationTest.SECONDARY_CFG_PATH); + secondaryConfFullPath = HadoopSecondaryFileSystemConfigurationTest.writeConfiguration(secondaryConf, + HadoopSecondaryFileSystemConfigurationTest.SECONDARY_CFG_PATH); - secondaryUri = HadoopSecondaryFileSystemConfigurationTest.mkUri(IGFS_SCHEME, SECONDARY_AUTHORITY); + secondaryUri = HadoopSecondaryFileSystemConfigurationTest.mkUri(IGFS_SCHEME, SECONDARY_AUTHORITY, + SECONDARY_WORKDIR); } /** http://git-wip-us.apache.org/repos/asf/ignite/blob/b94b0aea/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/HadoopSecondaryFileSystemConfigurationTest.java ---------------------------------------------------------------------- diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/HadoopSecondaryFileSystemConfigurationTest.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/HadoopSecondaryFileSystemConfigurationTest.java index fd75233..ae03f14 100644 --- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/HadoopSecondaryFileSystemConfigurationTest.java +++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/HadoopSecondaryFileSystemConfigurationTest.java @@ -580,4 +580,16 @@ public class HadoopSecondaryFileSystemConfigurationTest extends IgfsCommonAbstra static String mkUri(String scheme, String authority) { return scheme + "://" + authority + "/"; } + + /** + * Makes URI. + * + * @param scheme the scheme + * @param authority the authority + * @param path Path part of URI. + * @return URI String + */ + static String mkUri(String scheme, String authority, String path) { + return scheme + "://" + authority + "/" + path; + } } \ No newline at end of file