You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sentry.apache.org by an...@apache.org on 2016/04/05 01:37:22 UTC

sentry git commit: SENTRY-1155: Add waiting time for getMetastoreClient for avoiding metastore isn't ready (Dapeng Sun, reviewed by Anne Yu).

Repository: sentry
Updated Branches:
  refs/heads/master fd047665b -> 812159d96


SENTRY-1155: Add waiting time for getMetastoreClient for avoiding metastore isn't ready (Dapeng Sun, reviewed by Anne Yu).


Project: http://git-wip-us.apache.org/repos/asf/sentry/repo
Commit: http://git-wip-us.apache.org/repos/asf/sentry/commit/812159d9
Tree: http://git-wip-us.apache.org/repos/asf/sentry/tree/812159d9
Diff: http://git-wip-us.apache.org/repos/asf/sentry/diff/812159d9

Branch: refs/heads/master
Commit: 812159d9608c7ccd5c777a877ea678642a17437b
Parents: fd04766
Author: Anne Yu <an...@apache.org>
Authored: Mon Apr 4 17:04:36 2016 -0700
Committer: Anne Yu <an...@apache.org>
Committed: Mon Apr 4 17:08:10 2016 -0700

----------------------------------------------------------------------
 .../apache/sentry/tests/e2e/hive/Context.java   | 26 ++++++++++++++------
 1 file changed, 19 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sentry/blob/812159d9/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/Context.java
----------------------------------------------------------------------
diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/Context.java b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/Context.java
index 2e508d6..a92d8c9 100644
--- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/Context.java
+++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/Context.java
@@ -257,13 +257,25 @@ public class Context {
   // TODO: Handle kerberos login
   public HiveMetaStoreClient getMetaStoreClient(String userName) throws Exception {
     UserGroupInformation clientUgi = UserGroupInformation.createRemoteUser(userName);
-    HiveMetaStoreClient client = (HiveMetaStoreClient) clientUgi.
-        doAs(new PrivilegedExceptionAction<Object> () {
-          @Override
-          public HiveMetaStoreClient run() throws Exception {
-            return new HiveMetaStoreClient(new HiveConf());
-          }
-        });
+    HiveMetaStoreClient client = null;
+    try {
+      client = clientUgi.doAs(new PrivilegedExceptionAction<HiveMetaStoreClient>() {
+        @Override
+        public HiveMetaStoreClient run() throws Exception {
+          return new HiveMetaStoreClient(new HiveConf());
+        }
+      });
+    } catch (Throwable e) {
+      // The metastore may don't finish the initialization, wait for 10s for the
+      // initialization.
+      Thread.sleep(10 * 1000);
+      client = clientUgi.doAs(new PrivilegedExceptionAction<HiveMetaStoreClient>() {
+        @Override
+        public HiveMetaStoreClient run() throws Exception {
+          return new HiveMetaStoreClient(new HiveConf());
+        }
+      });
+    }
     return client;
   }