belugabehr commented on a change in pull request #1939:
URL: https://github.com/apache/hive/pull/1939#discussion_r569594294



##########
File path: ql/src/java/org/apache/hadoop/hive/ql/exec/tez/TezSessionPool.java
##########
@@ -395,20 +379,38 @@ int getInitialSize() {
     } while (!deltaRemaining.compareAndSet(oldVal, oldVal + delta));
     int toStart = oldVal + delta;
     if (toStart <= 0) return createDummyFuture();
-    LOG.info("Resizing the pool; adding " + toStart + " sessions");
-
-    // 2) If we need to create some extra sessions, we'd do it just like 
startup does.
-    int threadCount = Math.max(1, Math.min(toStart,
-        HiveConf.getIntVar(initConf, 
ConfVars.HIVE_SERVER2_TEZ_SESSION_MAX_INIT_THREADS)));
-    List<ListenableFutureTask<Boolean>> threadTasks = new 
ArrayList<>(threadCount);
-    // This is an async method, so always launch threads, even for a single 
task.
-    for (int i = 0; i < threadCount; ++i) {
-      ListenableFutureTask<Boolean> task = ListenableFutureTask.create(
-          new CreateSessionsRunnable(deltaRemaining));
-      new Thread(task, "Tez pool resize " + i).start();
-      threadTasks.add(task);
+    LOG.info("Resizing the pool; adding {} sessions", toStart);
+
+    final int threadCount =
+        Math.min(toStart, HiveConf.getIntVar(initConf, 
ConfVars.HIVE_SERVER2_TEZ_SESSION_MAX_INIT_THREADS));

Review comment:
       I would advise against that.  The first one initialized the pool, the 
second one is to increase the existing pool.  I think the naming is OK.

##########
File path: ql/src/java/org/apache/hadoop/hive/ql/exec/tez/TezSessionPool.java
##########
@@ -395,20 +379,38 @@ int getInitialSize() {
     } while (!deltaRemaining.compareAndSet(oldVal, oldVal + delta));
     int toStart = oldVal + delta;
     if (toStart <= 0) return createDummyFuture();
-    LOG.info("Resizing the pool; adding " + toStart + " sessions");
-
-    // 2) If we need to create some extra sessions, we'd do it just like 
startup does.
-    int threadCount = Math.max(1, Math.min(toStart,
-        HiveConf.getIntVar(initConf, 
ConfVars.HIVE_SERVER2_TEZ_SESSION_MAX_INIT_THREADS)));
-    List<ListenableFutureTask<Boolean>> threadTasks = new 
ArrayList<>(threadCount);
-    // This is an async method, so always launch threads, even for a single 
task.
-    for (int i = 0; i < threadCount; ++i) {
-      ListenableFutureTask<Boolean> task = ListenableFutureTask.create(
-          new CreateSessionsRunnable(deltaRemaining));
-      new Thread(task, "Tez pool resize " + i).start();
-      threadTasks.add(task);
+    LOG.info("Resizing the pool; adding {} sessions", toStart);
+
+    final int threadCount =
+        Math.min(toStart, HiveConf.getIntVar(initConf, 
ConfVars.HIVE_SERVER2_TEZ_SESSION_MAX_INIT_THREADS));
+
+    return createSessions(toStart, threadCount);
+  }
+
+  private ListenableFuture<List<Boolean>> createSessions(int sessionCount, int 
maxParallel) {

Review comment:
       Sure




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to