You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by ha...@apache.org on 2013/07/25 02:15:07 UTC

svn commit: r1506785 [8/8] - in /hive/branches/vectorization: ./ beeline/src/java/org/apache/hive/beeline/ cli/src/java/org/apache/hadoop/hive/cli/ common/src/java/org/apache/hadoop/hive/conf/ conf/ contrib/src/test/results/clientnegative/ data/files/ ...

Modified: hive/branches/vectorization/shims/src/common-secure/test/org/apache/hadoop/hive/thrift/TestHadoop20SAuthBridge.java
URL: http://svn.apache.org/viewvc/hive/branches/vectorization/shims/src/common-secure/test/org/apache/hadoop/hive/thrift/TestHadoop20SAuthBridge.java?rev=1506785&r1=1506784&r2=1506785&view=diff
==============================================================================
--- hive/branches/vectorization/shims/src/common-secure/test/org/apache/hadoop/hive/thrift/TestHadoop20SAuthBridge.java (original)
+++ hive/branches/vectorization/shims/src/common-secure/test/org/apache/hadoop/hive/thrift/TestHadoop20SAuthBridge.java Thu Jul 25 00:14:58 2013
@@ -35,7 +35,6 @@ import junit.framework.TestCase;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.hive.conf.HiveConf;
-import org.apache.hadoop.hive.conf.HiveConf.ConfVars;
 import org.apache.hadoop.hive.metastore.HiveMetaStore;
 import org.apache.hadoop.hive.metastore.HiveMetaStoreClient;
 import org.apache.hadoop.hive.metastore.MetaStoreUtils;
@@ -59,6 +58,12 @@ import org.apache.thrift.transport.TTran
 
 public class TestHadoop20SAuthBridge extends TestCase {
 
+  /**
+   * set to true when metastore token manager has intitialized token manager
+   * through call to HadoopThriftAuthBridge20S.Server.startDelegationTokenSecretManager
+   */
+  static volatile boolean isMetastoreTokenManagerInited;
+
   private static class MyHadoopThriftAuthBridge20S extends HadoopThriftAuthBridge20S {
     @Override
     public Server createServer(String keytabFile, String principalConf)
@@ -67,6 +72,8 @@ public class TestHadoop20SAuthBridge ext
       return new Server();
     }
 
+
+
     static class Server extends HadoopThriftAuthBridge20S.Server {
       public Server() throws TTransportException {
         super();
@@ -89,6 +96,14 @@ public class TestHadoop20SAuthBridge ext
       protected DelegationTokenStore getTokenStore(Configuration conf) throws IOException {
         return TOKEN_STORE;
       }
+
+      @Override
+      public void startDelegationTokenSecretManager(Configuration conf)
+      throws IOException{
+        super.startDelegationTokenSecretManager(conf);
+        isMetastoreTokenManagerInited = true;
+      }
+
     }
   }
 
@@ -120,6 +135,7 @@ public class TestHadoop20SAuthBridge ext
   }
 
   public void setup() throws Exception {
+    isMetastoreTokenManagerInited = false;
     int port = findFreePort();
     System.setProperty(HiveConf.ConfVars.METASTORE_USE_THRIFT_SASL.varname,
         "true");
@@ -292,6 +308,9 @@ public class TestHadoop20SAuthBridge ext
     //metastore checks whether the authentication method is KERBEROS or not
     //for getDelegationToken, and the testcases don't use
     //kerberos, this needs to be done
+
+    waitForMetastoreTokenInit();
+
     HadoopThriftAuthBridge20S.Server.authenticationMethod
                              .set(AuthenticationMethod.KERBEROS);
     HadoopThriftAuthBridge20S.Server.remoteAddress.set(InetAddress.getLocalHost());
@@ -300,6 +319,20 @@ public class TestHadoop20SAuthBridge ext
             realUgi.getShortUserName());
   }
 
+  /**
+   * Wait for metastore to have initialized token manager
+   * This does not have to be done in other metastore test cases as they
+   * use metastore client which will retry few times on failure
+   * @throws InterruptedException
+   */
+  private void waitForMetastoreTokenInit() throws InterruptedException {
+    int waitAttempts = 30;
+    while(waitAttempts > 0 && !isMetastoreTokenManagerInited){
+      Thread.sleep(1000);
+      waitAttempts--;
+    }
+  }
+
   private void obtainTokenAndAddIntoUGI(UserGroupInformation clientUgi,
       String tokenSig) throws Exception {
     String tokenStrForm = getDelegationTokenStr(clientUgi, clientUgi);