You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@accumulo.apache.org by "EdColeman (via GitHub)" <gi...@apache.org> on 2023/03/14 18:59:11 UTC

[GitHub] [accumulo] EdColeman commented on a diff in pull request #3167: Reuse ThreadPools where possible instead of recreating each time method is called

EdColeman commented on code in PR #3167:
URL: https://github.com/apache/accumulo/pull/3167#discussion_r1136053141


##########
server/manager/src/main/java/org/apache/accumulo/manager/Manager.java:
##########
@@ -1020,17 +1022,29 @@ private SortedMap<TServerInstance,TabletServerStatus> gatherTableInformation(
             badServers.remove(server);
           }
         }
-      });
-    }
-    tp.shutdown();
-    try {
-      tp.awaitTermination(Math.max(10000, rpcTimeout / 3), MILLISECONDS);
-    } catch (InterruptedException e) {
-      log.debug("Interrupted while fetching status");
+      }));
+    }
+    final long timeToWaitForCompletion = Math.max(10000, rpcTimeout / 3);
+    long currTime = NANOSECONDS.toMillis(System.nanoTime());
+    final long timeToCancelTasks = currTime + timeToWaitForCompletion;
+    // Wait for all tasks to complete
+    while (!tasks.isEmpty()) {
+      boolean cancel = (currTime > timeToCancelTasks);

Review Comment:
   The time returned by `System.nanoTime()` is only valid when compared relative to another nano time.  The value is relative to some arbitrary counter in the JVM and can be negative.
   
   This should be sometime like ```
   boolean cancel = ((currTime - System.nanoTime()) > MILLISECONDS.toNanos(timeToCancelTasks));
   ``` 
   
   If may also help if all times were kept as nanos - or converted to nanos for the calculations and only converting back to millis (or seconds) for display to the user.  Using one set of units consistently may help limit conversion errors if a conversion was missed.
   



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

To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org