You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by ct...@apache.org on 2022/01/31 11:02:02 UTC
[accumulo] 03/03: Clean up uses of Duration/TimeUnit
This is an automated email from the ASF dual-hosted git repository.
ctubbsii pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/accumulo.git
commit af4d4d978a4785c1971984513fb51c629ef68100
Author: Christopher Tubbs <ct...@apache.org>
AuthorDate: Mon Jan 31 04:30:08 2022 -0500
Clean up uses of Duration/TimeUnit
---
.../accumulo/coordinator/CompactionCoordinator.java | 4 +---
.../java/org/apache/accumulo/tserver/TabletServer.java | 16 ++++++++--------
.../tserver/tablet/CompactableImplFileManagerTest.java | 11 ++---------
3 files changed, 11 insertions(+), 20 deletions(-)
diff --git a/server/compaction-coordinator/src/main/java/org/apache/accumulo/coordinator/CompactionCoordinator.java b/server/compaction-coordinator/src/main/java/org/apache/accumulo/coordinator/CompactionCoordinator.java
index fef096f..77c1622 100644
--- a/server/compaction-coordinator/src/main/java/org/apache/accumulo/coordinator/CompactionCoordinator.java
+++ b/server/compaction-coordinator/src/main/java/org/apache/accumulo/coordinator/CompactionCoordinator.java
@@ -21,7 +21,6 @@ package org.apache.accumulo.coordinator;
import static org.apache.accumulo.fate.util.UtilWaitThread.sleepUninterruptibly;
import java.net.UnknownHostException;
-import java.time.Duration;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -98,8 +97,7 @@ public class CompactionCoordinator extends AbstractServer
private static final Logger LOG = LoggerFactory.getLogger(CompactionCoordinator.class);
private static final long TIME_BETWEEN_GC_CHECKS = 5000;
- private static final long FIFTEEN_MINUTES =
- TimeUnit.MILLISECONDS.convert(Duration.of(15, TimeUnit.MINUTES.toChronoUnit()));
+ private static final long FIFTEEN_MINUTES = TimeUnit.MINUTES.toMillis(15);
protected static final QueueSummaries QUEUE_SUMMARIES = new QueueSummaries();
diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java b/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java
index c852c1b..d335278f 100644
--- a/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java
+++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java
@@ -165,8 +165,8 @@ public class TabletServer extends AbstractServer {
private static final SecureRandom random = new SecureRandom();
private static final Logger log = LoggerFactory.getLogger(TabletServer.class);
- private static final long TIME_BETWEEN_GC_CHECKS = 5000;
- private static final long TIME_BETWEEN_LOCATOR_CACHE_CLEARS = 60 * 60 * 1000;
+ private static final long TIME_BETWEEN_GC_CHECKS = TimeUnit.SECONDS.toMillis(5);
+ private static final long TIME_BETWEEN_LOCATOR_CACHE_CLEARS = TimeUnit.HOURS.toMillis(1);
final GarbageCollectionLogger gcLogger = new GarbageCollectionLogger();
final ZooCache managerLockCache;
@@ -299,7 +299,7 @@ public class TabletServer extends AbstractServer {
}
}
}
- }), 5000, 5000, TimeUnit.MILLISECONDS);
+ }), 5, 5, TimeUnit.SECONDS);
@SuppressWarnings("deprecation")
final long walMaxSize =
@@ -797,7 +797,7 @@ public class TabletServer extends AbstractServer {
setupReplication(aconf);
}
}
- }, 0, 5000, TimeUnit.MILLISECONDS);
+ }, 0, 5, TimeUnit.SECONDS);
int tabletCheckFrequency = 30 + random.nextInt(31); // random 30-60 minute delay
// Periodically check that metadata of tablets matches what is held in memory
@@ -825,7 +825,7 @@ public class TabletServer extends AbstractServer {
}
}, tabletCheckFrequency, tabletCheckFrequency, TimeUnit.MINUTES);
- final long CLEANUP_BULK_LOADED_CACHE_MILLIS = 15 * 60 * 1000;
+ final long CLEANUP_BULK_LOADED_CACHE_MILLIS = TimeUnit.MINUTES.toMillis(15);
context.getScheduledExecutor().scheduleWithFixedDelay(new BulkImportCacheCleaner(this),
CLEANUP_BULK_LOADED_CACHE_MILLIS, CLEANUP_BULK_LOADED_CACHE_MILLIS, TimeUnit.MILLISECONDS);
@@ -840,7 +840,7 @@ public class TabletServer extends AbstractServer {
// wait until a message is ready to send, or a sever stop
// was requested
while (mm == null && !serverStopRequested) {
- mm = managerMessages.poll(1000, TimeUnit.MILLISECONDS);
+ mm = managerMessages.poll(1, TimeUnit.SECONDS);
}
// have a message to send to the manager, so grab a
@@ -948,8 +948,8 @@ public class TabletServer extends AbstractServer {
Runnable replicationWorkThreadPoolResizer = () -> {
ThreadPools.resizePool(replicationThreadPool, aconf, Property.REPLICATION_WORKER_THREADS);
};
- context.getScheduledExecutor().scheduleWithFixedDelay(replicationWorkThreadPoolResizer, 10000,
- 30000, TimeUnit.MILLISECONDS);
+ context.getScheduledExecutor().scheduleWithFixedDelay(replicationWorkThreadPoolResizer, 10, 30,
+ TimeUnit.SECONDS);
}
public String getClientAddressString() {
diff --git a/server/tserver/src/test/java/org/apache/accumulo/tserver/tablet/CompactableImplFileManagerTest.java b/server/tserver/src/test/java/org/apache/accumulo/tserver/tablet/CompactableImplFileManagerTest.java
index 4cc7cfd..059e828 100644
--- a/server/tserver/src/test/java/org/apache/accumulo/tserver/tablet/CompactableImplFileManagerTest.java
+++ b/server/tserver/src/test/java/org/apache/accumulo/tserver/tablet/CompactableImplFileManagerTest.java
@@ -36,7 +36,6 @@ import java.util.Set;
import java.util.stream.Collectors;
import org.apache.accumulo.core.client.admin.compaction.CompactableFile;
-import org.apache.accumulo.core.conf.AccumuloConfiguration.Deriver;
import org.apache.accumulo.core.data.TableId;
import org.apache.accumulo.core.dataImpl.KeyExtent;
import org.apache.accumulo.core.metadata.CompactableFileImpl;
@@ -410,19 +409,13 @@ public class CompactableImplFileManagerTest {
static class TestFileManager extends CompactableImpl.FileManager {
- public static final Duration SELECTION_EXPIRATION = Duration.ofSeconds(120);
+ public static final Duration SELECTION_EXPIRATION = Duration.ofMinutes(2);
private long time = 0;
public Set<CompactionKind> running = new HashSet<>();
public TestFileManager() {
super(new KeyExtent(TableId.of("1"), null, null), Set.of(), Optional.empty(),
- new Deriver<Duration>() {
-
- @Override
- public Duration derive() {
- return SELECTION_EXPIRATION;
- }
- });
+ () -> SELECTION_EXPIRATION);
}
@Override