i3wangyi commented on a change in pull request #357: [WIP] Add 
getWorkflows(long timeout) to TaskDriver.
URL: https://github.com/apache/helix/pull/357#discussion_r306580266
 
 

 ##########
 File path: helix-core/src/main/java/org/apache/helix/task/TaskDriver.java
 ##########
 @@ -850,6 +858,56 @@ public static JobConfig getJobConfig(HelixManager 
manager, String job) {
     return workflowConfigMap;
   }
 
+  /**
+   * Batch get the configurations of all workflows in this cluster
+   * within the specified timeout in milliseconds.
+   *
+   * @param timeout a long integer presents the timeout, in milliseconds
+   * @return a map of <String, WorkflowConfig>
+   * @throws InterruptedException if the future thread was interrupted
+   * @throws ExecutionException if the future task completed exceptionally
+   * @throws TimeoutException if waiting for result timed out
+   */
+  public Map<String, WorkflowConfig> getWorkflows(long timeout)
+    throws CancellationException, InterruptedException, ExecutionException, 
TimeoutException {
+    if (timeout <= 0L) {
+      throw new IllegalArgumentException("timeout must be positive.");
+    }
+    
+    ExecutorService executorService = Executors.newSingleThreadExecutor();
 
 Review comment:
   I'm afraid the underlying the executor is creating a thread pool with one 
worker. If this is the case, there's certainly overhead if each time when the 
method gets invoked, the thread gets created and deleted after the method call. 
I don't think creating a thread every time is cheap, I would suggest making it 
a private field. Also for timeout mechanism, there's better choice for you 
https://docs.oracle.com/javase/1.5.0/docs/api/java/util/concurrent/ScheduledExecutorService.html

----------------------------------------------------------------
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]


With regards,
Apache Git Services

Reply via email to