hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jiten...@apache.org
Subject svn commit: r1095970 - in /hadoop/common/branches/yahoo-merge: ./ src/java/org/apache/hadoop/fs/ src/test/core/org/apache/hadoop/fs/
Date Fri, 22 Apr 2011 17:45:44 GMT
Author: jitendra
Date: Fri Apr 22 17:45:43 2011
New Revision: 1095970

URL: http://svn.apache.org/viewvc?rev=1095970&view=rev
Log:
Merging change r1091618 from trunk to yahoo-merge.

Added:
    hadoop/common/branches/yahoo-merge/src/test/core/org/apache/hadoop/fs/TestFileContextResolveAfs.java
      - copied unchanged from r1091618, hadoop/common/trunk/src/test/core/org/apache/hadoop/fs/TestFileContextResolveAfs.java
Modified:
    hadoop/common/branches/yahoo-merge/CHANGES.txt   (contents, props changed)
    hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/AbstractFileSystem.java
    hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/DelegateToFileSystem.java
    hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/FileContext.java
    hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/FileSystem.java
    hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/FilterFileSystem.java
    hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/FilterFs.java

Modified: hadoop/common/branches/yahoo-merge/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/yahoo-merge/CHANGES.txt?rev=1095970&r1=1095969&r2=1095970&view=diff
==============================================================================
--- hadoop/common/branches/yahoo-merge/CHANGES.txt (original)
+++ hadoop/common/branches/yahoo-merge/CHANGES.txt Fri Apr 22 17:45:43 2011
@@ -6,6 +6,8 @@ Trunk (unreleased changes)
 
   NEW FEATURES
 
+    HADOOP-6994. Api to get delegation token in AbstractFileSystem. (jitendra)
+
   IMPROVEMENTS
 
     HADOOP-7133. Batch the calls in DataStorage to FileUtil.createHardLink().

Propchange: hadoop/common/branches/yahoo-merge/CHANGES.txt
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Apr 22 17:45:43 2011
@@ -1,4 +1,4 @@
-/hadoop/common/trunk/CHANGES.txt:1080396
+/hadoop/common/trunk/CHANGES.txt:1080396,1091618
 /hadoop/core/branches/branch-0.18/CHANGES.txt:727226
 /hadoop/core/branches/branch-0.19/CHANGES.txt:713112
 /hadoop/core/trunk/CHANGES.txt:776175-785643,785929-786278

Modified: hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/AbstractFileSystem.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/AbstractFileSystem.java?rev=1095970&r1=1095969&r2=1095970&view=diff
==============================================================================
--- hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/AbstractFileSystem.java
(original)
+++ hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/AbstractFileSystem.java
Fri Apr 22 17:45:43 2011
@@ -25,6 +25,7 @@ import java.net.URI;
 import java.net.URISyntaxException;
 import java.util.EnumSet;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.NoSuchElementException;
 import java.util.StringTokenizer;
@@ -42,6 +43,8 @@ import org.apache.hadoop.fs.Options.Rena
 import org.apache.hadoop.fs.permission.FsPermission;
 import org.apache.hadoop.fs.InvalidPathException;
 import org.apache.hadoop.security.AccessControlException;
+import org.apache.hadoop.security.SecurityUtil;
+import org.apache.hadoop.security.token.Token;
 import org.apache.hadoop.util.Progressable;
 
 /**
@@ -874,4 +877,40 @@ public abstract class AbstractFileSystem
    */
   public abstract void setVerifyChecksum(final boolean verifyChecksum)
       throws AccessControlException, IOException;
+  
+  /**
+   * Get a canonical name for this file system.
+   * @return a URI string that uniquely identifies this file system
+   */
+  public String getCanonicalServiceName() {
+    return SecurityUtil.buildDTServiceName(getUri(), getUriDefaultPort());
+  }
+  
+  /**
+   * Get one or more delegation tokens associated with the filesystem. Normally
+   * a file system returns a single delegation token. A file system that manages
+   * multiple file systems underneath, could return set of delegation tokens for
+   * all the file systems it manages
+   * 
+   * @param renewer the account name that is allowed to renew the token.
+   * @return List of delegation tokens.
+   * @throws IOException
+   */
+  @InterfaceAudience.LimitedPrivate( { "HDFS", "MapReduce" })
+  public List<Token<?>> getDelegationTokens(String renewer) throws IOException
{
+    return null;
+  }
+  
+  @Override //Object
+  public int hashCode() {
+    return myUri.hashCode();
+  }
+  
+  @Override //Object
+  public boolean equals(Object other) {
+    if (other == null || !(other instanceof AbstractFileSystem)) {
+      return false;
+    }
+    return myUri.equals(((AbstractFileSystem) other).myUri);
+  }
 }

Modified: hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/DelegateToFileSystem.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/DelegateToFileSystem.java?rev=1095970&r1=1095969&r2=1095970&view=diff
==============================================================================
--- hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/DelegateToFileSystem.java
(original)
+++ hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/DelegateToFileSystem.java
Fri Apr 22 17:45:43 2011
@@ -22,12 +22,17 @@ import java.io.IOException;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.util.EnumSet;
+import java.util.List;
 
 import org.apache.hadoop.classification.InterfaceAudience;
 import org.apache.hadoop.classification.InterfaceStability;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.permission.FsPermission;
+import org.apache.hadoop.security.SecurityUtil;
+import org.apache.hadoop.security.token.Token;
+import org.apache.hadoop.security.token.SecretManager.InvalidToken;
+import org.apache.hadoop.security.token.delegation.AbstractDelegationTokenIdentifier;
 import org.apache.hadoop.util.Progressable;
 
 /**
@@ -207,4 +212,14 @@ public abstract class DelegateToFileSyst
      */
     throw new AssertionError();
   }
+
+  @Override //AbstractFileSystem
+  public String getCanonicalServiceName() {
+    return fsImpl.getCanonicalServiceName();
+  }
+  
+  @Override //AbstractFileSystem
+  public List<Token<?>> getDelegationTokens(String renewer) throws IOException
{
+    return fsImpl.getDelegationTokens(renewer);
+  }
 }
\ No newline at end of file

Modified: hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/FileContext.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/FileContext.java?rev=1095970&r1=1095969&r2=1095970&view=diff
==============================================================================
--- hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/FileContext.java (original)
+++ hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/FileContext.java Fri
Apr 22 17:45:43 2011
@@ -26,6 +26,7 @@ import java.security.PrivilegedException
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.EnumSet;
+import java.util.HashSet;
 import java.util.IdentityHashMap;
 import java.util.List;
 import java.util.Map;
@@ -51,6 +52,7 @@ import org.apache.hadoop.ipc.UnexpectedS
 import org.apache.hadoop.fs.InvalidPathException;
 import org.apache.hadoop.security.AccessControlException;
 import org.apache.hadoop.security.UserGroupInformation;
+import org.apache.hadoop.security.token.Token;
 
 /**
  * The FileContext class provides an interface to the application writer for
@@ -2196,6 +2198,30 @@ public final class FileContext {
       }
     }.resolve(this, f).getPath();
   }
+
+  /**
+   * Returns the list of AbstractFileSystems accessed in the path. The list may
+   * contain more than one AbstractFileSystems objects in case of symlinks.
+   * 
+   * @param f
+   *          Path which needs to be resolved
+   * @return List of AbstractFileSystems accessed in the path
+   * @throws IOException
+   */
+  Set<AbstractFileSystem> resolveAbstractFileSystems(final Path f)
+      throws IOException {
+    final Path absF = fixRelativePart(f);
+    final HashSet<AbstractFileSystem> result = new HashSet<AbstractFileSystem>();
+    new FSLinkResolver<Void>() {
+      public Void next(final AbstractFileSystem fs, final Path p)
+          throws IOException, UnresolvedLinkException {
+        result.add(fs);
+        fs.getFileStatus(p);
+        return null;
+      }
+    }.resolve(this, absF);
+    return result;
+  }
   
   /**
    * Class used to perform an operation on and resolve symlinks in a
@@ -2289,4 +2315,25 @@ public final class FileContext {
   public static Map<URI, Statistics> getAllStatistics() {
     return AbstractFileSystem.getAllStatistics();
   }
+  
+  /**
+   * Get delegation tokens for the file systems accessed for a given
+   * path.
+   * @param p Path for which delegations tokens are requested.
+   * @param renewer the account name that is allowed to renew the token.
+   * @return List of delegation tokens.
+   * @throws IOException
+   */
+  @InterfaceAudience.LimitedPrivate( { "HDFS", "MapReduce" })
+  public List<Token<?>> getDelegationTokens(
+      Path p, String renewer) throws IOException {
+    Set<AbstractFileSystem> afsSet = resolveAbstractFileSystems(p);
+    List<Token<?>> tokenList = 
+        new ArrayList<Token<?>>();
+    for (AbstractFileSystem afs : afsSet) {
+      List<Token<?>> afsTokens = afs.getDelegationTokens(renewer);
+      tokenList.addAll(afsTokens);
+    }
+    return tokenList;
+  }
 }

Modified: hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/FileSystem.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/FileSystem.java?rev=1095970&r1=1095969&r2=1095970&view=diff
==============================================================================
--- hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/FileSystem.java (original)
+++ hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/FileSystem.java Fri Apr
22 17:45:43 2011
@@ -50,6 +50,8 @@ import org.apache.hadoop.io.MultipleIOEx
 import org.apache.hadoop.security.SecurityUtil;
 import org.apache.hadoop.security.UserGroupInformation;
 import org.apache.hadoop.security.token.Token;
+import org.apache.hadoop.security.token.SecretManager.InvalidToken;
+import org.apache.hadoop.security.token.delegation.AbstractDelegationTokenIdentifier;
 import org.apache.hadoop.util.Progressable;
 import org.apache.hadoop.util.ReflectionUtils;
 
@@ -363,9 +365,25 @@ public abstract class FileSystem extends
    * @return a new delegation token
    * @throws IOException
    */
+  @InterfaceAudience.LimitedPrivate({"HDFS", "MapReduce"})
   public Token<?> getDelegationToken(String renewer) throws IOException {
     return null;
   }
+  
+  /**
+   * Get one or more delegation tokens associated with the filesystem. Normally
+   * a file system returns a single delegation token. A file system that manages
+   * multiple file systems underneath, could return set of delegation tokens for
+   * all the file systems it manages.
+   * 
+   * @param renewer the account name that is allowed to renew the token.
+   * @return list of new delegation tokens
+   * @throws IOException
+   */
+  @InterfaceAudience.LimitedPrivate( { "HDFS", "MapReduce" })
+  public List<Token<?>> getDelegationTokens(String renewer) throws IOException
{
+    return null;
+  }
 
   /** create a file with the provided permission
    * The permission of the file is set to be the provided permission as in

Modified: hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/FilterFileSystem.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/FilterFileSystem.java?rev=1095970&r1=1095969&r2=1095970&view=diff
==============================================================================
--- hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/FilterFileSystem.java
(original)
+++ hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/FilterFileSystem.java
Fri Apr 22 17:45:43 2011
@@ -21,11 +21,13 @@ package org.apache.hadoop.fs;
 import java.io.*;
 import java.net.URI;
 import java.util.EnumSet;
+import java.util.List;
 
 import org.apache.hadoop.classification.InterfaceAudience;
 import org.apache.hadoop.classification.InterfaceStability;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.permission.FsPermission;
+import org.apache.hadoop.security.token.Token;
 import org.apache.hadoop.util.Progressable;
 
 /****************************************************************
@@ -360,4 +362,19 @@ public class FilterFileSystem extends Fi
       throws IOException {
     return fs.primitiveMkdir(f, abdolutePermission);
   }
+  
+  @Override // FileSystem
+  public String getCanonicalServiceName() {
+    return fs.getCanonicalServiceName();
+  }
+  
+  @Override // FileSystem
+  public Token<?> getDelegationToken(String renewer) throws IOException {
+    return fs.getDelegationToken(renewer);
+  }
+  
+  @Override // FileSystem
+  public List<Token<?>> getDelegationTokens(String renewer) throws IOException
{
+    return fs.getDelegationTokens(renewer);
+  }
 }

Modified: hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/FilterFs.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/FilterFs.java?rev=1095970&r1=1095969&r2=1095970&view=diff
==============================================================================
--- hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/FilterFs.java (original)
+++ hadoop/common/branches/yahoo-merge/src/java/org/apache/hadoop/fs/FilterFs.java Fri Apr
22 17:45:43 2011
@@ -21,12 +21,14 @@ import java.io.IOException;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.util.EnumSet;
+import java.util.List;
 
 import org.apache.hadoop.classification.InterfaceAudience;
 import org.apache.hadoop.classification.InterfaceStability;
 import org.apache.hadoop.fs.FileSystem.Statistics;
 import org.apache.hadoop.fs.permission.FsPermission;
 import org.apache.hadoop.security.AccessControlException;
+import org.apache.hadoop.security.token.Token;
 import org.apache.hadoop.util.Progressable;
 
 /**
@@ -252,4 +254,14 @@ public abstract class FilterFs extends A
   public Path getLinkTarget(final Path f) throws IOException {
     return myFs.getLinkTarget(f);
   }
+  
+  @Override // AbstractFileSystem
+  public String getCanonicalServiceName() {
+    return myFs.getCanonicalServiceName();
+  }
+  
+  @Override // AbstractFileSystem
+  public List<Token<?>> getDelegationTokens(String renewer) throws IOException
{
+    return myFs.getDelegationTokens(renewer);
+  }
 }



Mime
View raw message