浏览代码

MAPREDUCE-3392. Fixed Cluster's getDelegationToken's API to return null when there isn't a supported token. (John George via vinodkv) - Merging r1200484 from trunk

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.23.0@1201064 13f79535-47bb-0310-9956-ffa450edef68
Mahadev Konar 13 年之前
父节点
当前提交
c74c717982

+ 3 - 0
hadoop-mapreduce-project/CHANGES.txt

@@ -3,6 +3,9 @@ Hadoop MapReduce Change Log
     MAPREDUCE-3291. App fail to launch due to delegation token not 
     found in cache (Robert Evans via mahadev)
 
+    MAPREDUCE-3392. Fixed Cluster's getDelegationToken's API to return null
+    when there isn't a supported token. (John George via vinodkv)
+
 Release 0.23.0 - 2011-11-01 
 
   INCOMPATIBLE CHANGES

+ 5 - 0
hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/Cluster.java

@@ -390,6 +390,11 @@ public class Cluster {
       getDelegationToken(Text renewer) throws IOException, InterruptedException{
     Token<DelegationTokenIdentifier> result =
       client.getDelegationToken(renewer);
+
+    if (result == null) {
+      return result;
+    }
+
     InetSocketAddress addr = Master.getMasterAddress(conf);
     StringBuilder service = new StringBuilder();
     service.append(NetUtils.normalizeHostName(addr.getAddress().

+ 20 - 0
hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapreduce/TestYarnClientProtocolProvider.java

@@ -25,6 +25,7 @@ import junit.framework.TestCase;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.mapred.YARNRunner;
 import org.apache.hadoop.mapreduce.protocol.ClientProtocol;
+import org.apache.hadoop.io.Text;
 import org.junit.Test;
 
 public class TestYarnClientProtocolProvider extends TestCase {
@@ -56,4 +57,23 @@ public class TestYarnClientProtocolProvider extends TestCase {
       }
     }
   }
+
+ 
+  @Test
+  public void testClusterGetDelegationToken() throws Exception {
+
+    Configuration conf = new Configuration(false);
+    Cluster cluster = null;
+    try {
+      conf = new Configuration();
+      conf.set(MRConfig.FRAMEWORK_NAME, MRConfig.YARN_FRAMEWORK_NAME);
+      cluster = new Cluster(conf);
+      cluster.getDelegationToken(new Text(" "));
+    } finally {
+      if (cluster != null) {
+        cluster.close();
+      }
+    }
+  }
+
 }