This is an automated email from the ASF dual-hosted git repository.

DomGarguilo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/accumulo.git


The following commit(s) were added to refs/heads/main by this push:
     new e761b5b22e Use Duration for TestTicker.advance() and 
stopProcessesWithTimeout() (#6637)
e761b5b22e is described below

commit e761b5b22e074fa2236674f66fd921b5637e9d0c
Author: Dom G. <[email protected]>
AuthorDate: Mon Nov 9 11:14:13 2026 -0500

    Use Duration for TestTicker.advance() and stopProcessesWithTimeout() (#6637)
---
 .../miniclusterImpl/MiniAccumuloClusterControl.java     | 17 +++++++++--------
 .../miniclusterImpl/MiniAccumuloClusterImpl.java        |  6 +++---
 .../conf/store/impl/PropCacheCaffeineImplTest.java      |  8 ++++----
 .../server/conf/store/impl/ZooPropLoaderTest.java       | 10 +++++-----
 .../accumulo/test/conf/store/ZooBasedConfigIT.java      |  8 ++++----
 5 files changed, 25 insertions(+), 24 deletions(-)

diff --git 
a/minicluster/src/main/java/org/apache/accumulo/miniclusterImpl/MiniAccumuloClusterControl.java
 
b/minicluster/src/main/java/org/apache/accumulo/miniclusterImpl/MiniAccumuloClusterControl.java
index 2495a88688..8462a7e019 100644
--- 
a/minicluster/src/main/java/org/apache/accumulo/miniclusterImpl/MiniAccumuloClusterControl.java
+++ 
b/minicluster/src/main/java/org/apache/accumulo/miniclusterImpl/MiniAccumuloClusterControl.java
@@ -21,6 +21,7 @@ package org.apache.accumulo.miniclusterImpl;
 import static java.util.Objects.requireNonNull;
 
 import java.io.IOException;
+import java.time.Duration;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
@@ -55,6 +56,7 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 
 public class MiniAccumuloClusterControl implements ClusterControl {
   private static final Logger log = 
LoggerFactory.getLogger(MiniAccumuloClusterControl.class);
+  private static final Duration STOP_TIMEOUT = Duration.ofSeconds(60);
 
   protected MiniAccumuloClusterImpl cluster;
 
@@ -291,7 +293,7 @@ public class MiniAccumuloClusterControl implements 
ClusterControl {
       if (group == null) {
         return;
       }
-      cluster.stopProcessesWithTimeout(ServerType.COMPACTOR, group, 60, 
TimeUnit.SECONDS);
+      cluster.stopProcessesWithTimeout(ServerType.COMPACTOR, group, 
STOP_TIMEOUT);
       compactorProcesses.remove(compactorResourceGroup);
     }
   }
@@ -302,7 +304,7 @@ public class MiniAccumuloClusterControl implements 
ClusterControl {
       if (group == null) {
         return;
       }
-      cluster.stopProcessesWithTimeout(ServerType.SCAN_SERVER, group, 60, 
TimeUnit.SECONDS);
+      cluster.stopProcessesWithTimeout(ServerType.SCAN_SERVER, group, 
STOP_TIMEOUT);
       scanServerProcesses.remove(sserverResourceGroup);
     }
   }
@@ -313,7 +315,7 @@ public class MiniAccumuloClusterControl implements 
ClusterControl {
       if (group == null) {
         return;
       }
-      cluster.stopProcessesWithTimeout(ServerType.TABLET_SERVER, group, 60, 
TimeUnit.SECONDS);
+      cluster.stopProcessesWithTimeout(ServerType.TABLET_SERVER, group, 
STOP_TIMEOUT);
       tabletServerProcesses.remove(tserverResourceGroup);
     }
   }
@@ -324,8 +326,7 @@ public class MiniAccumuloClusterControl implements 
ClusterControl {
       case MANAGER:
         synchronized (managerProcesses) {
           try {
-            cluster.stopProcessesWithTimeout(ServerType.MANAGER, 
managerProcesses, 60,
-                TimeUnit.SECONDS);
+            cluster.stopProcessesWithTimeout(ServerType.MANAGER, 
managerProcesses, STOP_TIMEOUT);
             try {
               
System.setProperty(SiteConfiguration.ACCUMULO_PROPERTIES_PROPERTY,
                   "file://" + cluster.getAccumuloPropertiesPath());
@@ -371,7 +372,7 @@ public class MiniAccumuloClusterControl implements 
ClusterControl {
           try {
             final List<Process> procs = new ArrayList<>();
             tabletServerProcesses.values().forEach(procs::addAll);
-            cluster.stopProcessesWithTimeout(ServerType.TABLET_SERVER, procs, 
60, TimeUnit.SECONDS);
+            cluster.stopProcessesWithTimeout(ServerType.TABLET_SERVER, procs, 
STOP_TIMEOUT);
           } finally {
             tabletServerProcesses.clear();
           }
@@ -395,7 +396,7 @@ public class MiniAccumuloClusterControl implements 
ClusterControl {
           try {
             final List<Process> procs = new ArrayList<>();
             scanServerProcesses.values().forEach(procs::addAll);
-            cluster.stopProcessesWithTimeout(ServerType.SCAN_SERVER, procs, 
60, TimeUnit.SECONDS);
+            cluster.stopProcessesWithTimeout(ServerType.SCAN_SERVER, procs, 
STOP_TIMEOUT);
           } finally {
             scanServerProcesses.clear();
           }
@@ -406,7 +407,7 @@ public class MiniAccumuloClusterControl implements 
ClusterControl {
           try {
             final List<Process> procs = new ArrayList<>();
             compactorProcesses.values().forEach(procs::addAll);
-            cluster.stopProcessesWithTimeout(ServerType.COMPACTOR, procs, 60, 
TimeUnit.SECONDS);
+            cluster.stopProcessesWithTimeout(ServerType.COMPACTOR, procs, 
STOP_TIMEOUT);
           } finally {
             compactorProcesses.clear();
           }
diff --git 
a/minicluster/src/main/java/org/apache/accumulo/miniclusterImpl/MiniAccumuloClusterImpl.java
 
b/minicluster/src/main/java/org/apache/accumulo/miniclusterImpl/MiniAccumuloClusterImpl.java
index 8dba95d87f..66c193ffea 100644
--- 
a/minicluster/src/main/java/org/apache/accumulo/miniclusterImpl/MiniAccumuloClusterImpl.java
+++ 
b/minicluster/src/main/java/org/apache/accumulo/miniclusterImpl/MiniAccumuloClusterImpl.java
@@ -1145,18 +1145,18 @@ public class MiniAccumuloClusterImpl implements 
AccumuloCluster {
    * Stops the processes in parallel. The given timeout is the total wait for 
all given processes.
    */
   public void stopProcessesWithTimeout(final ServerType type, final 
List<Process> procs,
-      final long timeout, final TimeUnit unit) {
+      final Duration timeout) {
 
     // signal all first so they stop in parallel
     procs.forEach(Process::destroy);
 
-    final CountDownTimer timer = CountDownTimer.startNew(timeout, unit);
+    final CountDownTimer timer = CountDownTimer.startNew(timeout);
     try {
       for (Process proc : procs) {
         boolean stopped = proc.waitFor(timer.timeLeft(TimeUnit.NANOSECONDS), 
TimeUnit.NANOSECONDS);
         if (!stopped) {
           log.warn("{} (pid {}) did not fully stop after {} seconds", type, 
proc.pid(),
-              unit.toSeconds(timeout));
+              timeout.toSeconds());
         }
       }
     } catch (InterruptedException e) {
diff --git 
a/server/base/src/test/java/org/apache/accumulo/server/conf/store/impl/PropCacheCaffeineImplTest.java
 
b/server/base/src/test/java/org/apache/accumulo/server/conf/store/impl/PropCacheCaffeineImplTest.java
index adde8c8b51..30518542a9 100644
--- 
a/server/base/src/test/java/org/apache/accumulo/server/conf/store/impl/PropCacheCaffeineImplTest.java
+++ 
b/server/base/src/test/java/org/apache/accumulo/server/conf/store/impl/PropCacheCaffeineImplTest.java
@@ -28,10 +28,10 @@ import static org.easymock.EasyMock.verify;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.junit.jupiter.api.Assertions.assertNull;
 
+import java.time.Duration;
 import java.util.Map;
 import java.util.UUID;
 import java.util.concurrent.ThreadLocalRandom;
-import java.util.concurrent.TimeUnit;
 
 import org.apache.accumulo.core.data.InstanceId;
 import org.apache.accumulo.core.data.TableId;
@@ -155,7 +155,7 @@ public class PropCacheCaffeineImplTest {
     replay(context, propStoreWatcher, zooPropLoader);
     assertNotNull(cache.get(tablePropKey)); // will call load
 
-    ticker.advance(90, TimeUnit.MINUTES);
+    ticker.advance(Duration.ofMinutes(90));
     assertNotNull(cache.get(tablePropKey)); // expired - will call load.
   }
 
@@ -177,8 +177,8 @@ public class PropCacheCaffeineImplTest {
       elapsed = 0L;
     }
 
-    public void advance(final long value, final TimeUnit units) {
-      elapsed += TimeUnit.NANOSECONDS.convert(value, units);
+    public void advance(final Duration duration) {
+      elapsed += duration.toNanos();
     }
 
     @Override
diff --git 
a/server/base/src/test/java/org/apache/accumulo/server/conf/store/impl/ZooPropLoaderTest.java
 
b/server/base/src/test/java/org/apache/accumulo/server/conf/store/impl/ZooPropLoaderTest.java
index d6f8085ff7..b11d09faad 100644
--- 
a/server/base/src/test/java/org/apache/accumulo/server/conf/store/impl/ZooPropLoaderTest.java
+++ 
b/server/base/src/test/java/org/apache/accumulo/server/conf/store/impl/ZooPropLoaderTest.java
@@ -36,10 +36,10 @@ import static org.easymock.EasyMock.verify;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.junit.jupiter.api.Assertions.assertNull;
 
+import java.time.Duration;
 import java.time.Instant;
 import java.util.HashMap;
 import java.util.Map;
-import java.util.concurrent.TimeUnit;
 
 import org.apache.accumulo.core.data.TableId;
 import org.apache.accumulo.core.fate.zookeeper.ZooReaderWriter;
@@ -152,7 +152,7 @@ public class ZooPropLoaderTest {
     assertNotNull(cache.get(propStoreKey));
 
     // read cached entry - load count should not change.
-    ticker.advance(1, TimeUnit.MINUTES);
+    ticker.advance(Duration.ofMinutes(1));
     assertNotNull(cache.get(propStoreKey));
   }
 
@@ -210,7 +210,7 @@ public class ZooPropLoaderTest {
     // load cache
     assertNotNull(cache.get(propStoreKey));
 
-    ticker.advance(70, TimeUnit.MINUTES);
+    ticker.advance(Duration.ofMinutes(70));
 
     assertNotNull(cache.get(propStoreKey));
 
@@ -257,13 +257,13 @@ public class ZooPropLoaderTest {
     // prime cache
     assertNotNull(cache.get(propStoreKey));
 
-    ticker.advance(5, TimeUnit.MINUTES);
+    ticker.advance(Duration.ofMinutes(5));
 
     // read cached value
     assertNotNull(cache.get(propStoreKey));
 
     // advance so expire called.
-    ticker.advance(120, TimeUnit.MINUTES);
+    ticker.advance(Duration.ofMinutes(120));
 
     assertNull(cache.get(propStoreKey));
   }
diff --git 
a/test/src/main/java/org/apache/accumulo/test/conf/store/ZooBasedConfigIT.java 
b/test/src/main/java/org/apache/accumulo/test/conf/store/ZooBasedConfigIT.java
index 8677ac8ccd..9bd4cac5b5 100644
--- 
a/test/src/main/java/org/apache/accumulo/test/conf/store/ZooBasedConfigIT.java
+++ 
b/test/src/main/java/org/apache/accumulo/test/conf/store/ZooBasedConfigIT.java
@@ -31,9 +31,9 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.io.File;
+import java.time.Duration;
 import java.util.Map;
 import java.util.UUID;
-import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.accumulo.core.Constants;
@@ -262,7 +262,7 @@ public class ZooBasedConfigIT {
     long updateCount = zbc.getUpdateCount();
 
     // advance well past unload period.
-    ticker.advance(2, TimeUnit.HOURS);
+    ticker.advance(Duration.ofHours(2));
 
     var tableBPropKey = TablePropKey.of(tidB);
     propStore.create(tableBPropKey, Map.of());
@@ -362,8 +362,8 @@ public class ZooBasedConfigIT {
       elapsed = 0L;
     }
 
-    public void advance(final long value, final TimeUnit units) {
-      elapsed += TimeUnit.NANOSECONDS.convert(value, units);
+    public void advance(final Duration duration) {
+      elapsed += duration.toNanos();
     }
 
     @Override

Reply via email to