DomGarguilo commented on code in PR #6041:
URL: https://github.com/apache/accumulo/pull/6041#discussion_r2676491246


##########
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:
   Thanks for pointing that out, I did not know of those. As I was writing this 
code I was wondering why there wasn't an equivalent for Duration variables but 
never looked into it. 
   
   Added in 17dd12df38119e0501409e8d69462451b5a07048



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