ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [2/2] incubator-ignite git commit: [GG-9961]: case of non-null userName for AbstractFileSystem
Date Tue, 24 Mar 2015 10:18:47 GMT
[GG-9961]: case of non-null userName for AbstractFileSystem


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

Branch: refs/heads/ignite-gg-9961
Commit: 0edd4ab7ff684e1f12bf0c81c2b2789bb2e0849e
Parents: 5410431
Author: iveselovskiy <iveselovskiy@gridgain.com>
Authored: Tue Mar 24 13:18:02 2015 +0300
Committer: iveselovskiy <iveselovskiy@gridgain.com>
Committed: Tue Mar 24 13:18:02 2015 +0300

----------------------------------------------------------------------
 .../hadoop/fs/v1/IgniteHadoopFileSystem.java    |  3 +-
 .../hadoop/SecondaryFileSystemProvider.java     | 29 ++++++++++++++++++--
 2 files changed, 29 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0edd4ab7/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 06de60f..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
@@ -292,7 +292,8 @@ public class IgniteHadoopFileSystem extends FileSystem {
                 String secUserName = props.get(SECONDARY_FS_USER_NAME);
 
                 try {
-                    SecondaryFileSystemProvider secProvider = new SecondaryFileSystemProvider(secUri,
secConfPath, secUserName);
+                    SecondaryFileSystemProvider secProvider = new SecondaryFileSystemProvider(secUri,
secConfPath,
+                        secUserName);
 
                     secondaryFs = secProvider.createFileSystem();
                     secondaryUri = secProvider.uri();

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0edd4ab7/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 52dcc05..6990c2d 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
@@ -19,12 +19,14 @@ package org.apache.ignite.internal.processors.hadoop;
 
 import org.apache.hadoop.conf.*;
 import org.apache.hadoop.fs.*;
+import org.apache.hadoop.security.*;
 import org.apache.ignite.internal.util.*;
 import org.apache.ignite.internal.util.typedef.internal.*;
 import org.jetbrains.annotations.*;
 
 import java.io.*;
 import java.net.*;
+import java.security.*;
 
 /**
  * Encapsulates logic of secondary filesystem creation.
@@ -114,8 +116,31 @@ public class SecondaryFileSystemProvider {
      * @throws IOException
      */
     public AbstractFileSystem createAbstractFileSystem() throws IOException {
-        // TODO: how to use userName in this case?
-        final AbstractFileSystem secondaryFs = AbstractFileSystem.get(uri, cfg);
+        final AbstractFileSystem secondaryFs;
+
+        if (userName == null)
+            secondaryFs = AbstractFileSystem.get(uri, cfg);
+        else {
+            // The below code borrowed from
+            // org.apache.hadoop.fs.FileSystem.get(java.net.URI, org.apache.hadoop.conf.Configuration,
java.lang.String):
+            String ticketCachePath = cfg.get(CommonConfigurationKeys.KERBEROS_TICKET_CACHE_PATH);
+
+            UserGroupInformation ugi = UserGroupInformation.getBestUGI(ticketCachePath, userName);
+
+            try {
+                secondaryFs = ugi.doAs(new PrivilegedExceptionAction<AbstractFileSystem>()
{
+
+                    @Override public AbstractFileSystem run() throws IOException {
+                        return AbstractFileSystem.get(uri, cfg);
+                    }
+                });
+            }
+            catch (InterruptedException ie) {
+                Thread.currentThread().interrupt();
+
+                throw new IOException(ie);
+            }
+        }
 
         return secondaryFs;
     }


Mime
View raw message