diff --git a/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcWithMiniHS2.java b/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcWithMiniHS2.java index d7d7097336fc6be4c2f7a35cd6897e0375486e81..b536c5a5b1e8a7c68c77b5221cb3fb4b07725fc3 100644 --- a/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcWithMiniHS2.java +++ b/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcWithMiniHS2.java @@ -279,6 +279,56 @@ public void testParallelCompilation2() throws Exception { startConcurrencyTest(conn, tableName, 10); conn.close(); } + + @Test + public void testParallelCompilation3() throws Exception { + Statement stmt = conTestDb.createStatement(); + stmt.execute("set hive.driver.parallel.compilation=true"); + stmt.execute("set hive.server2.async.exec.async.compile=true"); + stmt.close(); + Connection conn = getConnection(testDbName); + stmt = conn.createStatement(); + stmt.execute("set hive.driver.parallel.compilation=true"); + stmt.execute("set hive.server2.async.exec.async.compile=true"); + stmt.close(); + int POOL_SIZE = 100; + SynchronousQueue executorQueue1 = new SynchronousQueue(); + ExecutorService workers1 = + new ThreadPoolExecutor(1, POOL_SIZE, 20, TimeUnit.SECONDS, executorQueue1); + SynchronousQueue executorQueue2 = new SynchronousQueue(); + ExecutorService workers2 = + new ThreadPoolExecutor(1, POOL_SIZE, 20, TimeUnit.SECONDS, executorQueue2); + List> list1 = startTaskes(workers1, conTestDb, tableName, 10); + List> list2 = startTaskes(workers2, conn, tableName, 10); + finishTasks(list1,workers1); + finishTasks(list2,workers2); + conn.close(); + } + + @Test + public void testParallelCompilation4() throws Exception { + Statement stmt = conTestDb.createStatement(); + stmt.execute("set hive.driver.parallel.compilation=true"); + stmt.execute("set hive.server2.async.exec.async.compile=false"); + stmt.close(); + Connection conn = getConnection(testDbName); + stmt = conn.createStatement(); + stmt.execute("set hive.driver.parallel.compilation=true"); + stmt.execute("set hive.server2.async.exec.async.compile=false"); + stmt.close(); + int POOL_SIZE = 100; + SynchronousQueue executorQueue1 = new SynchronousQueue(); + ExecutorService workers1 = + new ThreadPoolExecutor(1, POOL_SIZE, 20, TimeUnit.SECONDS, executorQueue1); + SynchronousQueue executorQueue2 = new SynchronousQueue(); + ExecutorService workers2 = + new ThreadPoolExecutor(1, POOL_SIZE, 20, TimeUnit.SECONDS, executorQueue2); + List> list1 = startTaskes(workers1, conTestDb, tableName, 10); + List> list2 = startTaskes(workers2, conn, tableName, 10); + finishTasks(list1,workers1); + finishTasks(list2,workers2); + conn.close(); + } @Test public void testConcurrentStatements() throws Exception { @@ -288,14 +338,17 @@ public void testConcurrentStatements() throws Exception { private static void startConcurrencyTest(Connection conn, String tableName, int numTasks) { // Start concurrent testing int POOL_SIZE = 100; - int TASK_COUNT = numTasks; - SynchronousQueue executorQueue = new SynchronousQueue(); ExecutorService workers = new ThreadPoolExecutor(1, POOL_SIZE, 20, TimeUnit.SECONDS, executorQueue); + List> list = startTaskes(workers, conn, tableName, numTasks); + finishTasks(list,workers); + } + + private static List> startTaskes(ExecutorService workers, Connection conn, String tableName, int numTasks) { List> list = new ArrayList>(); int i = 0; - while (i < TASK_COUNT) { + while (i < numTasks) { try { Future future = workers.submit(new JDBCTask(conn, i, tableName)); list.add(future); @@ -308,7 +361,10 @@ private static void startConcurrencyTest(Connection conn, String tableName, int } } } - + return list; + } + + private static void finishTasks (List> list, ExecutorService workers) { for (Future future : list) { try { Boolean result = future.get(30, TimeUnit.SECONDS); @@ -323,7 +379,7 @@ private static void startConcurrencyTest(Connection conn, String tableName, int System.out.println("Thread was interrupted: " + ie); } } - workers.shutdown(); + workers.shutdown(); } static class JDBCTask implements Callable {