ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vkuliche...@apache.org
Subject [18/50] incubator-ignite git commit: # GG-9961: Added user name propagation support to secondary file system factory.
Date Tue, 24 Mar 2015 17:47:29 GMT
# GG-9961: Added user name propagation support to secondary file system factory.


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/22bdbce4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/22bdbce4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/22bdbce4

Branch: refs/heads/ignite-45-ipc-debug
Commit: 22bdbce45bb1044b4834625fa445512bb75152d2
Parents: d578683
Author: vozerov-gridgain <vozerov@gridgain.com>
Authored: Tue Mar 24 14:31:23 2015 +0300
Committer: vozerov-gridgain <vozerov@gridgain.com>
Committed: Tue Mar 24 14:31:23 2015 +0300

----------------------------------------------------------------------
 .../ignite/internal/processors/igfs/IgfsEx.java |  3 ++
 .../visor/node/VisorIgfsConfiguration.java      | 11 +++++++
 .../fs/IgniteHadoopIgfsSecondaryFileSystem.java | 26 ++++++++++++++--
 .../hadoop/fs/v1/IgniteHadoopFileSystem.java    |  4 ++-
 .../hadoop/fs/v2/IgniteHadoopFileSystem.java    |  4 ++-
 .../internal/processors/hadoop/HadoopSetup.java |  8 ++---
 .../hadoop/SecondaryFileSystemProvider.java     | 31 ++++++++++++++------
 ...oopSecondaryFileSystemConfigurationTest.java |  4 +--
 8 files changed, 70 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/22bdbce4/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsEx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsEx.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsEx.java
index 0c5debd..99f647e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsEx.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsEx.java
@@ -48,6 +48,9 @@ public interface IgfsEx extends IgniteFileSystem {
     /** Property name for URI of file system. */
     public static final String SECONDARY_FS_URI = "SECONDARY_FS_URI";
 
+    /** Property name for user name of file system. */
+    public static final String SECONDARY_FS_USER_NAME = "SECONDARY_FS_USER_NAME";
+
     /**
      * Stops IGFS cleaning all used resources.
      */

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/22bdbce4/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorIgfsConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorIgfsConfiguration.java
b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorIgfsConfiguration.java
index a1e3c52..d0b0124 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorIgfsConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorIgfsConfiguration.java
@@ -66,6 +66,9 @@ public class VisorIgfsConfiguration implements Serializable {
     /** Path for the secondary hadoop file system config. */
     private String secondaryHadoopFileSysCfgPath;
 
+    /** User name for the secondary hadoop file system config. */
+    private String secondaryHadoopFileSysUserName;
+
     /** IGFS instance mode. */
     private IgfsMode dfltMode;
 
@@ -140,6 +143,7 @@ public class VisorIgfsConfiguration implements Serializable {
 
             cfg.secondaryHadoopFileSysUri = props.get(SECONDARY_FS_URI);
             cfg.secondaryHadoopFileSysCfgPath = props.get(SECONDARY_FS_CONFIG_PATH);
+            cfg.secondaryHadoopFileSysUserName = props.get(SECONDARY_FS_USER_NAME);
         }
 
         cfg.dfltMode = igfs.getDefaultMode();
@@ -249,6 +253,13 @@ public class VisorIgfsConfiguration implements Serializable {
     }
 
     /**
+     * @return User name of the secondary Hadoop file system.
+     */
+    @Nullable public String secondaryHadoopFileSystemUserName() {
+        return secondaryHadoopFileSysUserName;
+    }
+
+    /**
      * @return Path for the secondary hadoop file system config.
      */
     @Nullable public String secondaryHadoopFileSystemConfigPath() {

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/22bdbce4/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/IgniteHadoopIgfsSecondaryFileSystem.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/IgniteHadoopIgfsSecondaryFileSystem.java
b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/IgniteHadoopIgfsSecondaryFileSystem.java
index 6d0c386..13a2173 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/IgniteHadoopIgfsSecondaryFileSystem.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/IgniteHadoopIgfsSecondaryFileSystem.java
@@ -53,7 +53,7 @@ public class IgniteHadoopIgfsSecondaryFileSystem implements IgfsSecondaryFileSys
      * @throws IgniteCheckedException In case of error.
      */
     public IgniteHadoopIgfsSecondaryFileSystem(String uri) throws IgniteCheckedException
{
-        this(uri, null);
+        this(uri, null, null);
     }
 
     /**
@@ -64,13 +64,30 @@ public class IgniteHadoopIgfsSecondaryFileSystem implements IgfsSecondaryFileSys
      * @throws IgniteCheckedException In case of error.
      */
     public IgniteHadoopIgfsSecondaryFileSystem(@Nullable String uri, @Nullable String cfgPath)
+        throws IgniteCheckedException {
+        this(uri, cfgPath, null);
+    }
+
+    /**
+     * Constructor.
+     *
+     * @param uri URI of file system.
+     * @param cfgPath Additional path to Hadoop configuration.
+     * @param userName User name.
+     * @throws IgniteCheckedException In case of error.
+     */
+    public IgniteHadoopIgfsSecondaryFileSystem(@Nullable String uri, @Nullable String cfgPath,
+        @Nullable String userName)
             throws IgniteCheckedException {
-        // Treat empty uri argument as null to improve configuration usability:
+        // Treat empty uri and userName arguments as nulls to improve configuration usability:
         if (F.isEmpty(uri))
             uri = null;
 
+        if (F.isEmpty(userName))
+            userName = null;
+
         try {
-            SecondaryFileSystemProvider secProvider = new SecondaryFileSystemProvider(uri,
cfgPath);
+            SecondaryFileSystemProvider secProvider = new SecondaryFileSystemProvider(uri,
cfgPath, userName);
 
             fileSys = secProvider.createFileSystem();
 
@@ -82,6 +99,9 @@ public class IgniteHadoopIgfsSecondaryFileSystem implements IgfsSecondaryFileSys
             if (cfgPath != null)
                 props.put(SECONDARY_FS_CONFIG_PATH, cfgPath);
 
+            if (userName != null)
+                props.put(SECONDARY_FS_USER_NAME, userName);
+
             props.put(SECONDARY_FS_URI, uri);
         }
         catch (IOException e) {

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/22bdbce4/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/v1/IgniteHadoopFileSystem.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/v1/IgniteHadoopFileSystem.java
b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/v1/IgniteHadoopFileSystem.java
index 6bdcd8e..1f53a06 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/v1/IgniteHadoopFileSystem.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/v1/IgniteHadoopFileSystem.java
@@ -289,9 +289,11 @@ public class IgniteHadoopFileSystem extends FileSystem {
 
                 String secUri = props.get(SECONDARY_FS_URI);
                 String secConfPath = props.get(SECONDARY_FS_CONFIG_PATH);
+                String secUserName = props.get(SECONDARY_FS_USER_NAME);
 
                 try {
-                    SecondaryFileSystemProvider secProvider = new SecondaryFileSystemProvider(secUri,
secConfPath);
+                    SecondaryFileSystemProvider secProvider = new SecondaryFileSystemProvider(secUri,
secConfPath,
+                        secUserName);
 
                     secondaryFs = secProvider.createFileSystem();
                     secondaryUri = secProvider.uri();

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/22bdbce4/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/v2/IgniteHadoopFileSystem.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/v2/IgniteHadoopFileSystem.java
b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/v2/IgniteHadoopFileSystem.java
index 5dac047..9cfb79b 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/v2/IgniteHadoopFileSystem.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/v2/IgniteHadoopFileSystem.java
@@ -284,9 +284,11 @@ public class IgniteHadoopFileSystem extends AbstractFileSystem implements
Closea
 
                 String secUri = props.get(SECONDARY_FS_URI);
                 String secConfPath = props.get(SECONDARY_FS_CONFIG_PATH);
+                String secUserName = props.get(SECONDARY_FS_USER_NAME);
 
                 try {
-                    SecondaryFileSystemProvider secProvider = new SecondaryFileSystemProvider(secUri,
secConfPath);
+                    SecondaryFileSystemProvider secProvider = new SecondaryFileSystemProvider(secUri,
secConfPath,
+                        secUserName);
 
                     secondaryFs = secProvider.createAbstractFileSystem();
                     secondaryUri = secProvider.uri();

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/22bdbce4/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopSetup.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopSetup.java
b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopSetup.java
index c33c1f1..80c22fc 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopSetup.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/HadoopSetup.java
@@ -113,7 +113,7 @@ public class HadoopSetup {
         if (!hadoopDir.canRead())
             exit("Hadoop installation folder can not be read. Please check permissions.",
null);
 
-        File hadoopCommonDir;
+        final File hadoopCommonDir;
 
         String hadoopCommonHome = System.getenv("HADOOP_COMMON_HOME");
 
@@ -129,9 +129,9 @@ public class HadoopSetup {
         }
 
         if (!hadoopCommonDir.canRead())
-            exit("Failed to read Hadoop common dir in '" + hadoopCommonHome + "'.", null);
+            exit("Failed to read Hadoop common dir '" + hadoopCommonDir + "'.", null);
 
-        File hadoopCommonLibDir = new File(hadoopCommonDir, "lib");
+        final File hadoopCommonLibDir = new File(hadoopCommonDir, "lib");
 
         if (!hadoopCommonLibDir.canRead())
             exit("Failed to read Hadoop 'lib' folder in '" + hadoopCommonLibDir.getPath()
+ "'.", null);
@@ -139,7 +139,7 @@ public class HadoopSetup {
         if (U.isWindows()) {
             checkJavaPathSpaces();
 
-            File hadoopBinDir = new File(hadoopDir, "bin");
+            final File hadoopBinDir = new File(hadoopDir, "bin");
 
             if (!hadoopBinDir.canRead())
                 exit("Failed to read subdirectory 'bin' in HADOOP_HOME.", null);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/22bdbce4/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/SecondaryFileSystemProvider.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/SecondaryFileSystemProvider.java
b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/SecondaryFileSystemProvider.java
index c1dceba..27805f8 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/SecondaryFileSystemProvider.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/SecondaryFileSystemProvider.java
@@ -36,6 +36,9 @@ public class SecondaryFileSystemProvider {
     /** The secondary filesystem URI, never null. */
     private final URI uri;
 
+    /** Optional user name to log into secondary filesystem with. */
+    private @Nullable final String userName;
+
     /**
      * Creates new provider with given config parameters. The configuration URL is optional.
The filesystem URI must be
      * specified either explicitly or in the configuration provided.
@@ -44,10 +47,13 @@ public class SecondaryFileSystemProvider {
      * property in the provided configuration.
      * @param secConfPath the secondary Fs path (file path on the local file system, optional).
      * See {@link IgniteUtils#resolveIgniteUrl(String)} on how the path resolved.
+     * @param userName User name.
      * @throws IOException
      */
     public SecondaryFileSystemProvider(final @Nullable String secUri,
-        final @Nullable String secConfPath) throws IOException {
+        final @Nullable String secConfPath, @Nullable String userName) throws IOException
{
+        this.userName = userName;
+
         if (secConfPath != null) {
             URL url = U.resolveIgniteUrl(secConfPath);
 
@@ -72,10 +78,6 @@ public class SecondaryFileSystemProvider {
             }
         }
 
-        if (uri == null)
-            throw new IllegalArgumentException("Failed to get secondary file system URI (it
is neither given " +
-                "explicitly nor specified in the configuration): " + secConfPath);
-
         // Disable caching:
         String prop = String.format("fs.%s.impl.disable.cache", uri.getScheme());
 
@@ -87,7 +89,20 @@ public class SecondaryFileSystemProvider {
      * @throws IOException
      */
     public FileSystem createFileSystem() throws IOException {
-        FileSystem fileSys = FileSystem.get(uri, cfg);
+        final FileSystem fileSys;
+
+        if (userName == null)
+            fileSys = FileSystem.get(uri, cfg);
+        else {
+            try {
+                fileSys = FileSystem.get(uri, cfg, userName);
+            }
+            catch (InterruptedException e) {
+                Thread.currentThread().interrupt();
+
+                throw new IOException("Failed to create file system due to interrupt.", e);
+            }
+        }
 
         return fileSys;
     }
@@ -97,9 +112,7 @@ public class SecondaryFileSystemProvider {
      * @throws IOException
      */
     public AbstractFileSystem createAbstractFileSystem() throws IOException {
-        AbstractFileSystem secondaryFs = AbstractFileSystem.get(uri, cfg);
-
-        return secondaryFs;
+        return AbstractFileSystem.get(uri, cfg);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/22bdbce4/modules/hadoop/src/test/java/org/apache/ignite/igfs/HadoopSecondaryFileSystemConfigurationTest.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/igfs/HadoopSecondaryFileSystemConfigurationTest.java
b/modules/hadoop/src/test/java/org/apache/ignite/igfs/HadoopSecondaryFileSystemConfigurationTest.java
index e6c6faa..e28b5ba 100644
--- a/modules/hadoop/src/test/java/org/apache/ignite/igfs/HadoopSecondaryFileSystemConfigurationTest.java
+++ b/modules/hadoop/src/test/java/org/apache/ignite/igfs/HadoopSecondaryFileSystemConfigurationTest.java
@@ -31,8 +31,6 @@ import org.apache.ignite.internal.processors.hadoop.igfs.*;
 import org.apache.ignite.internal.processors.igfs.*;
 import org.apache.ignite.internal.util.typedef.*;
 import org.apache.ignite.internal.util.typedef.internal.*;
-import org.apache.ignite.spi.communication.*;
-import org.apache.ignite.spi.communication.tcp.*;
 import org.apache.ignite.spi.discovery.tcp.*;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
@@ -164,7 +162,7 @@ public class HadoopSecondaryFileSystemConfigurationTest extends IgfsCommonAbstra
             primaryConfFullPath = null;
 
         SecondaryFileSystemProvider provider =
-            new SecondaryFileSystemProvider(primaryFsUriStr, primaryConfFullPath);
+            new SecondaryFileSystemProvider(primaryFsUriStr, primaryConfFullPath, null);
 
         primaryFs = provider.createFileSystem();
 


Mime
View raw message