keith-turner commented on code in PR #6041:
URL: https://github.com/apache/accumulo/pull/6041#discussion_r2673890211


##########
core/src/main/java/org/apache/accumulo/core/clientImpl/ThriftTransportPool.java:
##########
@@ -84,18 +86,21 @@ private ThriftTransportPool(LongSupplier maxAgeMillis, 
boolean shouldHalt) {
   private Runnable thriftConnectionPoolChecker() {
     return () -> {
       try {
-        final long minNanos = MILLISECONDS.toNanos(250);
-        final long maxNanos = MINUTES.toNanos(1);
-        long lastRun = System.nanoTime();
+        final Duration minInterval = Duration.ofMillis(250);
+        final Duration maxInterval = Duration.ofMinutes(1);
+        Timer lastRunTimer = Timer.startNew();
         // loop often, to detect shutdowns quickly
         while (!connectionPool.awaitShutdown(250)) {
           // don't close on every loop; instead, check based on configured max 
age, within bounds
-          var threshold = Math.min(maxNanos,
-              Math.max(minNanos, 
MILLISECONDS.toNanos(maxAgeMillis.getAsLong()) / 2));
-          long currentNanos = System.nanoTime();
-          if ((currentNanos - lastRun) >= threshold) {
+          Duration threshold = Duration.ofMillis(maxAgeMillis.getAsLong() / 2);
+          if (threshold.compareTo(minInterval) < 0) {

Review Comment:
   Guava has Comparators.min and Comparators.max that could be used like the 
existing code uses Math.min and Math.max.  These changes are fine though, just 
pointing those out in case you were not aware.



-- 
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: [email protected]

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

Reply via email to