hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r1211749 - in /hadoop/common/branches/HDFS-1623/hadoop-common-project: hadoop-auth/src/main/java/org/apache/hadoop/security/authentication/server/ hadoop-auth/src/main/java/org/apache/hadoop/security/authentication/util/ hadoop-auth/src/tes...
Date Thu, 08 Dec 2011 02:57:49 GMT
Author: atm
Date: Thu Dec  8 02:57:47 2011
New Revision: 1211749

URL: http://svn.apache.org/viewvc?rev=1211749&view=rev
Log:
Merge trunk into HA branch.

Modified:
    hadoop/common/branches/HDFS-1623/hadoop-common-project/hadoop-auth/src/main/java/org/apache/hadoop/security/authentication/server/KerberosAuthenticationHandler.java
    hadoop/common/branches/HDFS-1623/hadoop-common-project/hadoop-auth/src/main/java/org/apache/hadoop/security/authentication/util/KerberosName.java
    hadoop/common/branches/HDFS-1623/hadoop-common-project/hadoop-auth/src/test/java/org/apache/hadoop/security/authentication/server/TestKerberosAuthenticationHandler.java
    hadoop/common/branches/HDFS-1623/hadoop-common-project/hadoop-common/CHANGES.txt   (contents,
props changed)
    hadoop/common/branches/HDFS-1623/hadoop-common-project/hadoop-common/src/main/docs/  
(props changed)
    hadoop/common/branches/HDFS-1623/hadoop-common-project/hadoop-common/src/main/java/  
(props changed)
    hadoop/common/branches/HDFS-1623/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileStatus.java
    hadoop/common/branches/HDFS-1623/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/retry/RetryInvocationHandler.java
    hadoop/common/branches/HDFS-1623/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/HadoopKerberosName.java
    hadoop/common/branches/HDFS-1623/hadoop-common-project/hadoop-common/src/test/core/  
(props changed)
    hadoop/common/branches/HDFS-1623/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/retry/TestFailoverProxy.java

Modified: hadoop/common/branches/HDFS-1623/hadoop-common-project/hadoop-auth/src/main/java/org/apache/hadoop/security/authentication/server/KerberosAuthenticationHandler.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-1623/hadoop-common-project/hadoop-auth/src/main/java/org/apache/hadoop/security/authentication/server/KerberosAuthenticationHandler.java?rev=1211749&r1=1211748&r2=1211749&view=diff
==============================================================================
--- hadoop/common/branches/HDFS-1623/hadoop-common-project/hadoop-auth/src/main/java/org/apache/hadoop/security/authentication/server/KerberosAuthenticationHandler.java
(original)
+++ hadoop/common/branches/HDFS-1623/hadoop-common-project/hadoop-auth/src/main/java/org/apache/hadoop/security/authentication/server/KerberosAuthenticationHandler.java
Thu Dec  8 02:57:47 2011
@@ -55,6 +55,8 @@ import java.util.Set;
  * It does not have a default value.</li>
  * <li>kerberos.keytab: the keytab file containing the credentials for the Kerberos
principal.
  * It does not have a default value.</li>
+ * <li>kerberos.name.rules: kerberos names rules to resolve principal names, see 
+ * {@link KerberosName#setRules(String)}</li>
  * </ul>
  */
 public class KerberosAuthenticationHandler implements AuthenticationHandler {
@@ -151,6 +153,11 @@ public class KerberosAuthenticationHandl
         throw new ServletException("Keytab does not exist: " + keytab);
       }
 
+      String nameRules = config.getProperty(NAME_RULES, null);
+      if (nameRules != null) {
+        KerberosName.setRules(nameRules);
+      }
+      
       Set<Principal> principals = new HashSet<Principal>();
       principals.add(new KerberosPrincipal(principal));
       Subject subject = new Subject(false, principals, new HashSet<Object>(), new HashSet<Object>());

Modified: hadoop/common/branches/HDFS-1623/hadoop-common-project/hadoop-auth/src/main/java/org/apache/hadoop/security/authentication/util/KerberosName.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-1623/hadoop-common-project/hadoop-auth/src/main/java/org/apache/hadoop/security/authentication/util/KerberosName.java?rev=1211749&r1=1211748&r2=1211749&view=diff
==============================================================================
--- hadoop/common/branches/HDFS-1623/hadoop-common-project/hadoop-auth/src/main/java/org/apache/hadoop/security/authentication/util/KerberosName.java
(original)
+++ hadoop/common/branches/HDFS-1623/hadoop-common-project/hadoop-auth/src/main/java/org/apache/hadoop/security/authentication/util/KerberosName.java
Thu Dec  8 02:57:47 2011
@@ -385,6 +385,15 @@ public class KerberosName {
     rules = parseRules(ruleString);
   }
 
+  /**
+   * Indicates if the name rules have been set.
+   * 
+   * @return if the name rules have been set.
+   */
+  public static boolean hasRulesBeenSet() {
+    return rules != null;
+  }
+  
   static void printRules() throws IOException {
     int i = 0;
     for(Rule r: rules) {

Modified: hadoop/common/branches/HDFS-1623/hadoop-common-project/hadoop-auth/src/test/java/org/apache/hadoop/security/authentication/server/TestKerberosAuthenticationHandler.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-1623/hadoop-common-project/hadoop-auth/src/test/java/org/apache/hadoop/security/authentication/server/TestKerberosAuthenticationHandler.java?rev=1211749&r1=1211748&r2=1211749&view=diff
==============================================================================
--- hadoop/common/branches/HDFS-1623/hadoop-common-project/hadoop-auth/src/test/java/org/apache/hadoop/security/authentication/server/TestKerberosAuthenticationHandler.java
(original)
+++ hadoop/common/branches/HDFS-1623/hadoop-common-project/hadoop-auth/src/test/java/org/apache/hadoop/security/authentication/server/TestKerberosAuthenticationHandler.java
Thu Dec  8 02:57:47 2011
@@ -18,6 +18,7 @@ import org.apache.hadoop.security.authen
 import org.apache.hadoop.security.authentication.client.KerberosAuthenticator;
 import junit.framework.TestCase;
 import org.apache.commons.codec.binary.Base64;
+import org.apache.hadoop.security.authentication.util.KerberosName;
 import org.ietf.jgss.GSSContext;
 import org.ietf.jgss.GSSManager;
 import org.ietf.jgss.GSSName;
@@ -59,6 +60,35 @@ public class TestKerberosAuthenticationH
     super.tearDown();
   }
 
+  public void testNameRules() throws Exception {
+    KerberosName kn = new KerberosName(KerberosTestUtils.getServerPrincipal());
+    assertEquals(KerberosTestUtils.getRealm(), kn.getRealm());
+
+    //destroy handler created in setUp()
+    handler.destroy();
+
+    KerberosName.setRules("RULE:[1:$1@$0](.*@FOO)s/@.*//\nDEFAULT");
+    
+    handler = new KerberosAuthenticationHandler();
+    Properties props = new Properties();
+    props.setProperty(KerberosAuthenticationHandler.PRINCIPAL, KerberosTestUtils.getServerPrincipal());
+    props.setProperty(KerberosAuthenticationHandler.KEYTAB, KerberosTestUtils.getKeytabFile());
+    props.setProperty(KerberosAuthenticationHandler.NAME_RULES, "RULE:[1:$1@$0](.*@BAR)s/@.*//\nDEFAULT");
+    try {
+      handler.init(props);
+    } catch (Exception ex) {
+    }
+    kn = new KerberosName("bar@BAR");
+    assertEquals("bar", kn.getShortName());
+    kn = new KerberosName("bar@FOO");
+    try {
+      kn.getShortName();
+      fail();
+    }
+    catch (Exception ex) {      
+    }
+  }
+  
   public void testInit() throws Exception {
     assertEquals(KerberosTestUtils.getServerPrincipal(), handler.getPrincipal());
     assertEquals(KerberosTestUtils.getKeytabFile(), handler.getKeytab());

Modified: hadoop/common/branches/HDFS-1623/hadoop-common-project/hadoop-common/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-1623/hadoop-common-project/hadoop-common/CHANGES.txt?rev=1211749&r1=1211748&r2=1211749&view=diff
==============================================================================
--- hadoop/common/branches/HDFS-1623/hadoop-common-project/hadoop-common/CHANGES.txt (original)
+++ hadoop/common/branches/HDFS-1623/hadoop-common-project/hadoop-common/CHANGES.txt Thu Dec
 8 02:57:47 2011
@@ -72,6 +72,8 @@ Trunk (unreleased changes)
     HADOOP-7876. Provided access to encoded key in DelegationKey for
     use in protobuf based RPCs. (suresh)
 
+    HADOOP-7886. Add toString to FileStatus. (SreeHari via jghoman)
+
   BUGS
 
     HADOOP-7606. Upgrade Jackson to version 1.7.1 to match the version required
@@ -115,6 +117,12 @@ Trunk (unreleased changes)
 
     HADOOP-7874. native libs should be under lib/native/ dir. (tucu)
 
+    HADOOP-7887. KerberosAuthenticatorHandler is not setting
+    KerberosName name rules from configuration. (tucu)
+
+    HADOOP-7888. TestFailoverProxy fails intermittently on trunk. (Jason Lowe
+                 via atm)
+
   OPTIMIZATIONS
 
     HADOOP-7761. Improve the performance of raw comparisons. (todd)

Propchange: hadoop/common/branches/HDFS-1623/hadoop-common-project/hadoop-common/CHANGES.txt
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Dec  8 02:57:47 2011
@@ -1,5 +1,5 @@
 /hadoop/common/branches/yahoo-merge/CHANGES.txt:1079157,1079163-1079164,1079167
-/hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt:1161333-1210544
+/hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt:1161333-1211747
 /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

Propchange: hadoop/common/branches/HDFS-1623/hadoop-common-project/hadoop-common/src/main/docs/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Dec  8 02:57:47 2011
@@ -1,2 +1,2 @@
-/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/docs:1152502-1210544
+/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/docs:1152502-1211747
 /hadoop/core/branches/branch-0.19/src/docs:713112

Propchange: hadoop/common/branches/HDFS-1623/hadoop-common-project/hadoop-common/src/main/java/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Dec  8 02:57:47 2011
@@ -1,3 +1,3 @@
-/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java:1152502-1210544
+/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java:1152502-1211747
 /hadoop/core/branches/branch-0.19/core/src/java:713112
 /hadoop/core/trunk/src/core:776175-785643,785929-786278

Modified: hadoop/common/branches/HDFS-1623/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileStatus.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-1623/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileStatus.java?rev=1211749&r1=1211748&r2=1211749&view=diff
==============================================================================
--- hadoop/common/branches/HDFS-1623/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileStatus.java
(original)
+++ hadoop/common/branches/HDFS-1623/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileStatus.java
Thu Dec  8 02:57:47 2011
@@ -331,4 +331,23 @@ public class FileStatus implements Writa
   public int hashCode() {
     return getPath().hashCode();
   }
+  
+  @Override
+  public String toString() {
+    StringBuilder sb = new StringBuilder();
+    sb.append(getClass().getSimpleName()); 
+    sb.append("{");
+    sb.append("path=" + path);
+    sb.append("; isDirectory=" + isdir);
+    if(!isDirectory()){
+      sb.append("; length=" + length);
+      sb.append("; replication=" + block_replication);
+      sb.append("; blocksize=" + blocksize);
+    }
+    sb.append("; owner=" + owner);
+    sb.append("; group=" + group);
+    sb.append("; permission=" + permission);
+    sb.append("}");
+    return sb.toString();
+  }
 }

Modified: hadoop/common/branches/HDFS-1623/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/retry/RetryInvocationHandler.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-1623/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/retry/RetryInvocationHandler.java?rev=1211749&r1=1211748&r2=1211749&view=diff
==============================================================================
--- hadoop/common/branches/HDFS-1623/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/retry/RetryInvocationHandler.java
(original)
+++ hadoop/common/branches/HDFS-1623/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/retry/RetryInvocationHandler.java
Thu Dec  8 02:57:47 2011
@@ -103,15 +103,12 @@ class RetryInvocationHandler implements 
             if (invocationAttemptFailoverCount == proxyProviderFailoverCount) {
               proxyProvider.performFailover(currentProxy);
               proxyProviderFailoverCount++;
+              currentProxy = proxyProvider.getProxy();
             } else {
               LOG.warn("A failover has occurred since the start of this method"
                   + " invocation attempt.");
             }
           }
-          // The call to getProxy() could technically only be made in the event
-          // performFailover() is called, but it needs to be out here for the
-          // purpose of testing.
-          currentProxy = proxyProvider.getProxy();
           invocationFailoverCount++;
         }
         if(LOG.isDebugEnabled()) {

Modified: hadoop/common/branches/HDFS-1623/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/HadoopKerberosName.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-1623/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/HadoopKerberosName.java?rev=1211749&r1=1211748&r2=1211749&view=diff
==============================================================================
--- hadoop/common/branches/HDFS-1623/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/HadoopKerberosName.java
(original)
+++ hadoop/common/branches/HDFS-1623/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/HadoopKerberosName.java
Thu Dec  8 02:57:47 2011
@@ -56,12 +56,19 @@ public class HadoopKerberosName extends 
   }
   /**
    * Set the static configuration to get the rules.
+   * <p/>
+   * IMPORTANT: This method does a NOP if the rules have been set already.
+   * If there is a need to reset the rules, the {@link KerberosName#setRules(String)}
+   * method should be invoked directly.
+   * 
    * @param conf the new configuration
    * @throws IOException
    */
   public static void setConfiguration(Configuration conf) throws IOException {
-    String ruleString = conf.get("hadoop.security.auth_to_local", "DEFAULT");
-    setRules(ruleString);
+    if (!hasRulesBeenSet()) {
+      String ruleString = conf.get("hadoop.security.auth_to_local", "DEFAULT");
+      setRules(ruleString);
+    }
   }
 
   public static void main(String[] args) throws Exception {

Propchange: hadoop/common/branches/HDFS-1623/hadoop-common-project/hadoop-common/src/test/core/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Dec  8 02:57:47 2011
@@ -1,3 +1,3 @@
-/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/core:1152502-1210544
+/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/core:1152502-1211747
 /hadoop/core/branches/branch-0.19/core/src/test/core:713112
 /hadoop/core/trunk/src/test/core:776175-785643,785929-786278

Modified: hadoop/common/branches/HDFS-1623/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/retry/TestFailoverProxy.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-1623/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/retry/TestFailoverProxy.java?rev=1211749&r1=1211748&r2=1211749&view=diff
==============================================================================
--- hadoop/common/branches/HDFS-1623/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/retry/TestFailoverProxy.java
(original)
+++ hadoop/common/branches/HDFS-1623/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/retry/TestFailoverProxy.java
Thu Dec  8 02:57:47 2011
@@ -36,34 +36,18 @@ public class TestFailoverProxy {
     private Object impl1;
     private Object impl2;
     
-    private boolean latchEnabled = false;
-    private CountDownLatch getProxyLatch;
     private int failoversOccurred = 0;
     
     public FlipFlopProxyProvider(Class<?> iface, Object activeImpl,
-        Object standbyImpl, int getProxyCountDown) {
+        Object standbyImpl) {
       this.iface = iface;
       this.impl1 = activeImpl;
       this.impl2 = standbyImpl;
       currentlyActive = impl1;
-      getProxyLatch = new CountDownLatch(getProxyCountDown);
-    }
-    
-    public FlipFlopProxyProvider(Class<?> iface, Object activeImpl,
-        Object standbyImpl) {
-      this(iface, activeImpl, standbyImpl, 0);
     }
     
     @Override
     public Object getProxy() {
-      if (latchEnabled) {
-        getProxyLatch.countDown();
-        try {
-          getProxyLatch.await();
-        } catch (InterruptedException e) {
-          throw new RuntimeException(e);
-        }
-      }
       return currentlyActive;
     }
 
@@ -83,10 +67,6 @@ public class TestFailoverProxy {
       // Nothing to do.
     }
     
-    public void setLatchEnabled(boolean latchEnabled) {
-      this.latchEnabled = latchEnabled;
-    }
-    
     public int getFailoversOccurred() {
       return failoversOccurred;
     }
@@ -214,6 +194,32 @@ public class TestFailoverProxy {
     assertEquals("impl2", unreliable.succeedsOnceThenFailsReturningStringIdempotent());
   }
   
+  private static class SynchronizedUnreliableImplementation extends UnreliableImplementation
{
+    
+    private CountDownLatch methodLatch;
+    
+    public SynchronizedUnreliableImplementation(String identifier,
+        TypeOfExceptionToFailWith exceptionToFailWith, int threadCount) {
+      super(identifier, exceptionToFailWith);
+      
+      methodLatch = new CountDownLatch(threadCount);
+    }
+
+    @Override
+    public String failsIfIdentifierDoesntMatch(String identifier)
+        throws UnreliableException, StandbyException, IOException {
+      // Wait until all threads are trying to invoke this method
+      methodLatch.countDown();
+      try {
+        methodLatch.await();
+      } catch (InterruptedException e) {
+        throw new RuntimeException(e);
+      }
+      return super.failsIfIdentifierDoesntMatch(identifier);
+    }
+    
+  }
+  
   private static class ConcurrentMethodThread extends Thread {
     
     private UnreliableInterface unreliable;
@@ -240,11 +246,11 @@ public class TestFailoverProxy {
   public void testConcurrentMethodFailures() throws InterruptedException {
     FlipFlopProxyProvider proxyProvider = new FlipFlopProxyProvider(
         UnreliableInterface.class,
-        new UnreliableImplementation("impl1",
-            TypeOfExceptionToFailWith.STANDBY_EXCEPTION),
+        new SynchronizedUnreliableImplementation("impl1",
+            TypeOfExceptionToFailWith.STANDBY_EXCEPTION,
+            2),
         new UnreliableImplementation("impl2",
-            TypeOfExceptionToFailWith.STANDBY_EXCEPTION),
-        2);
+            TypeOfExceptionToFailWith.STANDBY_EXCEPTION));
     
     final UnreliableInterface unreliable = (UnreliableInterface)RetryProxy
       .create(UnreliableInterface.class, proxyProvider,
@@ -253,9 +259,6 @@ public class TestFailoverProxy {
     ConcurrentMethodThread t1 = new ConcurrentMethodThread(unreliable);
     ConcurrentMethodThread t2 = new ConcurrentMethodThread(unreliable);
     
-    // Getting a proxy will now wait on a latch.
-    proxyProvider.setLatchEnabled(true);
-    
     t1.start();
     t2.start();
     t1.join();



Mime
View raw message