sentry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vam...@apache.org
Subject sentry git commit: SENTRY-1586: [unit test] Race condition between metastore server/client could cause connection refused errors (Vamsee Yarlagadda, Reviewed by: Alexander Kolbasov)
Date Thu, 05 Jan 2017 02:59:48 GMT
Repository: sentry
Updated Branches:
  refs/heads/sentry-ha-redesign 31cd4d0d4 -> cf8a16f2a


SENTRY-1586: [unit test] Race condition between metastore server/client could cause connection
refused errors (Vamsee Yarlagadda, Reviewed by: Alexander Kolbasov)


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

Branch: refs/heads/sentry-ha-redesign
Commit: cf8a16f2ae2c7aa5a0cf49d81e8de13f598c3c10
Parents: 31cd4d0
Author: Vamsee Yarlagadda <vamsee@cloudera.com>
Authored: Wed Jan 4 17:14:32 2017 -0800
Committer: Vamsee Yarlagadda <vamsee@cloudera.com>
Committed: Wed Jan 4 18:51:16 2017 -0800

----------------------------------------------------------------------
 .../hive/hiveserver/InternalMetastoreServer.java | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sentry/blob/cf8a16f2/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/hiveserver/InternalMetastoreServer.java
----------------------------------------------------------------------
diff --git a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/hiveserver/InternalMetastoreServer.java
b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/hiveserver/InternalMetastoreServer.java
index bf43798..27ea178 100644
--- a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/hiveserver/InternalMetastoreServer.java
+++ b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hive/hiveserver/InternalMetastoreServer.java
@@ -21,6 +21,10 @@ import java.net.URI;
 import java.util.concurrent.Callable;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.locks.Condition;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
 
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hive.conf.HiveConf;
@@ -54,18 +58,31 @@ public class InternalMetastoreServer extends AbstractHiveServer {
 
   // async metastore startup since Hive doesn't have that option
   private void startMetastore() throws Exception {
+    final Lock startLock = new ReentrantLock();
+    final Condition startCondition = startLock.newCondition();
+    final AtomicBoolean startedServing = new AtomicBoolean();
     Callable<Void> metastoreService = new Callable<Void>() {
       public Void call() throws Exception {
         try {
           HiveMetaStore.startMetaStore(getMetastorePort(conf),
-              ShimLoader.getHadoopThriftAuthBridge(), conf);
+              ShimLoader.getHadoopThriftAuthBridge(), conf, startLock, startCondition, startedServing);
         } catch (Throwable e) {
           throw new Exception("Error starting metastore", e);
         }
         return null;
       }
     };
+
+    // Wait for metastore server to initialize completely before letting tests connect to
it.
+    startLock.lock();
     metaStoreExecutor.submit(metastoreService);
+    try {
+      while (!startedServing.get()) {
+        startCondition.await();
+      }
+    } finally {
+      startLock.unlock();
+    }
   }
 
   private static String getMetastoreHostname(Configuration conf)


Mime
View raw message