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/02/24 04:34:15 UTC
[accumulo] branch main updated: Replace some calculation with TimeUnit (#2515)
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
The following commit(s) were added to refs/heads/main by this push:
new 0a64b44 Replace some calculation with TimeUnit (#2515)
0a64b44 is described below
commit 0a64b442a92f728858066c2bc12312f96d41d22e
Author: Kylian Meulin <59...@users.noreply.github.com>
AuthorDate: Thu Feb 24 05:34:08 2022 +0100
Replace some calculation with TimeUnit (#2515)
* Replace several multiplications of numeric literals with TimeUnit conversions
* Use import static for many TimeUnit to shorten many lines
* Replace .convert with more readable TimeUnit toMillis and toSeconds
Co-authored-by: Christopher Tubbs <ct...@apache.org>
---
.../DefaultContextClassLoaderFactory.java | 5 +-
.../accumulo/core/client/BatchWriterConfig.java | 10 +--
.../core/client/ClientSideIteratorScanner.java | 10 +--
.../core/client/ConditionalWriterConfig.java | 3 +-
.../accumulo/core/client/IsolatedScanner.java | 10 +--
.../accumulo/core/client/ZooKeeperInstance.java | 4 +-
.../core/client/admin/DelegationTokenConfig.java | 5 +-
.../accumulo/core/clientImpl/ClientContext.java | 19 ++---
.../core/clientImpl/ConditionalWriterImpl.java | 20 +++---
.../accumulo/core/clientImpl/ConnectorImpl.java | 10 +--
.../DelegationTokenConfigSerializer.java | 6 +-
.../accumulo/core/clientImpl/ManagerClient.java | 10 +--
.../core/clientImpl/NamespaceOperationsImpl.java | 6 +-
.../accumulo/core/clientImpl/OfflineIterator.java | 4 +-
.../core/clientImpl/RootTabletLocator.java | 7 +-
.../accumulo/core/clientImpl/ScannerImpl.java | 4 +-
.../accumulo/core/clientImpl/ScannerIterator.java | 5 +-
.../accumulo/core/clientImpl/ScannerOptions.java | 5 +-
.../accumulo/core/clientImpl/ServerClient.java | 6 +-
.../core/clientImpl/TableOperationsImpl.java | 47 ++++++------
.../core/clientImpl/TabletLocatorImpl.java | 11 +--
.../TabletServerBatchReaderIterator.java | 9 +--
.../core/clientImpl/TabletServerBatchWriter.java | 12 ++--
.../accumulo/core/clientImpl/ThriftScanner.java | 20 +++---
.../core/clientImpl/ThriftTransportPool.java | 4 +-
.../apache/accumulo/core/clientImpl/Writer.java | 7 +-
.../accumulo/core/clientImpl/bulk/BulkImport.java | 3 +-
.../core/conf/ConfigurationTypeHelper.java | 18 +++--
.../accumulo/core/file/BloomFilterLayer.java | 7 +-
.../file/blockfile/cache/lru/LruBlockCache.java | 4 +-
.../blockfile/cache/tinylfu/TinyLfuBlockCache.java | 6 +-
.../apache/accumulo/core/iterators/Combiner.java | 5 +-
.../core/metadata/MetadataLocationObtainer.java | 6 +-
.../core/metadata/schema/LinkingIterator.java | 4 +-
.../spi/balancer/HostRegexTableLoadBalancer.java | 8 +--
.../core/spi/balancer/SimpleLoadBalancer.java | 5 +-
.../core/spi/fs/SpaceAwareVolumeChooser.java | 6 +-
.../org/apache/accumulo/core/summary/Gatherer.java | 5 +-
.../java/org/apache/accumulo/core/util/Halt.java | 5 +-
.../org/apache/accumulo/core/util/OpTimer.java | 6 +-
.../util/compaction/RunningCompactionInfo.java | 6 +-
.../util/ratelimit/SharedRateLimiterFactory.java | 10 +--
.../accumulo/core/util/tables/TableZooHelper.java | 4 +-
.../accumulo/core/util/threads/ThreadPools.java | 33 +++++----
.../main/java/org/apache/accumulo/fate/Fate.java | 8 ++-
.../java/org/apache/accumulo/fate/ZooStore.java | 4 +-
.../fate/zookeeper/DistributedReadWriteLock.java | 8 ++-
.../apache/accumulo/fate/zookeeper/ZooReader.java | 9 +--
.../core/client/BatchWriterConfigTest.java | 83 +++++++++++-----------
.../accumulo/core/client/TestThrift1474.java | 6 +-
.../client/admin/DelegationTokenConfigTest.java | 18 ++---
.../client/mapred/AccumuloOutputFormatTest.java | 20 +++---
.../client/mapreduce/AccumuloOutputFormatTest.java | 20 +++---
.../core/clientImpl/ClientContextTest.java | 21 +++---
.../DelegationTokenConfigSerializerTest.java | 8 +--
.../bulk/ConcurrentKeyExtentCacheTest.java | 4 +-
.../core/conf/ConfigurationTypeHelperTest.java | 14 ++--
.../core/file/rfile/MultiThreadedRFileTest.java | 7 +-
.../core/file/rfile/bcfile/CompressionTest.java | 8 +--
.../accumulo/core/rpc/TTimeoutTransportTest.java | 5 +-
.../org/apache/accumulo/core/util/OpTimerTest.java | 18 +++--
.../org/apache/accumulo/server/ServerContext.java | 8 ++-
.../accumulo/server/client/BulkImporter.java | 3 +-
.../accumulo/server/manager/LiveTServerSet.java | 3 +-
.../balancer/HostRegexTableLoadBalancer.java | 8 +--
.../server/zookeeper/DistributedWorkQueue.java | 5 +-
.../AuthenticationTokenSecretManagerTest.java | 20 +++---
.../ZooAuthenticationKeyWatcherTest.java | 3 +-
.../org/apache/accumulo/compactor/Compactor.java | 3 +-
.../org/apache/accumulo/manager/ManagerTime.java | 6 +-
.../java/org/apache/accumulo/monitor/Monitor.java | 3 +-
.../apache/accumulo/tserver/AssignmentHandler.java | 3 +-
.../accumulo/tserver/ThriftClientHandler.java | 3 +-
.../accumulo/tserver/UnloadTabletHandler.java | 5 +-
.../tserver/compactions/CompactionManager.java | 19 +++--
.../memory/LargestFirstMemoryManagerTest.java | 12 ++--
.../vfs/AccumuloReloadingVFSClassLoader.java | 3 +-
.../org/apache/accumulo/test/GetManagerStats.java | 4 +-
.../accumulo/test/InterruptibleScannersIT.java | 3 +-
.../org/apache/accumulo/test/SplitRecoveryIT.java | 4 +-
.../test/functional/FateConcurrencyIT.java | 28 ++++----
.../accumulo/test/functional/KerberosIT.java | 7 +-
.../test/functional/KerberosRenewalIT.java | 8 ++-
.../accumulo/test/manager/SuspendedTabletsIT.java | 3 +-
84 files changed, 436 insertions(+), 389 deletions(-)
diff --git a/core/src/main/java/org/apache/accumulo/core/classloader/DefaultContextClassLoaderFactory.java b/core/src/main/java/org/apache/accumulo/core/classloader/DefaultContextClassLoaderFactory.java
index f7e556e..e19c38b 100644
--- a/core/src/main/java/org/apache/accumulo/core/classloader/DefaultContextClassLoaderFactory.java
+++ b/core/src/main/java/org/apache/accumulo/core/classloader/DefaultContextClassLoaderFactory.java
@@ -18,9 +18,10 @@
*/
package org.apache.accumulo.core.classloader;
+import static java.util.concurrent.TimeUnit.MINUTES;
+
import java.util.Map;
import java.util.Set;
-import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Supplier;
import java.util.stream.Collectors;
@@ -69,7 +70,7 @@ public class DefaultContextClassLoaderFactory implements ContextClassLoaderFacto
.collect(Collectors.toSet());
LOG.trace("{}-cleanup thread, contexts in use: {}", className, contextsInUse);
AccumuloVFSClassLoader.removeUnusedContexts(contextsInUse);
- }), 60_000, 60_000, TimeUnit.MILLISECONDS);
+ }), 1, 1, MINUTES);
LOG.debug("Context cleanup timer started at 60s intervals");
}
diff --git a/core/src/main/java/org/apache/accumulo/core/client/BatchWriterConfig.java b/core/src/main/java/org/apache/accumulo/core/client/BatchWriterConfig.java
index 6f9dff4..192b147 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/BatchWriterConfig.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/BatchWriterConfig.java
@@ -19,6 +19,7 @@
package org.apache.accumulo.core.client;
import static java.nio.charset.StandardCharsets.UTF_8;
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static org.apache.accumulo.core.conf.ClientProperty.BATCH_WRITER_LATENCY_MAX;
import static org.apache.accumulo.core.conf.ClientProperty.BATCH_WRITER_MEMORY_MAX;
import static org.apache.accumulo.core.conf.ClientProperty.BATCH_WRITER_THREADS_MAX;
@@ -187,12 +188,11 @@ public class BatchWriterConfig implements Writable {
}
public long getMaxLatency(TimeUnit timeUnit) {
- return timeUnit.convert(maxLatency != null ? maxLatency : DEFAULT_MAX_LATENCY,
- TimeUnit.MILLISECONDS);
+ return timeUnit.convert(maxLatency != null ? maxLatency : DEFAULT_MAX_LATENCY, MILLISECONDS);
}
public long getTimeout(TimeUnit timeUnit) {
- return timeUnit.convert(timeout != null ? timeout : DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS);
+ return timeUnit.convert(timeout != null ? timeout : DEFAULT_TIMEOUT, MILLISECONDS);
}
public int getMaxWriteThreads() {
@@ -377,8 +377,8 @@ public class BatchWriterConfig implements Writable {
public String toString() {
StringBuilder sb = new StringBuilder(32);
sb.append("[maxMemory=").append(getMaxMemory()).append(", maxLatency=")
- .append(getMaxLatency(TimeUnit.MILLISECONDS)).append(", maxWriteThreads=")
- .append(getMaxWriteThreads()).append(", timeout=").append(getTimeout(TimeUnit.MILLISECONDS))
+ .append(getMaxLatency(MILLISECONDS)).append(", maxWriteThreads=")
+ .append(getMaxWriteThreads()).append(", timeout=").append(getTimeout(MILLISECONDS))
.append(", durability=").append(durability).append("]");
return sb.toString();
}
diff --git a/core/src/main/java/org/apache/accumulo/core/client/ClientSideIteratorScanner.java b/core/src/main/java/org/apache/accumulo/core/client/ClientSideIteratorScanner.java
index 7845b4b..b56d475 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/ClientSideIteratorScanner.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/ClientSideIteratorScanner.java
@@ -19,6 +19,7 @@
package org.apache.accumulo.core.client;
import static java.util.Objects.requireNonNull;
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
import java.io.IOException;
import java.util.Collection;
@@ -28,7 +29,6 @@ import java.util.Map.Entry;
import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;
-import java.util.concurrent.TimeUnit;
import org.apache.accumulo.core.Constants;
import org.apache.accumulo.core.client.sample.SamplerConfiguration;
@@ -214,8 +214,8 @@ public class ClientSideIteratorScanner extends ScannerOptions implements Scanner
smi = new ScannerTranslatorImpl(scanner, scanner.getSamplerConfiguration());
this.range = scanner.getRange();
this.size = scanner.getBatchSize();
- this.timeOut = scanner.getTimeout(TimeUnit.MILLISECONDS);
- this.batchTimeOut = scanner.getTimeout(TimeUnit.MILLISECONDS);
+ this.timeOut = scanner.getTimeout(MILLISECONDS);
+ this.batchTimeOut = scanner.getTimeout(MILLISECONDS);
this.readaheadThreshold = scanner.getReadaheadThreshold();
SamplerConfiguration samplerConfig = scanner.getSamplerConfiguration();
if (samplerConfig != null)
@@ -232,8 +232,8 @@ public class ClientSideIteratorScanner extends ScannerOptions implements Scanner
@Override
public Iterator<Entry<Key,Value>> iterator() {
smi.scanner.setBatchSize(size);
- smi.scanner.setTimeout(timeOut, TimeUnit.MILLISECONDS);
- smi.scanner.setBatchTimeout(batchTimeOut, TimeUnit.MILLISECONDS);
+ smi.scanner.setTimeout(timeOut, MILLISECONDS);
+ smi.scanner.setBatchTimeout(batchTimeOut, MILLISECONDS);
smi.scanner.setReadaheadThreshold(readaheadThreshold);
if (isolated)
smi.scanner.enableIsolation();
diff --git a/core/src/main/java/org/apache/accumulo/core/client/ConditionalWriterConfig.java b/core/src/main/java/org/apache/accumulo/core/client/ConditionalWriterConfig.java
index 53618fa..67c258f 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/ConditionalWriterConfig.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/ConditionalWriterConfig.java
@@ -20,6 +20,7 @@ package org.apache.accumulo.core.client;
import static com.google.common.base.Preconditions.checkArgument;
import static java.util.Objects.requireNonNull;
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static org.apache.accumulo.core.conf.ClientProperty.CONDITIONAL_WRITER_THREADS_MAX;
import static org.apache.accumulo.core.conf.ClientProperty.CONDITIONAL_WRITER_TIMEOUT_MAX;
@@ -131,7 +132,7 @@ public class ConditionalWriterConfig {
}
public long getTimeout(TimeUnit timeUnit) {
- return timeUnit.convert(timeout != null ? timeout : DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS);
+ return timeUnit.convert(timeout != null ? timeout : DEFAULT_TIMEOUT, MILLISECONDS);
}
public int getMaxWriteThreads() {
diff --git a/core/src/main/java/org/apache/accumulo/core/client/IsolatedScanner.java b/core/src/main/java/org/apache/accumulo/core/client/IsolatedScanner.java
index f226107..75e505a 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/IsolatedScanner.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/IsolatedScanner.java
@@ -18,12 +18,12 @@
*/
package org.apache.accumulo.core.client;
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static org.apache.accumulo.fate.util.UtilWaitThread.sleepUninterruptibly;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Map.Entry;
-import java.util.concurrent.TimeUnit;
import org.apache.accumulo.core.clientImpl.IsolationException;
import org.apache.accumulo.core.clientImpl.ScannerOptions;
@@ -114,7 +114,7 @@ public class IsolatedScanner extends ScannerOptions implements Scanner {
}
// wait a moment before retrying
- sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
+ sleepUninterruptibly(100, MILLISECONDS);
source = newIterator(seekRange);
}
@@ -125,7 +125,7 @@ public class IsolatedScanner extends ScannerOptions implements Scanner {
synchronized (scanner) {
scanner.enableIsolation();
scanner.setBatchSize(batchSize);
- scanner.setTimeout(timeout, TimeUnit.MILLISECONDS);
+ scanner.setTimeout(timeout, MILLISECONDS);
scanner.setRange(r);
scanner.setReadaheadThreshold(readaheadThreshold);
setOptions((ScannerOptions) scanner, opts);
@@ -228,8 +228,8 @@ public class IsolatedScanner extends ScannerOptions implements Scanner {
public IsolatedScanner(Scanner scanner, RowBufferFactory bufferFactory) {
this.scanner = scanner;
this.range = scanner.getRange();
- this.timeOut = scanner.getTimeout(TimeUnit.MILLISECONDS);
- this.batchTimeOut = scanner.getBatchTimeout(TimeUnit.MILLISECONDS);
+ this.timeOut = scanner.getTimeout(MILLISECONDS);
+ this.batchTimeOut = scanner.getBatchTimeout(MILLISECONDS);
this.batchSize = scanner.getBatchSize();
this.readaheadThreshold = scanner.getReadaheadThreshold();
this.bufferFactory = bufferFactory;
diff --git a/core/src/main/java/org/apache/accumulo/core/client/ZooKeeperInstance.java b/core/src/main/java/org/apache/accumulo/core/client/ZooKeeperInstance.java
index 0b74a4d..7e81280 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/ZooKeeperInstance.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/ZooKeeperInstance.java
@@ -19,10 +19,10 @@
package org.apache.accumulo.core.client;
import static com.google.common.base.Preconditions.checkArgument;
+import static java.util.concurrent.TimeUnit.SECONDS;
import java.util.List;
import java.util.Properties;
-import java.util.concurrent.TimeUnit;
import org.apache.accumulo.core.Constants;
import org.apache.accumulo.core.client.security.tokens.AuthenticationToken;
@@ -154,7 +154,7 @@ public class ZooKeeperInstance implements Instance {
if (timer != null) {
timer.stop();
log.trace("tid={} Found root tablet at {} in {}", Thread.currentThread().getId(), loc,
- String.format("%.3f secs", timer.scale(TimeUnit.SECONDS)));
+ String.format("%.3f secs", timer.scale(SECONDS)));
}
if (loc == null || loc.getType() != LocationType.CURRENT) {
diff --git a/core/src/main/java/org/apache/accumulo/core/client/admin/DelegationTokenConfig.java b/core/src/main/java/org/apache/accumulo/core/client/admin/DelegationTokenConfig.java
index 476a435..d96ccbd 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/admin/DelegationTokenConfig.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/admin/DelegationTokenConfig.java
@@ -20,6 +20,7 @@ package org.apache.accumulo.core.client.admin;
import static com.google.common.base.Preconditions.checkArgument;
import static java.util.Objects.requireNonNull;
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
import java.util.concurrent.TimeUnit;
@@ -46,7 +47,7 @@ public class DelegationTokenConfig {
public DelegationTokenConfig setTokenLifetime(long lifetime, TimeUnit unit) {
checkArgument(lifetime >= 0, "Lifetime must be non-negative");
requireNonNull(unit, "TimeUnit was null");
- this.lifetime = TimeUnit.MILLISECONDS.convert(lifetime, unit);
+ this.lifetime = MILLISECONDS.convert(lifetime, unit);
return this;
}
@@ -60,7 +61,7 @@ public class DelegationTokenConfig {
*/
public long getTokenLifetime(TimeUnit unit) {
requireNonNull(unit);
- return unit.convert(lifetime, TimeUnit.MILLISECONDS);
+ return unit.convert(lifetime, MILLISECONDS);
}
@Override
diff --git a/core/src/main/java/org/apache/accumulo/core/clientImpl/ClientContext.java b/core/src/main/java/org/apache/accumulo/core/clientImpl/ClientContext.java
index dda366a..7c04571 100644
--- a/core/src/main/java/org/apache/accumulo/core/clientImpl/ClientContext.java
+++ b/core/src/main/java/org/apache/accumulo/core/clientImpl/ClientContext.java
@@ -21,6 +21,8 @@ package org.apache.accumulo.core.clientImpl;
import static com.google.common.base.Preconditions.checkArgument;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.util.Objects.requireNonNull;
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
+import static java.util.concurrent.TimeUnit.SECONDS;
import static org.apache.accumulo.core.metadata.schema.TabletMetadata.ColumnType.LOCATION;
import java.net.URL;
@@ -30,7 +32,6 @@ import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Properties;
-import java.util.concurrent.TimeUnit;
import java.util.function.Function;
import java.util.function.Supplier;
@@ -136,7 +137,7 @@ public class ClientContext implements AccumuloClient {
private static <T> Supplier<T> memoizeWithExpiration(Supplier<T> s) {
// This insanity exists to make modernizer plugin happy. We are living in the future now.
- return () -> Suppliers.memoizeWithExpiration(s::get, 100, TimeUnit.MILLISECONDS).get();
+ return () -> Suppliers.memoizeWithExpiration(s::get, 100, MILLISECONDS).get();
}
/**
@@ -300,11 +301,11 @@ public class ClientContext implements AccumuloClient {
}
Long maxLatency = ClientProperty.BATCH_WRITER_LATENCY_MAX.getTimeInMillis(props);
if (maxLatency != null) {
- batchWriterConfig.setMaxLatency(maxLatency, TimeUnit.SECONDS);
+ batchWriterConfig.setMaxLatency(maxLatency, SECONDS);
}
Long timeout = ClientProperty.BATCH_WRITER_TIMEOUT_MAX.getTimeInMillis(props);
if (timeout != null) {
- batchWriterConfig.setTimeout(timeout, TimeUnit.SECONDS);
+ batchWriterConfig.setTimeout(timeout, SECONDS);
}
Integer maxThreads = ClientProperty.BATCH_WRITER_THREADS_MAX.getInteger(props);
if (maxThreads != null) {
@@ -330,7 +331,7 @@ public class ClientContext implements AccumuloClient {
Long timeout = ClientProperty.CONDITIONAL_WRITER_TIMEOUT_MAX.getTimeInMillis(props);
if (timeout != null) {
- conditionalWriterConfig.setTimeout(timeout, TimeUnit.SECONDS);
+ conditionalWriterConfig.setTimeout(timeout, SECONDS);
}
String durability = ClientProperty.CONDITIONAL_WRITER_DURABILITY.getValue(props);
if (!durability.isEmpty()) {
@@ -389,7 +390,7 @@ public class ClientContext implements AccumuloClient {
if (timer != null) {
timer.stop();
log.trace("tid={} Found root tablet at {} in {}", Thread.currentThread().getId(), loc,
- String.format("%.3f secs", timer.scale(TimeUnit.SECONDS)));
+ String.format("%.3f secs", timer.scale(SECONDS)));
}
if (loc == null || loc.getType() != LocationType.CURRENT) {
@@ -427,7 +428,7 @@ public class ClientContext implements AccumuloClient {
timer.stop();
log.trace("tid={} Found manager at {} in {}", Thread.currentThread().getId(),
(loc == null ? "null" : new String(loc, UTF_8)),
- String.format("%.3f secs", timer.scale(TimeUnit.SECONDS)));
+ String.format("%.3f secs", timer.scale(SECONDS)));
}
if (loc == null) {
@@ -889,9 +890,9 @@ public class ClientContext implements AccumuloClient {
public ConnectionOptions<T> batchWriterConfig(BatchWriterConfig batchWriterConfig) {
ClientProperty.BATCH_WRITER_MEMORY_MAX.setBytes(properties, batchWriterConfig.getMaxMemory());
ClientProperty.BATCH_WRITER_LATENCY_MAX.setTimeInMillis(properties,
- batchWriterConfig.getMaxLatency(TimeUnit.MILLISECONDS));
+ batchWriterConfig.getMaxLatency(MILLISECONDS));
ClientProperty.BATCH_WRITER_TIMEOUT_MAX.setTimeInMillis(properties,
- batchWriterConfig.getTimeout(TimeUnit.MILLISECONDS));
+ batchWriterConfig.getTimeout(MILLISECONDS));
setProperty(ClientProperty.BATCH_WRITER_THREADS_MAX, batchWriterConfig.getMaxWriteThreads());
setProperty(ClientProperty.BATCH_WRITER_DURABILITY,
batchWriterConfig.getDurability().toString());
diff --git a/core/src/main/java/org/apache/accumulo/core/clientImpl/ConditionalWriterImpl.java b/core/src/main/java/org/apache/accumulo/core/clientImpl/ConditionalWriterImpl.java
index 3b61c7e..ff0d596 100644
--- a/core/src/main/java/org/apache/accumulo/core/clientImpl/ConditionalWriterImpl.java
+++ b/core/src/main/java/org/apache/accumulo/core/clientImpl/ConditionalWriterImpl.java
@@ -19,6 +19,8 @@
package org.apache.accumulo.core.clientImpl;
import static java.nio.charset.StandardCharsets.UTF_8;
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
+import static java.util.concurrent.TimeUnit.SECONDS;
import static org.apache.accumulo.fate.util.UtilWaitThread.sleepUninterruptibly;
import java.nio.ByteBuffer;
@@ -87,8 +89,8 @@ import org.apache.thrift.transport.TTransportException;
class ConditionalWriterImpl implements ConditionalWriter {
- private static ThreadPoolExecutor cleanupThreadPool = ThreadPools.createFixedThreadPool(1, 3,
- TimeUnit.SECONDS, "Conditional Writer Cleanup Thread", true);
+ private static ThreadPoolExecutor cleanupThreadPool =
+ ThreadPools.createFixedThreadPool(1, 3, SECONDS, "Conditional Writer Cleanup Thread", true);
private static final int MAX_SLEEP = 30000;
@@ -133,14 +135,14 @@ class ConditionalWriterImpl implements ConditionalWriter {
throw new NoSuchElementException();
try {
- Result result = rq.poll(1, TimeUnit.SECONDS);
+ Result result = rq.poll(1, SECONDS);
while (result == null) {
if (threadPool.isShutdown()) {
throw new NoSuchElementException("ConditionalWriter closed");
}
- result = rq.poll(1, TimeUnit.SECONDS);
+ result = rq.poll(1, SECONDS);
}
count--;
return result;
@@ -188,7 +190,7 @@ class ConditionalWriterImpl implements ConditionalWriter {
@Override
public long getDelay(TimeUnit unit) {
- return unit.convert(delay - (System.currentTimeMillis() - resetTime), TimeUnit.MILLISECONDS);
+ return unit.convert(delay - (System.currentTimeMillis() - resetTime), MILLISECONDS);
}
void resetDelay() {
@@ -251,7 +253,7 @@ class ConditionalWriterImpl implements ConditionalWriter {
for (QCMutation qcm : mutations) {
qcm.resetDelay();
- if (time + qcm.getDelay(TimeUnit.MILLISECONDS) > qcm.entryTime + timeout) {
+ if (time + qcm.getDelay(MILLISECONDS) > qcm.entryTime + timeout) {
TimedOutException toe;
if (server != null)
toe = new TimedOutException(Collections.singleton(server.toString()));
@@ -367,7 +369,7 @@ class ConditionalWriterImpl implements ConditionalWriter {
this.serverQueues = new HashMap<>();
this.tableId = tableId;
this.tableName = tableName;
- this.timeout = config.getTimeout(TimeUnit.MILLISECONDS);
+ this.timeout = config.getTimeout(MILLISECONDS);
this.durability = config.getDurability();
this.classLoaderContext = config.getClassLoaderContext();
@@ -378,7 +380,7 @@ class ConditionalWriterImpl implements ConditionalWriter {
queue(mutations);
};
- threadPool.scheduleAtFixedRate(failureHandler, 250, 250, TimeUnit.MILLISECONDS);
+ threadPool.scheduleAtFixedRate(failureHandler, 250, 250, MILLISECONDS);
}
@Override
@@ -676,7 +678,7 @@ class ConditionalWriterImpl implements ConditionalWriter {
if ((System.currentTimeMillis() - startTime) + sleepTime > timeout)
throw new TimedOutException(Collections.singleton(location.toString()));
- sleepUninterruptibly(sleepTime, TimeUnit.MILLISECONDS);
+ sleepUninterruptibly(sleepTime, MILLISECONDS);
sleepTime = Math.min(2 * sleepTime, MAX_SLEEP);
}
diff --git a/core/src/main/java/org/apache/accumulo/core/clientImpl/ConnectorImpl.java b/core/src/main/java/org/apache/accumulo/core/clientImpl/ConnectorImpl.java
index f7fad0d..73c716c 100644
--- a/core/src/main/java/org/apache/accumulo/core/clientImpl/ConnectorImpl.java
+++ b/core/src/main/java/org/apache/accumulo/core/clientImpl/ConnectorImpl.java
@@ -18,7 +18,7 @@
*/
package org.apache.accumulo.core.clientImpl;
-import java.util.concurrent.TimeUnit;
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
import org.apache.accumulo.core.client.AccumuloException;
import org.apache.accumulo.core.client.AccumuloSecurityException;
@@ -91,8 +91,8 @@ public class ConnectorImpl extends org.apache.accumulo.core.client.Connector {
int numQueryThreads, long maxMemory, long maxLatency, int maxWriteThreads)
throws TableNotFoundException {
return context.createBatchDeleter(tableName, authorizations, numQueryThreads,
- new BatchWriterConfig().setMaxMemory(maxMemory)
- .setMaxLatency(maxLatency, TimeUnit.MILLISECONDS).setMaxWriteThreads(maxWriteThreads));
+ new BatchWriterConfig().setMaxMemory(maxMemory).setMaxLatency(maxLatency, MILLISECONDS)
+ .setMaxWriteThreads(maxWriteThreads));
}
@Override
@@ -105,7 +105,7 @@ public class ConnectorImpl extends org.apache.accumulo.core.client.Connector {
public BatchWriter createBatchWriter(String tableName, long maxMemory, long maxLatency,
int maxWriteThreads) throws TableNotFoundException {
return context.createBatchWriter(tableName, new BatchWriterConfig().setMaxMemory(maxMemory)
- .setMaxLatency(maxLatency, TimeUnit.MILLISECONDS).setMaxWriteThreads(maxWriteThreads));
+ .setMaxLatency(maxLatency, MILLISECONDS).setMaxWriteThreads(maxWriteThreads));
}
@Override
@@ -118,7 +118,7 @@ public class ConnectorImpl extends org.apache.accumulo.core.client.Connector {
public MultiTableBatchWriter createMultiTableBatchWriter(long maxMemory, long maxLatency,
int maxWriteThreads) {
return context.createMultiTableBatchWriter(new BatchWriterConfig().setMaxMemory(maxMemory)
- .setMaxLatency(maxLatency, TimeUnit.MILLISECONDS).setMaxWriteThreads(maxWriteThreads));
+ .setMaxLatency(maxLatency, MILLISECONDS).setMaxWriteThreads(maxWriteThreads));
}
@Override
diff --git a/core/src/main/java/org/apache/accumulo/core/clientImpl/DelegationTokenConfigSerializer.java b/core/src/main/java/org/apache/accumulo/core/clientImpl/DelegationTokenConfigSerializer.java
index b098a83..d412996 100644
--- a/core/src/main/java/org/apache/accumulo/core/clientImpl/DelegationTokenConfigSerializer.java
+++ b/core/src/main/java/org/apache/accumulo/core/clientImpl/DelegationTokenConfigSerializer.java
@@ -18,7 +18,7 @@
*/
package org.apache.accumulo.core.clientImpl;
-import java.util.concurrent.TimeUnit;
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
import org.apache.accumulo.core.client.admin.DelegationTokenConfig;
import org.apache.accumulo.core.securityImpl.thrift.TDelegationTokenConfig;
@@ -36,7 +36,7 @@ public class DelegationTokenConfigSerializer {
*/
public static TDelegationTokenConfig serialize(DelegationTokenConfig config) {
TDelegationTokenConfig tconfig = new TDelegationTokenConfig();
- tconfig.setLifetime(config.getTokenLifetime(TimeUnit.MILLISECONDS));
+ tconfig.setLifetime(config.getTokenLifetime(MILLISECONDS));
return tconfig;
}
@@ -49,7 +49,7 @@ public class DelegationTokenConfigSerializer {
public static DelegationTokenConfig deserialize(TDelegationTokenConfig tconfig) {
DelegationTokenConfig config = new DelegationTokenConfig();
if (tconfig.isSetLifetime()) {
- config.setTokenLifetime(tconfig.getLifetime(), TimeUnit.MILLISECONDS);
+ config.setTokenLifetime(tconfig.getLifetime(), MILLISECONDS);
}
return config;
}
diff --git a/core/src/main/java/org/apache/accumulo/core/clientImpl/ManagerClient.java b/core/src/main/java/org/apache/accumulo/core/clientImpl/ManagerClient.java
index 20a2048..680bd09 100644
--- a/core/src/main/java/org/apache/accumulo/core/clientImpl/ManagerClient.java
+++ b/core/src/main/java/org/apache/accumulo/core/clientImpl/ManagerClient.java
@@ -19,11 +19,11 @@
package org.apache.accumulo.core.clientImpl;
import static com.google.common.base.Preconditions.checkArgument;
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static org.apache.accumulo.fate.util.UtilWaitThread.sleepUninterruptibly;
import java.net.UnknownHostException;
import java.util.List;
-import java.util.concurrent.TimeUnit;
import org.apache.accumulo.core.client.AccumuloException;
import org.apache.accumulo.core.client.AccumuloSecurityException;
@@ -49,7 +49,7 @@ public class ManagerClient {
ManagerClientService.Client result = getConnection(context);
if (result != null)
return result;
- sleepUninterruptibly(250, TimeUnit.MILLISECONDS);
+ sleepUninterruptibly(250, MILLISECONDS);
}
}
@@ -102,7 +102,7 @@ public class ManagerClient {
return exec.execute(client);
} catch (TTransportException tte) {
log.debug("ManagerClient request failed, retrying ... ", tte);
- sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
+ sleepUninterruptibly(100, MILLISECONDS);
} catch (ThriftSecurityException e) {
throw new AccumuloSecurityException(e.user, e.code, e);
} catch (AccumuloException e) {
@@ -119,7 +119,7 @@ public class ManagerClient {
} catch (ThriftNotActiveServiceException e) {
// Let it loop, fetching a new location
log.debug("Contacted a Manager which is no longer active, retrying");
- sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
+ sleepUninterruptibly(100, MILLISECONDS);
} catch (Exception e) {
throw new AccumuloException(e);
} finally {
@@ -140,7 +140,7 @@ public class ManagerClient {
break;
} catch (TTransportException tte) {
log.debug("ManagerClient request failed, retrying ... ", tte);
- sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
+ sleepUninterruptibly(100, MILLISECONDS);
} catch (ThriftSecurityException e) {
throw new AccumuloSecurityException(e.user, e.code, e);
} catch (AccumuloException e) {
diff --git a/core/src/main/java/org/apache/accumulo/core/clientImpl/NamespaceOperationsImpl.java b/core/src/main/java/org/apache/accumulo/core/clientImpl/NamespaceOperationsImpl.java
index 2c95c2f..b4de7e0 100644
--- a/core/src/main/java/org/apache/accumulo/core/clientImpl/NamespaceOperationsImpl.java
+++ b/core/src/main/java/org/apache/accumulo/core/clientImpl/NamespaceOperationsImpl.java
@@ -20,6 +20,7 @@ package org.apache.accumulo.core.clientImpl;
import static com.google.common.base.Preconditions.checkArgument;
import static java.nio.charset.StandardCharsets.UTF_8;
+import static java.util.concurrent.TimeUnit.SECONDS;
import static org.apache.accumulo.core.util.Validators.EXISTING_NAMESPACE_NAME;
import static org.apache.accumulo.core.util.Validators.NEW_NAMESPACE_NAME;
@@ -33,7 +34,6 @@ import java.util.Map;
import java.util.SortedSet;
import java.util.TreeMap;
import java.util.TreeSet;
-import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import org.apache.accumulo.core.client.AccumuloException;
@@ -87,7 +87,7 @@ public class NamespaceOperationsImpl extends NamespaceOperationsHelper {
if (timer != null) {
timer.stop();
log.trace("tid={} Fetched {} namespaces in {}", Thread.currentThread().getId(),
- namespaces.size(), String.format("%.3f secs", timer.scale(TimeUnit.SECONDS)));
+ namespaces.size(), String.format("%.3f secs", timer.scale(SECONDS)));
}
return namespaces;
@@ -110,7 +110,7 @@ public class NamespaceOperationsImpl extends NamespaceOperationsHelper {
if (timer != null) {
timer.stop();
log.trace("tid={} Checked existence of {} in {}", Thread.currentThread().getId(), exists,
- String.format("%.3f secs", timer.scale(TimeUnit.SECONDS)));
+ String.format("%.3f secs", timer.scale(SECONDS)));
}
return exists;
diff --git a/core/src/main/java/org/apache/accumulo/core/clientImpl/OfflineIterator.java b/core/src/main/java/org/apache/accumulo/core/clientImpl/OfflineIterator.java
index 209aa7e..fed8130 100644
--- a/core/src/main/java/org/apache/accumulo/core/clientImpl/OfflineIterator.java
+++ b/core/src/main/java/org/apache/accumulo/core/clientImpl/OfflineIterator.java
@@ -18,6 +18,7 @@
*/
package org.apache.accumulo.core.clientImpl;
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static org.apache.accumulo.core.metadata.schema.TabletMetadata.ColumnType.FILES;
import static org.apache.accumulo.core.metadata.schema.TabletMetadata.ColumnType.LOCATION;
import static org.apache.accumulo.core.metadata.schema.TabletMetadata.ColumnType.PREV_ROW;
@@ -30,7 +31,6 @@ import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map.Entry;
-import java.util.concurrent.TimeUnit;
import org.apache.accumulo.core.client.AccumuloException;
import org.apache.accumulo.core.client.SampleNotPresentException;
@@ -244,7 +244,7 @@ class OfflineIterator implements Iterator<Entry<Key,Value>> {
}
}
- sleepUninterruptibly(250, TimeUnit.MILLISECONDS);
+ sleepUninterruptibly(250, MILLISECONDS);
tablet = getTabletFiles(nextRange);
}
diff --git a/core/src/main/java/org/apache/accumulo/core/clientImpl/RootTabletLocator.java b/core/src/main/java/org/apache/accumulo/core/clientImpl/RootTabletLocator.java
index d91dbb5..81f0e55 100644
--- a/core/src/main/java/org/apache/accumulo/core/clientImpl/RootTabletLocator.java
+++ b/core/src/main/java/org/apache/accumulo/core/clientImpl/RootTabletLocator.java
@@ -18,6 +18,8 @@
*/
package org.apache.accumulo.core.clientImpl;
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
+import static java.util.concurrent.TimeUnit.SECONDS;
import static org.apache.accumulo.core.metadata.schema.TabletMetadata.ColumnType.LOCATION;
import static org.apache.accumulo.fate.util.UtilWaitThread.sleepUninterruptibly;
@@ -25,7 +27,6 @@ import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
-import java.util.concurrent.TimeUnit;
import org.apache.accumulo.core.Constants;
import org.apache.accumulo.core.clientImpl.TabletLocatorImpl.TabletServerLockChecker;
@@ -113,7 +114,7 @@ public class RootTabletLocator extends TabletLocator {
if (timer != null) {
timer.stop();
log.trace("tid={} Found root tablet at {} in {}", Thread.currentThread().getId(), loc,
- String.format("%.3f secs", timer.scale(TimeUnit.SECONDS)));
+ String.format("%.3f secs", timer.scale(SECONDS)));
}
if (loc == null || loc.getType() != LocationType.CURRENT) {
@@ -134,7 +135,7 @@ public class RootTabletLocator extends TabletLocator {
TabletLocation location = getRootTabletLocation(context);
// Always retry when finding the root tablet
while (retry && location == null) {
- sleepUninterruptibly(500, TimeUnit.MILLISECONDS);
+ sleepUninterruptibly(500, MILLISECONDS);
location = getRootTabletLocation(context);
}
diff --git a/core/src/main/java/org/apache/accumulo/core/clientImpl/ScannerImpl.java b/core/src/main/java/org/apache/accumulo/core/clientImpl/ScannerImpl.java
index 8da83ed..338726a 100644
--- a/core/src/main/java/org/apache/accumulo/core/clientImpl/ScannerImpl.java
+++ b/core/src/main/java/org/apache/accumulo/core/clientImpl/ScannerImpl.java
@@ -19,12 +19,12 @@
package org.apache.accumulo.core.clientImpl;
import static com.google.common.base.Preconditions.checkArgument;
+import static java.util.concurrent.TimeUnit.SECONDS;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;
-import java.util.concurrent.TimeUnit;
import org.apache.accumulo.core.Constants;
import org.apache.accumulo.core.client.Scanner;
@@ -151,7 +151,7 @@ public class ScannerImpl extends ScannerOptions implements Scanner {
public synchronized Iterator<Entry<Key,Value>> iterator() {
ensureOpen();
ScannerIterator iter = new ScannerIterator(context, tableId, authorizations, range, size,
- getTimeout(TimeUnit.SECONDS), this, isolated, readaheadThreshold, new Reporter());
+ getTimeout(SECONDS), this, isolated, readaheadThreshold, new Reporter());
iters.put(iter, iterCount++);
diff --git a/core/src/main/java/org/apache/accumulo/core/clientImpl/ScannerIterator.java b/core/src/main/java/org/apache/accumulo/core/clientImpl/ScannerIterator.java
index 99485c2..b349333 100644
--- a/core/src/main/java/org/apache/accumulo/core/clientImpl/ScannerIterator.java
+++ b/core/src/main/java/org/apache/accumulo/core/clientImpl/ScannerIterator.java
@@ -18,6 +18,8 @@
*/
package org.apache.accumulo.core.clientImpl;
+import static java.util.concurrent.TimeUnit.SECONDS;
+
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
@@ -27,7 +29,6 @@ import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.ThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
import org.apache.accumulo.core.client.SampleNotPresentException;
import org.apache.accumulo.core.client.TableDeletedException;
@@ -65,7 +66,7 @@ public class ScannerIterator implements Iterator<Entry<Key,Value>> {
private ScannerImpl.Reporter reporter;
private static ThreadPoolExecutor readaheadPool =
- ThreadPools.createThreadPool(0, Integer.MAX_VALUE, 3L, TimeUnit.SECONDS,
+ ThreadPools.createThreadPool(0, Integer.MAX_VALUE, 3L, SECONDS,
"Accumulo scanner read ahead thread", new SynchronousQueue<>(), true);
private boolean closed = false;
diff --git a/core/src/main/java/org/apache/accumulo/core/clientImpl/ScannerOptions.java b/core/src/main/java/org/apache/accumulo/core/clientImpl/ScannerOptions.java
index 05aa172..ee7b1be 100644
--- a/core/src/main/java/org/apache/accumulo/core/clientImpl/ScannerOptions.java
+++ b/core/src/main/java/org/apache/accumulo/core/clientImpl/ScannerOptions.java
@@ -20,6 +20,7 @@ package org.apache.accumulo.core.clientImpl;
import static com.google.common.base.Preconditions.checkArgument;
import static java.util.Objects.requireNonNull;
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
import java.util.ArrayList;
import java.util.Collections;
@@ -205,7 +206,7 @@ public class ScannerOptions implements ScannerBase {
@Override
public synchronized long getTimeout(TimeUnit timeunit) {
- return timeunit.convert(timeOut, TimeUnit.MILLISECONDS);
+ return timeunit.convert(timeOut, MILLISECONDS);
}
@Override
@@ -248,7 +249,7 @@ public class ScannerOptions implements ScannerBase {
@Override
public long getBatchTimeout(TimeUnit timeUnit) {
- return timeUnit.convert(batchTimeOut, TimeUnit.MILLISECONDS);
+ return timeUnit.convert(batchTimeOut, MILLISECONDS);
}
@Override
diff --git a/core/src/main/java/org/apache/accumulo/core/clientImpl/ServerClient.java b/core/src/main/java/org/apache/accumulo/core/clientImpl/ServerClient.java
index afc99e5..00d369e 100644
--- a/core/src/main/java/org/apache/accumulo/core/clientImpl/ServerClient.java
+++ b/core/src/main/java/org/apache/accumulo/core/clientImpl/ServerClient.java
@@ -20,10 +20,10 @@ package org.apache.accumulo.core.clientImpl;
import static com.google.common.base.Preconditions.checkArgument;
import static java.nio.charset.StandardCharsets.UTF_8;
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static org.apache.accumulo.fate.util.UtilWaitThread.sleepUninterruptibly;
import java.util.ArrayList;
-import java.util.concurrent.TimeUnit;
import org.apache.accumulo.core.Constants;
import org.apache.accumulo.core.client.AccumuloException;
@@ -99,7 +99,7 @@ public class ServerClient {
throw new AccumuloServerException(server, tae);
} catch (TTransportException tte) {
log.debug("ClientService request failed " + server + ", retrying ... ", tte);
- sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
+ sleepUninterruptibly(100, MILLISECONDS);
} finally {
if (client != null)
ServerClient.close(client, context);
@@ -123,7 +123,7 @@ public class ServerClient {
throw new AccumuloServerException(server, tae);
} catch (TTransportException tte) {
log.debug("ClientService request failed " + server + ", retrying ... ", tte);
- sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
+ sleepUninterruptibly(100, MILLISECONDS);
} finally {
if (client != null)
ServerClient.close(client, context);
diff --git a/core/src/main/java/org/apache/accumulo/core/clientImpl/TableOperationsImpl.java b/core/src/main/java/org/apache/accumulo/core/clientImpl/TableOperationsImpl.java
index a247239..996d74f 100644
--- a/core/src/main/java/org/apache/accumulo/core/clientImpl/TableOperationsImpl.java
+++ b/core/src/main/java/org/apache/accumulo/core/clientImpl/TableOperationsImpl.java
@@ -22,6 +22,7 @@ import static com.google.common.base.Preconditions.checkArgument;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.util.Objects.requireNonNull;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
+import static java.util.concurrent.TimeUnit.MINUTES;
import static java.util.concurrent.TimeUnit.SECONDS;
import static java.util.stream.Collectors.toSet;
import static org.apache.accumulo.core.metadata.schema.TabletMetadata.ColumnType.LOCATION;
@@ -55,7 +56,6 @@ import java.util.TreeMap;
import java.util.TreeSet;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
-import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Predicate;
import java.util.regex.Pattern;
@@ -183,7 +183,7 @@ public class TableOperationsImpl extends TableOperationsHelper {
if (timer != null) {
timer.stop();
log.trace("tid={} Fetched {} table names in {}", Thread.currentThread().getId(),
- tableNames.size(), String.format("%.3f secs", timer.scale(TimeUnit.SECONDS)));
+ tableNames.size(), String.format("%.3f secs", timer.scale(SECONDS)));
}
return tableNames;
@@ -208,7 +208,7 @@ public class TableOperationsImpl extends TableOperationsHelper {
if (timer != null) {
timer.stop();
log.trace("tid={} Checked existence of {} in {}", Thread.currentThread().getId(), exists,
- String.format("%.3f secs", timer.scale(TimeUnit.SECONDS)));
+ String.format("%.3f secs", timer.scale(SECONDS)));
}
return exists;
@@ -261,11 +261,11 @@ public class TableOperationsImpl extends TableOperationsHelper {
return client.beginFateOperation(TraceUtil.traceInfo(), context.rpcCreds());
} catch (TTransportException tte) {
log.debug("Failed to call beginFateOperation(), retrying ... ", tte);
- sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
+ sleepUninterruptibly(100, MILLISECONDS);
} catch (ThriftNotActiveServiceException e) {
// Let it loop, fetching a new location
log.debug("Contacted a Manager which is no longer active, retrying");
- sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
+ sleepUninterruptibly(100, MILLISECONDS);
} finally {
ManagerClient.close(client, context);
}
@@ -286,11 +286,11 @@ public class TableOperationsImpl extends TableOperationsHelper {
return;
} catch (TTransportException tte) {
log.debug("Failed to call executeFateOperation(), retrying ... ", tte);
- sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
+ sleepUninterruptibly(100, MILLISECONDS);
} catch (ThriftNotActiveServiceException e) {
// Let it loop, fetching a new location
log.debug("Contacted a Manager which is no longer active, retrying");
- sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
+ sleepUninterruptibly(100, MILLISECONDS);
} finally {
ManagerClient.close(client, context);
}
@@ -306,11 +306,11 @@ public class TableOperationsImpl extends TableOperationsHelper {
return client.waitForFateOperation(TraceUtil.traceInfo(), context.rpcCreds(), opid);
} catch (TTransportException tte) {
log.debug("Failed to call waitForFateOperation(), retrying ... ", tte);
- sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
+ sleepUninterruptibly(100, MILLISECONDS);
} catch (ThriftNotActiveServiceException e) {
// Let it loop, fetching a new location
log.debug("Contacted a Manager which is no longer active, retrying");
- sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
+ sleepUninterruptibly(100, MILLISECONDS);
} finally {
ManagerClient.close(client, context);
}
@@ -326,11 +326,11 @@ public class TableOperationsImpl extends TableOperationsHelper {
break;
} catch (TTransportException tte) {
log.debug("Failed to call finishFateOperation(), retrying ... ", tte);
- sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
+ sleepUninterruptibly(100, MILLISECONDS);
} catch (ThriftNotActiveServiceException e) {
// Let it loop, fetching a new location
log.debug("Contacted a Manager which is no longer active, retrying");
- sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
+ sleepUninterruptibly(100, MILLISECONDS);
} finally {
ManagerClient.close(client, context);
}
@@ -492,7 +492,7 @@ public class TableOperationsImpl extends TableOperationsHelper {
executor.execute(
new SplitTask(new SplitEnv(tableName, tableId, executor, latch, exception), splits));
- while (!latch.await(100, TimeUnit.MILLISECONDS)) {
+ while (!latch.await(100, MILLISECONDS)) {
if (exception.get() != null) {
executor.shutdownNow();
Throwable excep = exception.get();
@@ -540,7 +540,7 @@ public class TableOperationsImpl extends TableOperationsHelper {
while (!successful) {
if (attempt > 0)
- sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
+ sleepUninterruptibly(100, MILLISECONDS);
attempt++;
@@ -574,8 +574,7 @@ public class TableOperationsImpl extends TableOperationsHelper {
if (timer != null) {
timer.stop();
- log.trace("Split tablet in {}",
- String.format("%.3f secs", timer.scale(TimeUnit.SECONDS)));
+ log.trace("Split tablet in {}", String.format("%.3f secs", timer.scale(SECONDS)));
}
} finally {
@@ -676,7 +675,7 @@ public class TableOperationsImpl extends TableOperationsHelper {
}
log.info("{} ... retrying ...", e, e);
- sleepUninterruptibly(3, TimeUnit.SECONDS);
+ sleepUninterruptibly(3, SECONDS);
}
}
@@ -955,11 +954,11 @@ public class TableOperationsImpl extends TableOperationsHelper {
break;
} catch (TTransportException tte) {
log.debug("Failed to call initiateFlush, retrying ... ", tte);
- sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
+ sleepUninterruptibly(100, MILLISECONDS);
} catch (ThriftNotActiveServiceException e) {
// Let it loop, fetching a new location
log.debug("Contacted a Manager which is no longer active, retrying");
- sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
+ sleepUninterruptibly(100, MILLISECONDS);
} finally {
ManagerClient.close(client, context);
}
@@ -975,11 +974,11 @@ public class TableOperationsImpl extends TableOperationsHelper {
break;
} catch (TTransportException tte) {
log.debug("Failed to call initiateFlush, retrying ... ", tte);
- sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
+ sleepUninterruptibly(100, MILLISECONDS);
} catch (ThriftNotActiveServiceException e) {
// Let it loop, fetching a new location
log.debug("Contacted a Manager which is no longer active, retrying");
- sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
+ sleepUninterruptibly(100, MILLISECONDS);
} finally {
ManagerClient.close(client, context);
}
@@ -1172,7 +1171,7 @@ public class TableOperationsImpl extends TableOperationsHelper {
log.warn("Unable to locate bins for specified range. Retrying.");
// sleep randomly between 100 and 200ms
- sleepUninterruptibly(100 + random.nextInt(100), TimeUnit.MILLISECONDS);
+ sleepUninterruptibly(100 + random.nextInt(100), MILLISECONDS);
binnedRanges.clear();
tl.invalidateCache();
}
@@ -1349,7 +1348,7 @@ public class TableOperationsImpl extends TableOperationsHelper {
waitTime = Math.min(5000, waitTime);
log.trace("Waiting for {}({}) tablets, startRow = {} lastRow = {}, holes={} sleeping:{}ms",
waitFor, maxPerServer, startRow, lastRow, holes, waitTime);
- sleepUninterruptibly(waitTime, TimeUnit.MILLISECONDS);
+ sleepUninterruptibly(waitTime, MILLISECONDS);
} else {
break;
}
@@ -1485,7 +1484,7 @@ public class TableOperationsImpl extends TableOperationsHelper {
} else {
log.debug("Disk usage request failed {}, retrying ... ", pair.getFirst(), e);
}
- sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
+ sleepUninterruptibly(100, MILLISECONDS);
} catch (TException e) {
// may be a TApplicationException which indicates error on the server side
throw new AccumuloException(e);
@@ -1844,7 +1843,7 @@ public class TableOperationsImpl extends TableOperationsHelper {
Retry retry = Retry.builder().infiniteRetries().retryAfter(100, MILLISECONDS)
.incrementBy(100, MILLISECONDS).maxWait(2, SECONDS).backOffFactor(1.5)
- .logInterval(3, TimeUnit.MINUTES).createRetry();
+ .logInterval(3, MINUTES).createRetry();
while (!locator.binRanges(context, rangeList, binnedRanges).isEmpty()) {
context.requireTableExists(tableId, tableName);
diff --git a/core/src/main/java/org/apache/accumulo/core/clientImpl/TabletLocatorImpl.java b/core/src/main/java/org/apache/accumulo/core/clientImpl/TabletLocatorImpl.java
index 5e4d4e4..b4eb6d5 100644
--- a/core/src/main/java/org/apache/accumulo/core/clientImpl/TabletLocatorImpl.java
+++ b/core/src/main/java/org/apache/accumulo/core/clientImpl/TabletLocatorImpl.java
@@ -18,6 +18,8 @@
*/
package org.apache.accumulo.core.clientImpl;
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
+import static java.util.concurrent.TimeUnit.SECONDS;
import static org.apache.accumulo.fate.util.UtilWaitThread.sleepUninterruptibly;
import java.util.ArrayList;
@@ -33,7 +35,6 @@ import java.util.Map.Entry;
import java.util.SortedMap;
import java.util.TreeMap;
import java.util.TreeSet;
-import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
@@ -227,7 +228,7 @@ public class TabletLocatorImpl extends TabletLocator {
timer.stop();
log.trace("tid={} Binned {} mutations for table {} to {} tservers in {}",
Thread.currentThread().getId(), mutations.size(), tableId, binnedMutations.size(),
- String.format("%.3f secs", timer.scale(TimeUnit.SECONDS)));
+ String.format("%.3f secs", timer.scale(SECONDS)));
}
}
@@ -373,7 +374,7 @@ public class TabletLocatorImpl extends TabletLocator {
timer.stop();
log.trace("tid={} Binned {} ranges for table {} to {} tservers in {}",
Thread.currentThread().getId(), ranges.size(), tableId, binnedRanges.size(),
- String.format("%.3f secs", timer.scale(TimeUnit.SECONDS)));
+ String.format("%.3f secs", timer.scale(SECONDS)));
}
return failures;
@@ -458,7 +459,7 @@ public class TabletLocatorImpl extends TabletLocator {
TabletLocation tl = _locateTablet(context, row, skipRow, retry, true, lcSession);
if (retry && tl == null) {
- sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
+ sleepUninterruptibly(100, MILLISECONDS);
if (log.isTraceEnabled())
log.trace("Failed to locate tablet containing row {} in table {}, will retry...",
TextUtil.truncate(row), tableId);
@@ -469,7 +470,7 @@ public class TabletLocatorImpl extends TabletLocator {
timer.stop();
log.trace("tid={} Located tablet {} at {} in {}", Thread.currentThread().getId(),
(tl == null ? "null" : tl.tablet_extent), (tl == null ? "null" : tl.tablet_location),
- String.format("%.3f secs", timer.scale(TimeUnit.SECONDS)));
+ String.format("%.3f secs", timer.scale(SECONDS)));
}
return tl;
diff --git a/core/src/main/java/org/apache/accumulo/core/clientImpl/TabletServerBatchReaderIterator.java b/core/src/main/java/org/apache/accumulo/core/clientImpl/TabletServerBatchReaderIterator.java
index 660d314..d9ee46c 100644
--- a/core/src/main/java/org/apache/accumulo/core/clientImpl/TabletServerBatchReaderIterator.java
+++ b/core/src/main/java/org/apache/accumulo/core/clientImpl/TabletServerBatchReaderIterator.java
@@ -18,6 +18,8 @@
*/
package org.apache.accumulo.core.clientImpl;
+import static java.util.concurrent.TimeUnit.SECONDS;
+
import java.io.IOException;
import java.util.AbstractMap.SimpleImmutableEntry;
import java.util.ArrayList;
@@ -35,7 +37,6 @@ import java.util.Set;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Semaphore;
-import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
import java.util.stream.Collectors;
@@ -169,7 +170,7 @@ public class TabletServerBatchReaderIterator implements Iterator<Entry<Key,Value
try {
batch = null;
while (batch == null && fatalException == null && !queryThreadPool.isShutdown())
- batch = resultsQueue.poll(1, TimeUnit.SECONDS);
+ batch = resultsQueue.poll(1, SECONDS);
if (fatalException != null)
if (fatalException instanceof RuntimeException)
@@ -699,7 +700,7 @@ public class TabletServerBatchReaderIterator implements Iterator<Entry<Key,Value
log.trace("tid={} Got 1st multi scan results, #results={} {} in {}",
Thread.currentThread().getId(), scanResult.results.size(),
(scanResult.more ? "scanID=" + imsr.scanID : ""),
- String.format("%.3f secs", timer.scale(TimeUnit.SECONDS)));
+ String.format("%.3f secs", timer.scale(SECONDS)));
}
ArrayList<Entry<Key,Value>> entries = new ArrayList<>(scanResult.results.size());
@@ -734,7 +735,7 @@ public class TabletServerBatchReaderIterator implements Iterator<Entry<Key,Value
log.trace("tid={} oid={} Got more multi scan results, #results={} {} in {}",
Thread.currentThread().getId(), nextOpid.getAndIncrement(),
scanResult.results.size(), (scanResult.more ? " scanID=" + imsr.scanID : ""),
- String.format("%.3f secs", timer.scale(TimeUnit.SECONDS)));
+ String.format("%.3f secs", timer.scale(SECONDS)));
}
entries = new ArrayList<>(scanResult.results.size());
diff --git a/core/src/main/java/org/apache/accumulo/core/clientImpl/TabletServerBatchWriter.java b/core/src/main/java/org/apache/accumulo/core/clientImpl/TabletServerBatchWriter.java
index 75e862c..9047622 100644
--- a/core/src/main/java/org/apache/accumulo/core/clientImpl/TabletServerBatchWriter.java
+++ b/core/src/main/java/org/apache/accumulo/core/clientImpl/TabletServerBatchWriter.java
@@ -18,6 +18,7 @@
*/
package org.apache.accumulo.core.clientImpl;
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static java.util.function.Function.identity;
import static java.util.stream.Collectors.toList;
import static java.util.stream.Collectors.toMap;
@@ -39,7 +40,6 @@ import java.util.TreeSet;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.ThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
@@ -204,9 +204,9 @@ public class TabletServerBatchWriter implements AutoCloseable {
ThreadPools.createGeneralScheduledExecutorService(this.context.getConfiguration());
this.failedMutations = new FailedMutations();
this.maxMem = config.getMaxMemory();
- this.maxLatency = config.getMaxLatency(TimeUnit.MILLISECONDS) <= 0 ? Long.MAX_VALUE
- : config.getMaxLatency(TimeUnit.MILLISECONDS);
- this.timeout = config.getTimeout(TimeUnit.MILLISECONDS);
+ this.maxLatency = config.getMaxLatency(MILLISECONDS) <= 0 ? Long.MAX_VALUE
+ : config.getMaxLatency(MILLISECONDS);
+ this.timeout = config.getTimeout(MILLISECONDS);
this.mutations = new MutationSet();
this.lastProcessingStartTime = System.currentTimeMillis();
this.durability = config.getDurability();
@@ -224,7 +224,7 @@ public class TabletServerBatchWriter implements AutoCloseable {
} catch (Exception e) {
updateUnknownErrors("Max latency task failed " + e.getMessage(), e);
}
- }), 0, this.maxLatency / 4, TimeUnit.MILLISECONDS);
+ }), 0, this.maxLatency / 4, MILLISECONDS);
}
}
@@ -580,7 +580,7 @@ public class TabletServerBatchWriter implements AutoCloseable {
FailedMutations() {
task =
Threads.createNamedRunnable("failed mutationBatchWriterLatencyTimers handler", this::run);
- executor.scheduleWithFixedDelay(task, 0, 500, TimeUnit.MILLISECONDS);
+ executor.scheduleWithFixedDelay(task, 0, 500, MILLISECONDS);
}
private MutationSet init() {
diff --git a/core/src/main/java/org/apache/accumulo/core/clientImpl/ThriftScanner.java b/core/src/main/java/org/apache/accumulo/core/clientImpl/ThriftScanner.java
index 8516ee6..0243a84 100644
--- a/core/src/main/java/org/apache/accumulo/core/clientImpl/ThriftScanner.java
+++ b/core/src/main/java/org/apache/accumulo/core/clientImpl/ThriftScanner.java
@@ -18,6 +18,8 @@
*/
package org.apache.accumulo.core.clientImpl;
+import static java.util.concurrent.TimeUnit.SECONDS;
+
import java.io.IOException;
import java.security.SecureRandom;
import java.util.ArrayList;
@@ -29,7 +31,6 @@ import java.util.Map;
import java.util.Set;
import java.util.SortedMap;
import java.util.SortedSet;
-import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import org.apache.accumulo.core.Constants;
@@ -516,9 +517,8 @@ public class ThriftScanner {
if (timer != null) {
timer.stop();
log.trace("tid={} Finished scan in {} #results={} scanid={}",
- Thread.currentThread().getId(),
- String.format("%.3f secs", timer.scale(TimeUnit.SECONDS)), sr.results.size(),
- scanState.scanID);
+ Thread.currentThread().getId(), String.format("%.3f secs", timer.scale(SECONDS)),
+ sr.results.size(), scanState.scanID);
}
} else {
// log.debug("No more : tab end row = "+loc.tablet_extent.getEndRow()+" range =
@@ -529,8 +529,8 @@ public class ThriftScanner {
if (timer != null) {
timer.stop();
log.trace("tid={} Completely finished scan in {} #results={}",
- Thread.currentThread().getId(),
- String.format("%.3f secs", timer.scale(TimeUnit.SECONDS)), sr.results.size());
+ Thread.currentThread().getId(), String.format("%.3f secs", timer.scale(SECONDS)),
+ sr.results.size());
}
} else if (scanState.range.getEndKey() == null || !scanState.range
@@ -541,16 +541,16 @@ public class ThriftScanner {
if (timer != null) {
timer.stop();
log.trace("tid={} Finished scanning tablet in {} #results={}",
- Thread.currentThread().getId(),
- String.format("%.3f secs", timer.scale(TimeUnit.SECONDS)), sr.results.size());
+ Thread.currentThread().getId(), String.format("%.3f secs", timer.scale(SECONDS)),
+ sr.results.size());
}
} else {
scanState.finished = true;
if (timer != null) {
timer.stop();
log.trace("tid={} Completely finished in {} #results={}",
- Thread.currentThread().getId(),
- String.format("%.3f secs", timer.scale(TimeUnit.SECONDS)), sr.results.size());
+ Thread.currentThread().getId(), String.format("%.3f secs", timer.scale(SECONDS)),
+ sr.results.size());
}
}
}
diff --git a/core/src/main/java/org/apache/accumulo/core/clientImpl/ThriftTransportPool.java b/core/src/main/java/org/apache/accumulo/core/clientImpl/ThriftTransportPool.java
index 49641e2..98893ca 100644
--- a/core/src/main/java/org/apache/accumulo/core/clientImpl/ThriftTransportPool.java
+++ b/core/src/main/java/org/apache/accumulo/core/clientImpl/ThriftTransportPool.java
@@ -18,6 +18,8 @@
*/
package org.apache.accumulo.core.clientImpl;
+import static java.util.concurrent.TimeUnit.MINUTES;
+
import java.security.SecureRandom;
import java.util.ArrayDeque;
import java.util.ArrayList;
@@ -371,7 +373,7 @@ public class ThriftTransportPool {
private static final Logger log = LoggerFactory.getLogger(ThriftTransportPool.class);
private static final Long ERROR_THRESHOLD = 20L;
- private static final int STUCK_THRESHOLD = 2 * 60_000;
+ private static final long STUCK_THRESHOLD = MINUTES.toMillis(2);
private static class CachedConnection {
diff --git a/core/src/main/java/org/apache/accumulo/core/clientImpl/Writer.java b/core/src/main/java/org/apache/accumulo/core/clientImpl/Writer.java
index da67a5b..9425fb8 100644
--- a/core/src/main/java/org/apache/accumulo/core/clientImpl/Writer.java
+++ b/core/src/main/java/org/apache/accumulo/core/clientImpl/Writer.java
@@ -20,10 +20,9 @@ package org.apache.accumulo.core.clientImpl;
import static com.google.common.base.Preconditions.checkArgument;
import static java.nio.charset.StandardCharsets.UTF_8;
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static org.apache.accumulo.fate.util.UtilWaitThread.sleepUninterruptibly;
-import java.util.concurrent.TimeUnit;
-
import org.apache.accumulo.core.client.AccumuloException;
import org.apache.accumulo.core.client.AccumuloSecurityException;
import org.apache.accumulo.core.client.TableNotFoundException;
@@ -93,7 +92,7 @@ public class Writer {
if (tabLoc == null) {
log.trace("No tablet location found for row {}", new String(m.getRow(), UTF_8));
- sleepUninterruptibly(500, TimeUnit.MILLISECONDS);
+ sleepUninterruptibly(500, MILLISECONDS);
continue;
}
@@ -114,7 +113,7 @@ public class Writer {
TabletLocator.getLocator(context, tableId).invalidateCache(tabLoc.tablet_extent);
}
- sleepUninterruptibly(500, TimeUnit.MILLISECONDS);
+ sleepUninterruptibly(500, MILLISECONDS);
}
}
diff --git a/core/src/main/java/org/apache/accumulo/core/clientImpl/bulk/BulkImport.java b/core/src/main/java/org/apache/accumulo/core/clientImpl/bulk/BulkImport.java
index f0cb714..eef25cc 100644
--- a/core/src/main/java/org/apache/accumulo/core/clientImpl/bulk/BulkImport.java
+++ b/core/src/main/java/org/apache/accumulo/core/clientImpl/bulk/BulkImport.java
@@ -46,7 +46,6 @@ import java.util.concurrent.CompletionException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
-import java.util.concurrent.TimeUnit;
import java.util.stream.Stream;
import org.apache.accumulo.core.Constants;
@@ -146,7 +145,7 @@ public class BulkImport implements ImportDestinationArguments, ImportMappingOpti
}
Retry retry = Retry.builder().infiniteRetries().retryAfter(100, MILLISECONDS)
.incrementBy(100, MILLISECONDS).maxWait(2, MINUTES).backOffFactor(1.5)
- .logInterval(3, TimeUnit.MINUTES).createRetry();
+ .logInterval(3, MINUTES).createRetry();
// retry if a merge occurs
boolean shouldRetry = true;
diff --git a/core/src/main/java/org/apache/accumulo/core/conf/ConfigurationTypeHelper.java b/core/src/main/java/org/apache/accumulo/core/conf/ConfigurationTypeHelper.java
index 2e9ecb7..5951f61 100644
--- a/core/src/main/java/org/apache/accumulo/core/conf/ConfigurationTypeHelper.java
+++ b/core/src/main/java/org/apache/accumulo/core/conf/ConfigurationTypeHelper.java
@@ -18,6 +18,12 @@
*/
package org.apache.accumulo.core.conf;
+import static java.util.concurrent.TimeUnit.DAYS;
+import static java.util.concurrent.TimeUnit.HOURS;
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
+import static java.util.concurrent.TimeUnit.MINUTES;
+import static java.util.concurrent.TimeUnit.SECONDS;
+
import java.io.IOException;
import java.util.Collections;
import java.util.HashMap;
@@ -114,23 +120,23 @@ public class ConfigurationTypeHelper {
int unitsLen = 1;
switch (str.charAt(str.length() - 1)) {
case 'd':
- timeUnit = TimeUnit.DAYS;
+ timeUnit = DAYS;
break;
case 'h':
- timeUnit = TimeUnit.HOURS;
+ timeUnit = HOURS;
break;
case 'm':
- timeUnit = TimeUnit.MINUTES;
+ timeUnit = MINUTES;
break;
case 's':
- timeUnit = TimeUnit.SECONDS;
+ timeUnit = SECONDS;
if (str.endsWith("ms")) {
- timeUnit = TimeUnit.MILLISECONDS;
+ timeUnit = MILLISECONDS;
unitsLen = 2;
}
break;
default:
- timeUnit = TimeUnit.SECONDS;
+ timeUnit = SECONDS;
unitsLen = 0;
break;
}
diff --git a/core/src/main/java/org/apache/accumulo/core/file/BloomFilterLayer.java b/core/src/main/java/org/apache/accumulo/core/file/BloomFilterLayer.java
index 778e7a3..3b4c041 100644
--- a/core/src/main/java/org/apache/accumulo/core/file/BloomFilterLayer.java
+++ b/core/src/main/java/org/apache/accumulo/core/file/BloomFilterLayer.java
@@ -18,6 +18,8 @@
*/
package org.apache.accumulo.core.file;
+import static java.util.concurrent.TimeUnit.SECONDS;
+
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
@@ -30,7 +32,6 @@ import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ExecutorService;
-import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.accumulo.core.bloomfilter.DynamicBloomFilter;
@@ -78,8 +79,8 @@ public class BloomFilterLayer {
}
if (maxLoadThreads > 0) {
- loadThreadPool = ThreadPools.createThreadPool(0, maxLoadThreads, 60, TimeUnit.SECONDS,
- "bloom-loader", false);
+ loadThreadPool =
+ ThreadPools.createThreadPool(0, maxLoadThreads, 60, SECONDS, "bloom-loader", false);
}
return loadThreadPool;
diff --git a/core/src/main/java/org/apache/accumulo/core/file/blockfile/cache/lru/LruBlockCache.java b/core/src/main/java/org/apache/accumulo/core/file/blockfile/cache/lru/LruBlockCache.java
index cadc4e0..b66fa36 100644
--- a/core/src/main/java/org/apache/accumulo/core/file/blockfile/cache/lru/LruBlockCache.java
+++ b/core/src/main/java/org/apache/accumulo/core/file/blockfile/cache/lru/LruBlockCache.java
@@ -18,6 +18,7 @@
*/
package org.apache.accumulo.core.file.blockfile.cache.lru;
+import static java.util.concurrent.TimeUnit.SECONDS;
import static org.apache.accumulo.core.file.blockfile.cache.impl.ClassSize.CONCURRENT_HASHMAP;
import static org.apache.accumulo.core.file.blockfile.cache.impl.ClassSize.CONCURRENT_HASHMAP_ENTRY;
import static org.apache.accumulo.core.file.blockfile.cache.impl.ClassSize.CONCURRENT_HASHMAP_SEGMENT;
@@ -27,7 +28,6 @@ import java.util.Objects;
import java.util.PriorityQueue;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.locks.ReentrantLock;
import java.util.function.Supplier;
@@ -161,7 +161,7 @@ public class LruBlockCache extends SynchronousLoadingBlockCache implements Block
this.evictionThread = null;
}
this.scheduleThreadPool.scheduleAtFixedRate(new StatisticsThread(this), statThreadPeriod,
- statThreadPeriod, TimeUnit.SECONDS);
+ statThreadPeriod, SECONDS);
}
public long getOverhead() {
diff --git a/core/src/main/java/org/apache/accumulo/core/file/blockfile/cache/tinylfu/TinyLfuBlockCache.java b/core/src/main/java/org/apache/accumulo/core/file/blockfile/cache/tinylfu/TinyLfuBlockCache.java
index dba920f..6553319 100644
--- a/core/src/main/java/org/apache/accumulo/core/file/blockfile/cache/tinylfu/TinyLfuBlockCache.java
+++ b/core/src/main/java/org/apache/accumulo/core/file/blockfile/cache/tinylfu/TinyLfuBlockCache.java
@@ -18,12 +18,13 @@
*/
package org.apache.accumulo.core.file.blockfile.cache.tinylfu;
+import static java.util.concurrent.TimeUnit.SECONDS;
+
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
import java.util.function.Supplier;
import org.apache.accumulo.core.file.blockfile.cache.impl.ClassSize;
@@ -70,8 +71,7 @@ public final class TinyLfuBlockCache implements BlockCache {
}).maximumWeight(conf.getMaxSize(type)).recordStats().build();
policy = cache.policy().eviction().get();
maxSize = (int) Math.min(Integer.MAX_VALUE, policy.getMaximum());
- statsExecutor.scheduleAtFixedRate(this::logStats, STATS_PERIOD_SEC, STATS_PERIOD_SEC,
- TimeUnit.SECONDS);
+ statsExecutor.scheduleAtFixedRate(this::logStats, STATS_PERIOD_SEC, STATS_PERIOD_SEC, SECONDS);
}
@Override
diff --git a/core/src/main/java/org/apache/accumulo/core/iterators/Combiner.java b/core/src/main/java/org/apache/accumulo/core/iterators/Combiner.java
index f6c326a..c3fd555 100644
--- a/core/src/main/java/org/apache/accumulo/core/iterators/Combiner.java
+++ b/core/src/main/java/org/apache/accumulo/core/iterators/Combiner.java
@@ -18,6 +18,8 @@
*/
package org.apache.accumulo.core.iterators;
+import static java.util.concurrent.TimeUnit.HOURS;
+
import java.io.IOException;
import java.util.Collection;
import java.util.Iterator;
@@ -25,7 +27,6 @@ import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
import org.apache.accumulo.core.client.IteratorSetting;
import org.apache.accumulo.core.client.IteratorSetting.Column;
@@ -184,7 +185,7 @@ public abstract class Combiner extends WrappingIterator implements OptionDescrib
@VisibleForTesting
static final Cache<String,Boolean> loggedMsgCache =
- CacheBuilder.newBuilder().expireAfterWrite(1, TimeUnit.HOURS).maximumSize(10000).build();
+ CacheBuilder.newBuilder().expireAfterWrite(1, HOURS).maximumSize(10000).build();
private void sawDelete() {
if (isMajorCompaction && !reduceOnFullCompactionOnly) {
diff --git a/core/src/main/java/org/apache/accumulo/core/metadata/MetadataLocationObtainer.java b/core/src/main/java/org/apache/accumulo/core/metadata/MetadataLocationObtainer.java
index 07b7f11..b68cbf0 100644
--- a/core/src/main/java/org/apache/accumulo/core/metadata/MetadataLocationObtainer.java
+++ b/core/src/main/java/org/apache/accumulo/core/metadata/MetadataLocationObtainer.java
@@ -18,6 +18,8 @@
*/
package org.apache.accumulo.core.metadata;
+import static java.util.concurrent.TimeUnit.SECONDS;
+
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
@@ -29,7 +31,6 @@ import java.util.SortedMap;
import java.util.SortedSet;
import java.util.TreeMap;
import java.util.TreeSet;
-import java.util.concurrent.TimeUnit;
import org.apache.accumulo.core.Constants;
import org.apache.accumulo.core.client.AccumuloException;
@@ -124,8 +125,7 @@ public class MetadataLocationObtainer implements TabletLocationObtainer {
if (timer != null) {
timer.stop();
log.trace("tid={} Got {} results from {} in {}", Thread.currentThread().getId(),
- results.size(), src.tablet_extent,
- String.format("%.3f secs", timer.scale(TimeUnit.SECONDS)));
+ results.size(), src.tablet_extent, String.format("%.3f secs", timer.scale(SECONDS)));
}
// if (log.isTraceEnabled()) log.trace("results "+results);
diff --git a/core/src/main/java/org/apache/accumulo/core/metadata/schema/LinkingIterator.java b/core/src/main/java/org/apache/accumulo/core/metadata/schema/LinkingIterator.java
index 5efe356..7c9c230 100644
--- a/core/src/main/java/org/apache/accumulo/core/metadata/schema/LinkingIterator.java
+++ b/core/src/main/java/org/apache/accumulo/core/metadata/schema/LinkingIterator.java
@@ -18,10 +18,10 @@
*/
package org.apache.accumulo.core.metadata.schema;
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static org.apache.accumulo.fate.util.UtilWaitThread.sleepUninterruptibly;
import java.util.Iterator;
-import java.util.concurrent.TimeUnit;
import java.util.function.Function;
import org.apache.accumulo.core.data.Key;
@@ -176,7 +176,7 @@ public class LinkingIterator implements Iterator<TabletMetadata> {
}
if (currTablet == null) {
- sleepUninterruptibly(sleepTime, TimeUnit.MILLISECONDS);
+ sleepUninterruptibly(sleepTime, MILLISECONDS);
resetSource();
sleepTime = Math.min(2 * sleepTime, 5000);
}
diff --git a/core/src/main/java/org/apache/accumulo/core/spi/balancer/HostRegexTableLoadBalancer.java b/core/src/main/java/org/apache/accumulo/core/spi/balancer/HostRegexTableLoadBalancer.java
index d830ee8..a6346bd 100644
--- a/core/src/main/java/org/apache/accumulo/core/spi/balancer/HostRegexTableLoadBalancer.java
+++ b/core/src/main/java/org/apache/accumulo/core/spi/balancer/HostRegexTableLoadBalancer.java
@@ -18,6 +18,8 @@
*/
package org.apache.accumulo.core.spi.balancer;
+import static java.util.concurrent.TimeUnit.HOURS;
+
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.security.SecureRandom;
@@ -32,7 +34,6 @@ import java.util.Map.Entry;
import java.util.Set;
import java.util.SortedMap;
import java.util.TreeMap;
-import java.util.concurrent.TimeUnit;
import java.util.function.Supplier;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
@@ -175,7 +176,6 @@ public class HostRegexTableLoadBalancer extends TableLoadBalancer {
}
}
- private static final long ONE_HOUR = 60 * 60_000;
private static final Set<TabletId> EMPTY_MIGRATIONS = Collections.emptySet();
private volatile long lastOOBCheck = System.currentTimeMillis();
private Map<String,SortedMap<TabletServerId,TServerStatus>> pools = new HashMap<>();
@@ -326,7 +326,7 @@ public class HostRegexTableLoadBalancer extends TableLoadBalancer {
this.hrtlbConf = balancerEnvironment.getConfiguration().getDerived(HrtlbConf::new);
tablesRegExCache =
- CacheBuilder.newBuilder().expireAfterAccess(1, TimeUnit.HOURS).build(new CacheLoader<>() {
+ CacheBuilder.newBuilder().expireAfterAccess(1, HOURS).build(new CacheLoader<>() {
@Override
public Supplier<Map<String,String>> load(TableId key) {
return balancerEnvironment.getConfiguration(key)
@@ -512,7 +512,7 @@ public class HostRegexTableLoadBalancer extends TableLoadBalancer {
if (newMigrations.isEmpty()) {
tableToTimeSinceNoMigrations.remove(tableId);
} else if (tableToTimeSinceNoMigrations.containsKey(tableId)) {
- if ((now - tableToTimeSinceNoMigrations.get(tableId)) > ONE_HOUR) {
+ if ((now - tableToTimeSinceNoMigrations.get(tableId)) > HOURS.toMillis(1)) {
LOG.warn("We have been consistently producing migrations for {}: {}", tableName,
Iterables.limit(newMigrations, 10));
}
diff --git a/core/src/main/java/org/apache/accumulo/core/spi/balancer/SimpleLoadBalancer.java b/core/src/main/java/org/apache/accumulo/core/spi/balancer/SimpleLoadBalancer.java
index 96aea38..323f22c 100644
--- a/core/src/main/java/org/apache/accumulo/core/spi/balancer/SimpleLoadBalancer.java
+++ b/core/src/main/java/org/apache/accumulo/core/spi/balancer/SimpleLoadBalancer.java
@@ -18,6 +18,8 @@
*/
package org.apache.accumulo.core.spi.balancer;
+import static java.util.concurrent.TimeUnit.SECONDS;
+
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
@@ -28,7 +30,6 @@ import java.util.Map.Entry;
import java.util.Objects;
import java.util.Set;
import java.util.SortedMap;
-import java.util.concurrent.TimeUnit;
import org.apache.accumulo.core.client.AccumuloException;
import org.apache.accumulo.core.client.AccumuloSecurityException;
@@ -374,7 +375,7 @@ public class SimpleLoadBalancer implements TabletBalancer {
if (params.currentMigrations().isEmpty()) {
problemReporter.clearProblemReportTimes();
if (getMigrations(params.currentStatus(), params.migrationsOut()))
- return TimeUnit.SECONDS.toMillis(1);
+ return SECONDS.toMillis(1);
} else {
outstandingMigrationsProblem.setMigrations(params.currentMigrations());
problemReporter.reportProblem(outstandingMigrationsProblem);
diff --git a/core/src/main/java/org/apache/accumulo/core/spi/fs/SpaceAwareVolumeChooser.java b/core/src/main/java/org/apache/accumulo/core/spi/fs/SpaceAwareVolumeChooser.java
index 7fc6bde..fd1b8d3 100644
--- a/core/src/main/java/org/apache/accumulo/core/spi/fs/SpaceAwareVolumeChooser.java
+++ b/core/src/main/java/org/apache/accumulo/core/spi/fs/SpaceAwareVolumeChooser.java
@@ -18,13 +18,14 @@
*/
package org.apache.accumulo.core.spi.fs;
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
+
import java.io.IOException;
import java.security.SecureRandom;
import java.util.NavigableMap;
import java.util.Set;
import java.util.TreeMap;
import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
import org.apache.commons.lang3.StringUtils;
import org.apache.hadoop.conf.Configuration;
@@ -84,8 +85,7 @@ public class SpaceAwareVolumeChooser extends PreferredVolumeChooser {
? Long.parseLong(propertyValue) : defaultComputationCacheDuration;
choiceCache = CacheBuilder.newBuilder()
- .expireAfterWrite(computationCacheDuration, TimeUnit.MILLISECONDS)
- .build(new CacheLoader<>() {
+ .expireAfterWrite(computationCacheDuration, MILLISECONDS).build(new CacheLoader<>() {
@Override
public WeightedRandomCollection load(Set<String> key) {
return new WeightedRandomCollection(key, env);
diff --git a/core/src/main/java/org/apache/accumulo/core/summary/Gatherer.java b/core/src/main/java/org/apache/accumulo/core/summary/Gatherer.java
index 2d19a84..363cebb 100644
--- a/core/src/main/java/org/apache/accumulo/core/summary/Gatherer.java
+++ b/core/src/main/java/org/apache/accumulo/core/summary/Gatherer.java
@@ -19,6 +19,7 @@
package org.apache.accumulo.core.summary;
import static java.nio.charset.StandardCharsets.UTF_8;
+import static java.util.concurrent.TimeUnit.NANOSECONDS;
import static org.apache.accumulo.core.metadata.schema.TabletMetadata.ColumnType.FILES;
import static org.apache.accumulo.core.metadata.schema.TabletMetadata.ColumnType.LAST;
import static org.apache.accumulo.core.metadata.schema.TabletMetadata.ColumnType.LOCATION;
@@ -483,13 +484,13 @@ public class Gatherer {
long t1, t2;
CompletableFuture<ProcessedFiles> futureRef = updateFuture();
t1 = System.nanoTime();
- ProcessedFiles processedFiles = futureRef.get(Long.max(1, nanosLeft), TimeUnit.NANOSECONDS);
+ ProcessedFiles processedFiles = futureRef.get(Long.max(1, nanosLeft), NANOSECONDS);
t2 = System.nanoTime();
nanosLeft -= (t2 - t1);
while (!processedFiles.failedFiles.isEmpty()) {
futureRef = updateFuture();
t1 = System.nanoTime();
- processedFiles = futureRef.get(Long.max(1, nanosLeft), TimeUnit.NANOSECONDS);
+ processedFiles = futureRef.get(Long.max(1, nanosLeft), NANOSECONDS);
t2 = System.nanoTime();
nanosLeft -= (t2 - t1);
}
diff --git a/core/src/main/java/org/apache/accumulo/core/util/Halt.java b/core/src/main/java/org/apache/accumulo/core/util/Halt.java
index e9c097e..bce13fe 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/Halt.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/Halt.java
@@ -18,10 +18,9 @@
*/
package org.apache.accumulo.core.util;
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static org.apache.accumulo.fate.util.UtilWaitThread.sleepUninterruptibly;
-import java.util.concurrent.TimeUnit;
-
import org.apache.accumulo.core.util.threads.Threads;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -53,7 +52,7 @@ public class Halt {
try {
// give ourselves a little time to try and do something
Threads.createThread("Halt Thread", () -> {
- sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
+ sleepUninterruptibly(100, MILLISECONDS);
Runtime.getRuntime().halt(status);
}).start();
diff --git a/core/src/main/java/org/apache/accumulo/core/util/OpTimer.java b/core/src/main/java/org/apache/accumulo/core/util/OpTimer.java
index 0339239..e0f61f9 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/OpTimer.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/OpTimer.java
@@ -18,6 +18,8 @@
*/
package org.apache.accumulo.core.util;
+import static java.util.concurrent.TimeUnit.NANOSECONDS;
+
import java.util.concurrent.TimeUnit;
/**
@@ -92,7 +94,7 @@ public class OpTimer {
* @return truncated time in unit of specified time unit.
*/
public long now(TimeUnit timeUnit) {
- return timeUnit.convert(now(), TimeUnit.NANOSECONDS);
+ return timeUnit.convert(now(), NANOSECONDS);
}
/**
@@ -108,7 +110,7 @@ public class OpTimer {
* @return the elapsed time of this instance scaled to the provided time unit.
*/
public double scale(TimeUnit timeUnit) {
- return (double) now() / TimeUnit.NANOSECONDS.convert(1L, timeUnit);
+ return (double) now() / NANOSECONDS.convert(1L, timeUnit);
}
/**
diff --git a/core/src/main/java/org/apache/accumulo/core/util/compaction/RunningCompactionInfo.java b/core/src/main/java/org/apache/accumulo/core/util/compaction/RunningCompactionInfo.java
index 87b1574..79752c2 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/compaction/RunningCompactionInfo.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/compaction/RunningCompactionInfo.java
@@ -19,9 +19,9 @@
package org.apache.accumulo.core.util.compaction;
import static java.util.Objects.requireNonNull;
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
import java.util.TreeMap;
-import java.util.concurrent.TimeUnit;
import org.apache.accumulo.core.compaction.thrift.TCompactionStatusUpdate;
import org.apache.accumulo.core.compaction.thrift.TExternalCompaction;
@@ -75,7 +75,7 @@ public class RunningCompactionInfo {
startedMillis = firstEntry.getKey();
}
duration = nowMillis - startedMillis;
- long durationMinutes = TimeUnit.MILLISECONDS.toMinutes(duration);
+ long durationMinutes = MILLISECONDS.toMinutes(duration);
if (durationMinutes > 15) {
log.warn("Compaction {} has been running for {} minutes", ecid, durationMinutes);
}
@@ -92,7 +92,7 @@ public class RunningCompactionInfo {
return;
}
- long sinceLastUpdateSeconds = TimeUnit.MILLISECONDS.toSeconds(nowMillis - updateMillis);
+ long sinceLastUpdateSeconds = MILLISECONDS.toSeconds(nowMillis - updateMillis);
log.debug("Time since Last update {} - {} = {} seconds", nowMillis, updateMillis,
sinceLastUpdateSeconds);
diff --git a/core/src/main/java/org/apache/accumulo/core/util/ratelimit/SharedRateLimiterFactory.java b/core/src/main/java/org/apache/accumulo/core/util/ratelimit/SharedRateLimiterFactory.java
index c5c6890..f31d26b 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/ratelimit/SharedRateLimiterFactory.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/ratelimit/SharedRateLimiterFactory.java
@@ -18,12 +18,14 @@
*/
package org.apache.accumulo.core.util.ratelimit;
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
+import static java.util.concurrent.TimeUnit.NANOSECONDS;
+
import java.lang.ref.WeakReference;
import java.util.HashMap;
import java.util.Map;
import java.util.WeakHashMap;
import java.util.concurrent.ScheduledThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
import java.util.function.Consumer;
@@ -55,11 +57,11 @@ public class SharedRateLimiterFactory {
ScheduledThreadPoolExecutor svc = ThreadPools.createGeneralScheduledExecutorService(conf);
svc.scheduleWithFixedDelay(Threads
.createNamedRunnable("SharedRateLimiterFactory update polling", instance::updateAll),
- UPDATE_RATE, UPDATE_RATE, TimeUnit.MILLISECONDS);
+ UPDATE_RATE, UPDATE_RATE, MILLISECONDS);
svc.scheduleWithFixedDelay(Threads
.createNamedRunnable("SharedRateLimiterFactory report polling", instance::reportAll),
- REPORT_RATE, REPORT_RATE, TimeUnit.MILLISECONDS);
+ REPORT_RATE, REPORT_RATE, MILLISECONDS);
}
return instance;
@@ -167,7 +169,7 @@ public class SharedRateLimiterFactory {
/** Report the current throughput and usage of this rate limiter to the debug log. */
public void report() {
if (log.isDebugEnabled()) {
- long duration = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - lastUpdate.get());
+ long duration = NANOSECONDS.toMillis(System.nanoTime() - lastUpdate.get());
if (duration == 0) {
return;
}
diff --git a/core/src/main/java/org/apache/accumulo/core/util/tables/TableZooHelper.java b/core/src/main/java/org/apache/accumulo/core/util/tables/TableZooHelper.java
index 90840bb..1a0e8a5 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/tables/TableZooHelper.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/tables/TableZooHelper.java
@@ -20,12 +20,12 @@ package org.apache.accumulo.core.util.tables;
import static com.google.common.base.Preconditions.checkArgument;
import static java.nio.charset.StandardCharsets.UTF_8;
+import static java.util.concurrent.TimeUnit.MINUTES;
import static org.apache.accumulo.core.util.Validators.EXISTING_TABLE_NAME;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
import org.apache.accumulo.core.Constants;
import org.apache.accumulo.core.client.NamespaceNotFoundException;
@@ -46,7 +46,7 @@ public class TableZooHelper implements AutoCloseable {
// Per instance cache will expire after 10 minutes in case we
// encounter an instance not used frequently
private final Cache<TableZooHelper,TableMap> instanceToMapCache =
- CacheBuilder.newBuilder().expireAfterAccess(10, TimeUnit.MINUTES).build();
+ CacheBuilder.newBuilder().expireAfterAccess(10, MINUTES).build();
public TableZooHelper(ClientContext context) {
this.context = Objects.requireNonNull(context);
diff --git a/core/src/main/java/org/apache/accumulo/core/util/threads/ThreadPools.java b/core/src/main/java/org/apache/accumulo/core/util/threads/ThreadPools.java
index 642ec7f..67d08ba 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/threads/ThreadPools.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/threads/ThreadPools.java
@@ -18,6 +18,9 @@
*/
package org.apache.accumulo.core.util.threads;
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
+import static java.util.concurrent.TimeUnit.SECONDS;
+
import java.util.OptionalInt;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.Callable;
@@ -117,7 +120,7 @@ public class ThreadPools {
emitThreadPoolMetrics);
case MANAGER_BULK_THREADPOOL_SIZE:
return createFixedThreadPool(conf.getCount(p),
- conf.getTimeInMillis(Property.MANAGER_BULK_THREADPOOL_TIMEOUT), TimeUnit.MILLISECONDS,
+ conf.getTimeInMillis(Property.MANAGER_BULK_THREADPOOL_TIMEOUT), MILLISECONDS,
"bulk import", emitThreadPoolMetrics);
case MANAGER_RENAME_THREADS:
return createFixedThreadPool(conf.getCount(p), "bulk move", emitThreadPoolMetrics);
@@ -126,8 +129,8 @@ public class ThreadPools {
case MANAGER_STATUS_THREAD_POOL_SIZE:
int threads = conf.getCount(p);
if (threads == 0) {
- return createThreadPool(0, Integer.MAX_VALUE, 60L, TimeUnit.SECONDS,
- "GatherTableInformation", new SynchronousQueue<>(), emitThreadPoolMetrics);
+ return createThreadPool(0, Integer.MAX_VALUE, 60L, SECONDS, "GatherTableInformation",
+ new SynchronousQueue<>(), emitThreadPoolMetrics);
} else {
return createFixedThreadPool(threads, "GatherTableInformation", emitThreadPoolMetrics);
}
@@ -135,22 +138,22 @@ public class ThreadPools {
return createFixedThreadPool(conf.getCount(p), "distributed work queue",
emitThreadPoolMetrics);
case TSERV_MINC_MAXCONCURRENT:
- return createFixedThreadPool(conf.getCount(p), 0L, TimeUnit.MILLISECONDS, "minor compactor",
+ return createFixedThreadPool(conf.getCount(p), 0L, MILLISECONDS, "minor compactor",
emitThreadPoolMetrics);
case TSERV_MIGRATE_MAXCONCURRENT:
- return createFixedThreadPool(conf.getCount(p), 0L, TimeUnit.MILLISECONDS,
- "tablet migration", emitThreadPoolMetrics);
+ return createFixedThreadPool(conf.getCount(p), 0L, MILLISECONDS, "tablet migration",
+ emitThreadPoolMetrics);
case TSERV_ASSIGNMENT_MAXCONCURRENT:
- return createFixedThreadPool(conf.getCount(p), 0L, TimeUnit.MILLISECONDS,
- "tablet assignment", emitThreadPoolMetrics);
+ return createFixedThreadPool(conf.getCount(p), 0L, MILLISECONDS, "tablet assignment",
+ emitThreadPoolMetrics);
case TSERV_SUMMARY_RETRIEVAL_THREADS:
- return createThreadPool(conf.getCount(p), conf.getCount(p), 60, TimeUnit.SECONDS,
+ return createThreadPool(conf.getCount(p), conf.getCount(p), 60, SECONDS,
"summary file retriever", emitThreadPoolMetrics);
case TSERV_SUMMARY_REMOTE_THREADS:
- return createThreadPool(conf.getCount(p), conf.getCount(p), 60, TimeUnit.SECONDS,
- "summary remote", emitThreadPoolMetrics);
+ return createThreadPool(conf.getCount(p), conf.getCount(p), 60, SECONDS, "summary remote",
+ emitThreadPoolMetrics);
case TSERV_SUMMARY_PARTITION_THREADS:
- return createThreadPool(conf.getCount(p), conf.getCount(p), 60, TimeUnit.SECONDS,
+ return createThreadPool(conf.getCount(p), conf.getCount(p), 60, SECONDS,
"summary partition", emitThreadPoolMetrics);
case GC_DELETE_THREADS:
return createFixedThreadPool(conf.getCount(p), "deleting", emitThreadPoolMetrics);
@@ -179,7 +182,7 @@ public class ThreadPools {
*/
public static ThreadPoolExecutor createFixedThreadPool(int numThreads, final String name,
boolean emitThreadPoolMetrics) {
- return createFixedThreadPool(numThreads, DEFAULT_TIMEOUT_MILLISECS, TimeUnit.MILLISECONDS, name,
+ return createFixedThreadPool(numThreads, DEFAULT_TIMEOUT_MILLISECS, MILLISECONDS, name,
emitThreadPoolMetrics);
}
@@ -203,8 +206,8 @@ public class ThreadPools {
*/
public static ThreadPoolExecutor createFixedThreadPool(int numThreads, final String name,
BlockingQueue<Runnable> queue, boolean emitThreadPoolMetrics) {
- return createThreadPool(numThreads, numThreads, DEFAULT_TIMEOUT_MILLISECS,
- TimeUnit.MILLISECONDS, name, queue, emitThreadPoolMetrics);
+ return createThreadPool(numThreads, numThreads, DEFAULT_TIMEOUT_MILLISECS, MILLISECONDS, name,
+ queue, emitThreadPoolMetrics);
}
/**
diff --git a/core/src/main/java/org/apache/accumulo/fate/Fate.java b/core/src/main/java/org/apache/accumulo/fate/Fate.java
index a2559ea..eeebb04 100644
--- a/core/src/main/java/org/apache/accumulo/fate/Fate.java
+++ b/core/src/main/java/org/apache/accumulo/fate/Fate.java
@@ -18,13 +18,15 @@
*/
package org.apache.accumulo.fate;
+import static java.util.concurrent.TimeUnit.MINUTES;
+import static java.util.concurrent.TimeUnit.SECONDS;
+
import java.io.IOException;
import java.util.EnumSet;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.ThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Function;
@@ -160,7 +162,7 @@ public class Fate<T> {
while (true) {
// Nothing is going to work well at this point, so why even try. Just wait for the end,
// preventing this FATE thread from processing further work and likely failing.
- UtilWaitThread.sleepUninterruptibly(1, TimeUnit.MINUTES);
+ UtilWaitThread.sleepUninterruptibly(1, MINUTES);
}
}
}
@@ -257,7 +259,7 @@ public class Fate<T> {
}
}
}
- }, 3, TimeUnit.SECONDS);
+ }, 3, SECONDS);
executor = pool;
}
diff --git a/core/src/main/java/org/apache/accumulo/fate/ZooStore.java b/core/src/main/java/org/apache/accumulo/fate/ZooStore.java
index 9bcc132..c1a3790 100644
--- a/core/src/main/java/org/apache/accumulo/fate/ZooStore.java
+++ b/core/src/main/java/org/apache/accumulo/fate/ZooStore.java
@@ -19,6 +19,7 @@
package org.apache.accumulo.fate;
import static java.nio.charset.StandardCharsets.UTF_8;
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static org.apache.accumulo.fate.util.UtilWaitThread.sleepUninterruptibly;
import java.io.ByteArrayInputStream;
@@ -36,7 +37,6 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.concurrent.TimeUnit;
import org.apache.accumulo.fate.zookeeper.ZooReaderWriter;
import org.apache.accumulo.fate.zookeeper.ZooUtil.NodeExistsPolicy;
@@ -297,7 +297,7 @@ public class ZooStore<T> implements TStore<T> {
return (Repo<T>) deserialize(ser);
} catch (KeeperException.NoNodeException ex) {
log.debug("zookeeper error reading " + txpath + ": " + ex, ex);
- sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
+ sleepUninterruptibly(100, MILLISECONDS);
continue;
} catch (Exception e) {
throw new RuntimeException(e);
diff --git a/core/src/main/java/org/apache/accumulo/fate/zookeeper/DistributedReadWriteLock.java b/core/src/main/java/org/apache/accumulo/fate/zookeeper/DistributedReadWriteLock.java
index 5e424cb..41f308a 100644
--- a/core/src/main/java/org/apache/accumulo/fate/zookeeper/DistributedReadWriteLock.java
+++ b/core/src/main/java/org/apache/accumulo/fate/zookeeper/DistributedReadWriteLock.java
@@ -19,6 +19,8 @@
package org.apache.accumulo.fate.zookeeper;
import static java.nio.charset.StandardCharsets.UTF_8;
+import static java.util.concurrent.TimeUnit.DAYS;
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
import java.util.Arrays;
import java.util.Iterator;
@@ -129,7 +131,7 @@ public class DistributedReadWriteLock implements java.util.concurrent.locks.Read
public void lock() {
while (true) {
try {
- if (tryLock(1, TimeUnit.DAYS))
+ if (tryLock(1, DAYS))
return;
} catch (InterruptedException ex) {
// ignored
@@ -140,7 +142,7 @@ public class DistributedReadWriteLock implements java.util.concurrent.locks.Read
@Override
public void lockInterruptibly() throws InterruptedException {
while (!Thread.currentThread().isInterrupted()) {
- if (tryLock(100, TimeUnit.MILLISECONDS))
+ if (tryLock(100, MILLISECONDS))
return;
}
}
@@ -167,7 +169,7 @@ public class DistributedReadWriteLock implements java.util.concurrent.locks.Read
@Override
public boolean tryLock(long time, TimeUnit unit) throws InterruptedException {
long now = System.currentTimeMillis();
- long returnTime = now + TimeUnit.MILLISECONDS.convert(time, unit);
+ long returnTime = now + MILLISECONDS.convert(time, unit);
while (returnTime > now) {
if (tryLock())
return true;
diff --git a/core/src/main/java/org/apache/accumulo/fate/zookeeper/ZooReader.java b/core/src/main/java/org/apache/accumulo/fate/zookeeper/ZooReader.java
index f4d6b3c..fb8ad96 100644
--- a/core/src/main/java/org/apache/accumulo/fate/zookeeper/ZooReader.java
+++ b/core/src/main/java/org/apache/accumulo/fate/zookeeper/ZooReader.java
@@ -20,10 +20,11 @@ package org.apache.accumulo.fate.zookeeper;
import static java.util.Objects.requireNonNull;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
+import static java.util.concurrent.TimeUnit.MINUTES;
+import static java.util.concurrent.TimeUnit.SECONDS;
import java.util.List;
import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Predicate;
@@ -41,9 +42,9 @@ import org.slf4j.LoggerFactory;
public class ZooReader {
private static final Logger log = LoggerFactory.getLogger(ZooReader.class);
- protected static final RetryFactory RETRY_FACTORY = Retry.builder().maxRetries(10)
- .retryAfter(250, MILLISECONDS).incrementBy(250, MILLISECONDS).maxWait(5, TimeUnit.SECONDS)
- .backOffFactor(1.5).logInterval(3, TimeUnit.MINUTES).createFactory();
+ protected static final RetryFactory RETRY_FACTORY =
+ Retry.builder().maxRetries(10).retryAfter(250, MILLISECONDS).incrementBy(250, MILLISECONDS)
+ .maxWait(5, SECONDS).backOffFactor(1.5).logInterval(3, MINUTES).createFactory();
protected final String keepers;
protected final int timeout;
diff --git a/core/src/test/java/org/apache/accumulo/core/client/BatchWriterConfigTest.java b/core/src/test/java/org/apache/accumulo/core/client/BatchWriterConfigTest.java
index 40309ed..df6dd18 100644
--- a/core/src/test/java/org/apache/accumulo/core/client/BatchWriterConfigTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/client/BatchWriterConfigTest.java
@@ -19,6 +19,12 @@
package org.apache.accumulo.core.client;
import static java.nio.charset.StandardCharsets.UTF_8;
+import static java.util.concurrent.TimeUnit.DAYS;
+import static java.util.concurrent.TimeUnit.HOURS;
+import static java.util.concurrent.TimeUnit.MICROSECONDS;
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
+import static java.util.concurrent.TimeUnit.NANOSECONDS;
+import static java.util.concurrent.TimeUnit.SECONDS;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -29,7 +35,6 @@ import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.Arrays;
-import java.util.concurrent.TimeUnit;
import org.apache.accumulo.core.conf.ClientProperty;
import org.junit.jupiter.api.Test;
@@ -46,8 +51,8 @@ public class BatchWriterConfigTest {
BatchWriterConfig defaults = new BatchWriterConfig();
assertEquals(expectedMaxMemory, defaults.getMaxMemory());
- assertEquals(expectedMaxLatency, defaults.getMaxLatency(TimeUnit.MILLISECONDS));
- assertEquals(expectedTimeout, defaults.getTimeout(TimeUnit.MILLISECONDS));
+ assertEquals(expectedMaxLatency, defaults.getMaxLatency(MILLISECONDS));
+ assertEquals(expectedTimeout, defaults.getTimeout(MILLISECONDS));
assertEquals(expectedMaxWriteThreads, defaults.getMaxWriteThreads());
assertEquals(expectedDurability, defaults.getDurability());
}
@@ -56,14 +61,14 @@ public class BatchWriterConfigTest {
public void testOverridingDefaults() {
BatchWriterConfig bwConfig = new BatchWriterConfig();
bwConfig.setMaxMemory(1123581321L);
- bwConfig.setMaxLatency(22, TimeUnit.HOURS);
- bwConfig.setTimeout(33, TimeUnit.DAYS);
+ bwConfig.setMaxLatency(22, HOURS);
+ bwConfig.setTimeout(33, DAYS);
bwConfig.setMaxWriteThreads(42);
bwConfig.setDurability(Durability.NONE);
assertEquals(1123581321L, bwConfig.getMaxMemory());
- assertEquals(22 * 60 * 60_000L, bwConfig.getMaxLatency(TimeUnit.MILLISECONDS));
- assertEquals(33 * 24 * 60 * 60_000L, bwConfig.getTimeout(TimeUnit.MILLISECONDS));
+ assertEquals(HOURS.toMillis(22), bwConfig.getMaxLatency(MILLISECONDS));
+ assertEquals(DAYS.toMillis(33), bwConfig.getTimeout(MILLISECONDS));
assertEquals(42, bwConfig.getMaxWriteThreads());
assertEquals(Durability.NONE, bwConfig.getDurability());
}
@@ -71,12 +76,12 @@ public class BatchWriterConfigTest {
@Test
public void testZeroValues() {
BatchWriterConfig bwConfig = new BatchWriterConfig();
- bwConfig.setMaxLatency(0, TimeUnit.MILLISECONDS);
- bwConfig.setTimeout(0, TimeUnit.MILLISECONDS);
+ bwConfig.setMaxLatency(0, MILLISECONDS);
+ bwConfig.setTimeout(0, MILLISECONDS);
bwConfig.setMaxMemory(0);
- assertEquals(Long.MAX_VALUE, bwConfig.getMaxLatency(TimeUnit.MILLISECONDS));
- assertEquals(Long.MAX_VALUE, bwConfig.getTimeout(TimeUnit.MILLISECONDS));
+ assertEquals(Long.MAX_VALUE, bwConfig.getMaxLatency(MILLISECONDS));
+ assertEquals(Long.MAX_VALUE, bwConfig.getTimeout(MILLISECONDS));
assertEquals(0, bwConfig.getMaxMemory());
}
@@ -89,34 +94,34 @@ public class BatchWriterConfigTest {
@Test
public void testNegativeMaxLatency() {
BatchWriterConfig bwConfig = new BatchWriterConfig();
- assertThrows(IllegalArgumentException.class, () -> bwConfig.setMaxLatency(-1, TimeUnit.DAYS));
+ assertThrows(IllegalArgumentException.class, () -> bwConfig.setMaxLatency(-1, DAYS));
}
@Test
public void testTinyTimeConversions() {
BatchWriterConfig bwConfig = new BatchWriterConfig();
- bwConfig.setMaxLatency(999, TimeUnit.MICROSECONDS);
- bwConfig.setTimeout(999, TimeUnit.MICROSECONDS);
+ bwConfig.setMaxLatency(999, MICROSECONDS);
+ bwConfig.setTimeout(999, MICROSECONDS);
- assertEquals(1000, bwConfig.getMaxLatency(TimeUnit.MICROSECONDS));
- assertEquals(1000, bwConfig.getTimeout(TimeUnit.MICROSECONDS));
- assertEquals(1, bwConfig.getMaxLatency(TimeUnit.MILLISECONDS));
- assertEquals(1, bwConfig.getTimeout(TimeUnit.MILLISECONDS));
+ assertEquals(1000, bwConfig.getMaxLatency(MICROSECONDS));
+ assertEquals(1000, bwConfig.getTimeout(MICROSECONDS));
+ assertEquals(1, bwConfig.getMaxLatency(MILLISECONDS));
+ assertEquals(1, bwConfig.getTimeout(MILLISECONDS));
- bwConfig.setMaxLatency(10, TimeUnit.NANOSECONDS);
- bwConfig.setTimeout(10, TimeUnit.NANOSECONDS);
+ bwConfig.setMaxLatency(10, NANOSECONDS);
+ bwConfig.setTimeout(10, NANOSECONDS);
- assertEquals(1000000, bwConfig.getMaxLatency(TimeUnit.NANOSECONDS));
- assertEquals(1000000, bwConfig.getTimeout(TimeUnit.NANOSECONDS));
- assertEquals(1, bwConfig.getMaxLatency(TimeUnit.MILLISECONDS));
- assertEquals(1, bwConfig.getTimeout(TimeUnit.MILLISECONDS));
+ assertEquals(1000000, bwConfig.getMaxLatency(NANOSECONDS));
+ assertEquals(1000000, bwConfig.getTimeout(NANOSECONDS));
+ assertEquals(1, bwConfig.getMaxLatency(MILLISECONDS));
+ assertEquals(1, bwConfig.getTimeout(MILLISECONDS));
}
@Test
public void testNegativeTimeout() {
BatchWriterConfig bwConfig = new BatchWriterConfig();
- assertThrows(IllegalArgumentException.class, () -> bwConfig.setTimeout(-1, TimeUnit.DAYS));
+ assertThrows(IllegalArgumentException.class, () -> bwConfig.setTimeout(-1, DAYS));
}
@Test
@@ -135,16 +140,16 @@ public class BatchWriterConfigTest {
public void testSerialize() throws IOException {
// make sure we aren't testing defaults
final BatchWriterConfig bwDefaults = new BatchWriterConfig();
- assertNotEquals(7654321L, bwDefaults.getMaxLatency(TimeUnit.MILLISECONDS));
- assertNotEquals(9898989L, bwDefaults.getTimeout(TimeUnit.MILLISECONDS));
+ assertNotEquals(7654321L, bwDefaults.getMaxLatency(MILLISECONDS));
+ assertNotEquals(9898989L, bwDefaults.getTimeout(MILLISECONDS));
assertNotEquals(42, bwDefaults.getMaxWriteThreads());
assertNotEquals(1123581321L, bwDefaults.getMaxMemory());
assertNotEquals(Durability.FLUSH, bwDefaults.getDurability());
// test setting all fields
BatchWriterConfig bwConfig = new BatchWriterConfig();
- bwConfig.setMaxLatency(7654321L, TimeUnit.MILLISECONDS);
- bwConfig.setTimeout(9898989L, TimeUnit.MILLISECONDS);
+ bwConfig.setMaxLatency(7654321L, MILLISECONDS);
+ bwConfig.setTimeout(9898989L, MILLISECONDS);
bwConfig.setMaxWriteThreads(42);
bwConfig.setMaxMemory(1123581321L);
bwConfig.setDurability(Durability.FLUSH);
@@ -161,7 +166,7 @@ public class BatchWriterConfigTest {
// test human-readable with 2 fields
bwConfig = new BatchWriterConfig();
bwConfig.setMaxWriteThreads(24);
- bwConfig.setTimeout(3, TimeUnit.SECONDS);
+ bwConfig.setTimeout(3, SECONDS);
bytes = createBytes(bwConfig);
assertEquals(" v#maxWriteThreads=24,timeout=3000", new String(bytes, UTF_8));
checkBytes(bwConfig, bytes);
@@ -189,14 +194,14 @@ public class BatchWriterConfigTest {
@Test
public void testManualEquality() {
BatchWriterConfig cfg1 = new BatchWriterConfig(), cfg2 = new BatchWriterConfig();
- cfg1.setMaxLatency(10, TimeUnit.SECONDS);
- cfg2.setMaxLatency(10000, TimeUnit.MILLISECONDS);
+ cfg1.setMaxLatency(10, SECONDS);
+ cfg2.setMaxLatency(10000, MILLISECONDS);
cfg1.setMaxMemory(100);
cfg2.setMaxMemory(100);
- cfg1.setTimeout(10, TimeUnit.SECONDS);
- cfg2.setTimeout(10000, TimeUnit.MILLISECONDS);
+ cfg1.setTimeout(10, SECONDS);
+ cfg2.setTimeout(10000, MILLISECONDS);
assertEquals(cfg1, cfg2);
@@ -209,7 +214,7 @@ public class BatchWriterConfigTest {
cfg1.setMaxMemory(1234);
cfg2.setMaxMemory(5858);
cfg2.setDurability(Durability.LOG);
- cfg2.setMaxLatency(456, TimeUnit.MILLISECONDS);
+ cfg2.setMaxLatency(456, MILLISECONDS);
assertEquals(Durability.DEFAULT, cfg1.getDurability());
@@ -217,7 +222,7 @@ public class BatchWriterConfigTest {
assertEquals(1234, merged.getMaxMemory());
assertEquals(Durability.LOG, merged.getDurability());
- assertEquals(456, merged.getMaxLatency(TimeUnit.MILLISECONDS));
+ assertEquals(456, merged.getMaxLatency(MILLISECONDS));
assertEquals(3, merged.getMaxWriteThreads());
}
@@ -233,10 +238,8 @@ public class BatchWriterConfigTest {
createdConfig.readFields(new DataInputStream(bais));
assertEquals(bwConfig.getMaxMemory(), createdConfig.getMaxMemory());
- assertEquals(bwConfig.getMaxLatency(TimeUnit.MILLISECONDS),
- createdConfig.getMaxLatency(TimeUnit.MILLISECONDS));
- assertEquals(bwConfig.getTimeout(TimeUnit.MILLISECONDS),
- createdConfig.getTimeout(TimeUnit.MILLISECONDS));
+ assertEquals(bwConfig.getMaxLatency(MILLISECONDS), createdConfig.getMaxLatency(MILLISECONDS));
+ assertEquals(bwConfig.getTimeout(MILLISECONDS), createdConfig.getTimeout(MILLISECONDS));
assertEquals(bwConfig.getMaxWriteThreads(), createdConfig.getMaxWriteThreads());
}
diff --git a/core/src/test/java/org/apache/accumulo/core/client/TestThrift1474.java b/core/src/test/java/org/apache/accumulo/core/client/TestThrift1474.java
index 2051c68..f8a18a6 100644
--- a/core/src/test/java/org/apache/accumulo/core/client/TestThrift1474.java
+++ b/core/src/test/java/org/apache/accumulo/core/client/TestThrift1474.java
@@ -18,13 +18,13 @@
*/
package org.apache.accumulo.core.client;
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static org.apache.accumulo.fate.util.UtilWaitThread.sleepUninterruptibly;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
-import java.util.concurrent.TimeUnit;
import org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException;
import org.apache.accumulo.core.clientImpl.thrift.ThriftTest;
@@ -69,12 +69,12 @@ public class TestThrift1474 {
TThreadPoolServer.Args args = new TThreadPoolServer.Args(serverTransport);
args.stopTimeoutVal = 10;
- args.stopTimeoutUnit = TimeUnit.MILLISECONDS;
+ args.stopTimeoutUnit = MILLISECONDS;
final TServer server = new TThreadPoolServer(args.processor(processor));
Thread thread = new Thread(server::serve);
thread.start();
while (!server.isServing()) {
- sleepUninterruptibly(10, TimeUnit.MILLISECONDS);
+ sleepUninterruptibly(10, MILLISECONDS);
}
TTransport transport = new TSocket("localhost", port);
diff --git a/core/src/test/java/org/apache/accumulo/core/client/admin/DelegationTokenConfigTest.java b/core/src/test/java/org/apache/accumulo/core/client/admin/DelegationTokenConfigTest.java
index cef5343..bc8623a 100644
--- a/core/src/test/java/org/apache/accumulo/core/client/admin/DelegationTokenConfigTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/client/admin/DelegationTokenConfigTest.java
@@ -18,11 +18,12 @@
*/
package org.apache.accumulo.core.client.admin;
+import static java.util.concurrent.TimeUnit.DAYS;
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
+import static java.util.concurrent.TimeUnit.SECONDS;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
-import java.util.concurrent.TimeUnit;
-
import org.junit.jupiter.api.Test;
public class DelegationTokenConfigTest {
@@ -32,11 +33,10 @@ public class DelegationTokenConfigTest {
DelegationTokenConfig config1 = new DelegationTokenConfig(),
config2 = new DelegationTokenConfig();
- config1.setTokenLifetime(1000, TimeUnit.MILLISECONDS);
- config2.setTokenLifetime(1, TimeUnit.SECONDS);
+ config1.setTokenLifetime(1000, MILLISECONDS);
+ config2.setTokenLifetime(1, SECONDS);
- assertEquals(config1.getTokenLifetime(TimeUnit.MILLISECONDS),
- config2.getTokenLifetime(TimeUnit.MILLISECONDS));
+ assertEquals(config1.getTokenLifetime(MILLISECONDS), config2.getTokenLifetime(MILLISECONDS));
assertEquals(config1, config2);
assertEquals(config1.hashCode(), config2.hashCode());
}
@@ -45,16 +45,16 @@ public class DelegationTokenConfigTest {
public void testNoTimeout() {
DelegationTokenConfig config = new DelegationTokenConfig();
- config.setTokenLifetime(0, TimeUnit.MILLISECONDS);
+ config.setTokenLifetime(0, MILLISECONDS);
- assertEquals(0, config.getTokenLifetime(TimeUnit.MILLISECONDS));
+ assertEquals(0, config.getTokenLifetime(MILLISECONDS));
}
@Test
public void testInvalidLifetime() {
assertThrows(IllegalArgumentException.class,
- () -> new DelegationTokenConfig().setTokenLifetime(-1, TimeUnit.DAYS));
+ () -> new DelegationTokenConfig().setTokenLifetime(-1, DAYS));
}
@Test
diff --git a/core/src/test/java/org/apache/accumulo/core/client/mapred/AccumuloOutputFormatTest.java b/core/src/test/java/org/apache/accumulo/core/client/mapred/AccumuloOutputFormatTest.java
index eaad58c..97314a2 100644
--- a/core/src/test/java/org/apache/accumulo/core/client/mapred/AccumuloOutputFormatTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/client/mapred/AccumuloOutputFormatTest.java
@@ -18,11 +18,11 @@
*/
package org.apache.accumulo.core.client.mapred;
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import java.io.IOException;
-import java.util.concurrent.TimeUnit;
import org.apache.accumulo.core.client.BatchWriterConfig;
import org.apache.hadoop.fs.FileSystem;
@@ -38,14 +38,14 @@ public class AccumuloOutputFormatTest {
// make sure we aren't testing defaults
final BatchWriterConfig bwDefaults = new BatchWriterConfig();
- assertNotEquals(7654321L, bwDefaults.getMaxLatency(TimeUnit.MILLISECONDS));
- assertNotEquals(9898989L, bwDefaults.getTimeout(TimeUnit.MILLISECONDS));
+ assertNotEquals(7654321L, bwDefaults.getMaxLatency(MILLISECONDS));
+ assertNotEquals(9898989L, bwDefaults.getTimeout(MILLISECONDS));
assertNotEquals(42, bwDefaults.getMaxWriteThreads());
assertNotEquals(1123581321L, bwDefaults.getMaxMemory());
final BatchWriterConfig bwConfig = new BatchWriterConfig();
- bwConfig.setMaxLatency(7654321L, TimeUnit.MILLISECONDS);
- bwConfig.setTimeout(9898989L, TimeUnit.MILLISECONDS);
+ bwConfig.setMaxLatency(7654321L, MILLISECONDS);
+ bwConfig.setTimeout(9898989L, MILLISECONDS);
bwConfig.setMaxWriteThreads(42);
bwConfig.setMaxMemory(1123581321L);
AccumuloOutputFormat.setBatchWriterOptions(job, bwConfig);
@@ -56,16 +56,14 @@ public class AccumuloOutputFormatTest {
BatchWriterConfig bwOpts = getBatchWriterOptions(job);
// passive check
- assertEquals(bwConfig.getMaxLatency(TimeUnit.MILLISECONDS),
- bwOpts.getMaxLatency(TimeUnit.MILLISECONDS));
- assertEquals(bwConfig.getTimeout(TimeUnit.MILLISECONDS),
- bwOpts.getTimeout(TimeUnit.MILLISECONDS));
+ assertEquals(bwConfig.getMaxLatency(MILLISECONDS), bwOpts.getMaxLatency(MILLISECONDS));
+ assertEquals(bwConfig.getTimeout(MILLISECONDS), bwOpts.getTimeout(MILLISECONDS));
assertEquals(bwConfig.getMaxWriteThreads(), bwOpts.getMaxWriteThreads());
assertEquals(bwConfig.getMaxMemory(), bwOpts.getMaxMemory());
// explicit check
- assertEquals(7654321L, bwOpts.getMaxLatency(TimeUnit.MILLISECONDS));
- assertEquals(9898989L, bwOpts.getTimeout(TimeUnit.MILLISECONDS));
+ assertEquals(7654321L, bwOpts.getMaxLatency(MILLISECONDS));
+ assertEquals(9898989L, bwOpts.getTimeout(MILLISECONDS));
assertEquals(42, bwOpts.getMaxWriteThreads());
assertEquals(1123581321L, bwOpts.getMaxMemory());
diff --git a/core/src/test/java/org/apache/accumulo/core/client/mapreduce/AccumuloOutputFormatTest.java b/core/src/test/java/org/apache/accumulo/core/client/mapreduce/AccumuloOutputFormatTest.java
index fa06829..f723541 100644
--- a/core/src/test/java/org/apache/accumulo/core/client/mapreduce/AccumuloOutputFormatTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/client/mapreduce/AccumuloOutputFormatTest.java
@@ -18,11 +18,11 @@
*/
package org.apache.accumulo.core.client.mapreduce;
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import java.io.IOException;
-import java.util.concurrent.TimeUnit;
import org.apache.accumulo.core.client.BatchWriterConfig;
import org.apache.hadoop.mapreduce.Job;
@@ -38,14 +38,14 @@ public class AccumuloOutputFormatTest {
// make sure we aren't testing defaults
final BatchWriterConfig bwDefaults = new BatchWriterConfig();
- assertNotEquals(7654321L, bwDefaults.getMaxLatency(TimeUnit.MILLISECONDS));
- assertNotEquals(9898989L, bwDefaults.getTimeout(TimeUnit.MILLISECONDS));
+ assertNotEquals(7654321L, bwDefaults.getMaxLatency(MILLISECONDS));
+ assertNotEquals(9898989L, bwDefaults.getTimeout(MILLISECONDS));
assertNotEquals(42, bwDefaults.getMaxWriteThreads());
assertNotEquals(1123581321L, bwDefaults.getMaxMemory());
final BatchWriterConfig bwConfig = new BatchWriterConfig();
- bwConfig.setMaxLatency(7654321L, TimeUnit.MILLISECONDS);
- bwConfig.setTimeout(9898989L, TimeUnit.MILLISECONDS);
+ bwConfig.setMaxLatency(7654321L, MILLISECONDS);
+ bwConfig.setTimeout(9898989L, MILLISECONDS);
bwConfig.setMaxWriteThreads(42);
bwConfig.setMaxMemory(1123581321L);
AccumuloOutputFormat.setBatchWriterOptions(job, bwConfig);
@@ -56,16 +56,14 @@ public class AccumuloOutputFormatTest {
BatchWriterConfig bwOpts = getBatchWriterOptions(job);
// passive check
- assertEquals(bwConfig.getMaxLatency(TimeUnit.MILLISECONDS),
- bwOpts.getMaxLatency(TimeUnit.MILLISECONDS));
- assertEquals(bwConfig.getTimeout(TimeUnit.MILLISECONDS),
- bwOpts.getTimeout(TimeUnit.MILLISECONDS));
+ assertEquals(bwConfig.getMaxLatency(MILLISECONDS), bwOpts.getMaxLatency(MILLISECONDS));
+ assertEquals(bwConfig.getTimeout(MILLISECONDS), bwOpts.getTimeout(MILLISECONDS));
assertEquals(bwConfig.getMaxWriteThreads(), bwOpts.getMaxWriteThreads());
assertEquals(bwConfig.getMaxMemory(), bwOpts.getMaxMemory());
// explicit check
- assertEquals(7654321L, bwOpts.getMaxLatency(TimeUnit.MILLISECONDS));
- assertEquals(9898989L, bwOpts.getTimeout(TimeUnit.MILLISECONDS));
+ assertEquals(7654321L, bwOpts.getMaxLatency(MILLISECONDS));
+ assertEquals(9898989L, bwOpts.getTimeout(MILLISECONDS));
assertEquals(42, bwOpts.getMaxWriteThreads());
assertEquals(1123581321L, bwOpts.getMaxMemory());
diff --git a/core/src/test/java/org/apache/accumulo/core/clientImpl/ClientContextTest.java b/core/src/test/java/org/apache/accumulo/core/clientImpl/ClientContextTest.java
index 7ba0135..afc10f4 100644
--- a/core/src/test/java/org/apache/accumulo/core/clientImpl/ClientContextTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/clientImpl/ClientContextTest.java
@@ -18,6 +18,8 @@
*/
package org.apache.accumulo.core.clientImpl;
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
+import static java.util.concurrent.TimeUnit.SECONDS;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
@@ -27,7 +29,6 @@ import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
-import java.util.concurrent.TimeUnit;
import org.apache.accumulo.core.client.BatchWriterConfig;
import org.apache.accumulo.core.client.ConditionalWriterConfig;
@@ -117,18 +118,18 @@ public class ClientContextTest {
.getTimeInMillis(ClientProperty.BATCH_WRITER_LATENCY_MAX.getDefaultValue());
if (expectedLatency == 0) {
expectedLatency = Long.MAX_VALUE;
- assertEquals(expectedLatency, batchWriterConfig.getMaxLatency(TimeUnit.MILLISECONDS));
+ assertEquals(expectedLatency, batchWriterConfig.getMaxLatency(MILLISECONDS));
} else {
- assertEquals(expectedLatency, batchWriterConfig.getMaxLatency(TimeUnit.SECONDS));
+ assertEquals(expectedLatency, batchWriterConfig.getMaxLatency(SECONDS));
}
long expectedTimeout = ConfigurationTypeHelper
.getTimeInMillis(ClientProperty.BATCH_WRITER_TIMEOUT_MAX.getDefaultValue());
if (expectedTimeout == 0) {
expectedTimeout = Long.MAX_VALUE;
- assertEquals(expectedTimeout, batchWriterConfig.getTimeout(TimeUnit.MILLISECONDS));
+ assertEquals(expectedTimeout, batchWriterConfig.getTimeout(MILLISECONDS));
} else {
- assertEquals(expectedTimeout, batchWriterConfig.getTimeout(TimeUnit.SECONDS));
+ assertEquals(expectedTimeout, batchWriterConfig.getTimeout(SECONDS));
}
int expectedThreads =
@@ -158,10 +159,10 @@ public class ClientContextTest {
.getMemoryAsBytes(ClientProperty.BATCH_WRITER_MEMORY_MAX.getValue(props));
assertEquals(expectedMemory, batchWriterConfig.getMaxMemory());
- assertEquals(Long.MAX_VALUE, batchWriterConfig.getMaxLatency(TimeUnit.MILLISECONDS));
+ assertEquals(Long.MAX_VALUE, batchWriterConfig.getMaxLatency(MILLISECONDS));
// getTimeout returns time in milliseconds, therefore the 15 becomes 15000.
- assertEquals(15000, batchWriterConfig.getTimeout(TimeUnit.SECONDS));
+ assertEquals(15000, batchWriterConfig.getTimeout(SECONDS));
long expectedThreads = ClientProperty.BATCH_WRITER_THREADS_MAX.getInteger(props);
assertEquals(expectedThreads, batchWriterConfig.getMaxWriteThreads());
@@ -186,9 +187,9 @@ public class ClientContextTest {
long expectedTimeout = ConfigurationTypeHelper
.getTimeInMillis(ClientProperty.CONDITIONAL_WRITER_TIMEOUT_MAX.getDefaultValue());
if (expectedTimeout == 0) {
- assertEquals(Long.MAX_VALUE, conditionalWriterConfig.getTimeout(TimeUnit.MILLISECONDS));
+ assertEquals(Long.MAX_VALUE, conditionalWriterConfig.getTimeout(MILLISECONDS));
} else {
- assertEquals(expectedTimeout, conditionalWriterConfig.getTimeout(TimeUnit.SECONDS));
+ assertEquals(expectedTimeout, conditionalWriterConfig.getTimeout(SECONDS));
}
int expectedThreads =
@@ -215,7 +216,7 @@ public class ClientContextTest {
assertNotNull(conditionalWriterConfig);
// getTimeout returns time in milliseconds, therefore the 17 becomes 17000.
- assertEquals(17000, conditionalWriterConfig.getTimeout(TimeUnit.SECONDS));
+ assertEquals(17000, conditionalWriterConfig.getTimeout(SECONDS));
long expectedThreads = ClientProperty.CONDITIONAL_WRITER_THREADS_MAX.getInteger(props);
assertEquals(expectedThreads, conditionalWriterConfig.getMaxWriteThreads());
diff --git a/core/src/test/java/org/apache/accumulo/core/clientImpl/DelegationTokenConfigSerializerTest.java b/core/src/test/java/org/apache/accumulo/core/clientImpl/DelegationTokenConfigSerializerTest.java
index 5f38cbd..8b7455f 100644
--- a/core/src/test/java/org/apache/accumulo/core/clientImpl/DelegationTokenConfigSerializerTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/clientImpl/DelegationTokenConfigSerializerTest.java
@@ -18,10 +18,10 @@
*/
package org.apache.accumulo.core.clientImpl;
+import static java.util.concurrent.TimeUnit.HOURS;
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static org.junit.jupiter.api.Assertions.assertEquals;
-import java.util.concurrent.TimeUnit;
-
import org.apache.accumulo.core.client.admin.DelegationTokenConfig;
import org.apache.accumulo.core.securityImpl.thrift.TDelegationTokenConfig;
import org.junit.jupiter.api.Test;
@@ -31,10 +31,10 @@ public class DelegationTokenConfigSerializerTest {
@Test
public void test() {
DelegationTokenConfig cfg = new DelegationTokenConfig();
- cfg.setTokenLifetime(8323, TimeUnit.HOURS);
+ cfg.setTokenLifetime(8323, HOURS);
TDelegationTokenConfig tCfg = DelegationTokenConfigSerializer.serialize(cfg);
- assertEquals(tCfg.getLifetime(), cfg.getTokenLifetime(TimeUnit.MILLISECONDS));
+ assertEquals(tCfg.getLifetime(), cfg.getTokenLifetime(MILLISECONDS));
assertEquals(cfg, DelegationTokenConfigSerializer.deserialize(tCfg));
}
diff --git a/core/src/test/java/org/apache/accumulo/core/clientImpl/bulk/ConcurrentKeyExtentCacheTest.java b/core/src/test/java/org/apache/accumulo/core/clientImpl/bulk/ConcurrentKeyExtentCacheTest.java
index f92342c..96811ba 100644
--- a/core/src/test/java/org/apache/accumulo/core/clientImpl/bulk/ConcurrentKeyExtentCacheTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/clientImpl/bulk/ConcurrentKeyExtentCacheTest.java
@@ -18,6 +18,7 @@
*/
package org.apache.accumulo.core.clientImpl.bulk;
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -27,7 +28,6 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.concurrent.ConcurrentSkipListSet;
-import java.util.concurrent.TimeUnit;
import java.util.stream.Stream;
import org.apache.accumulo.core.data.TableId;
@@ -83,7 +83,7 @@ public class ConcurrentKeyExtentCacheTest {
}
}
- Uninterruptibles.sleepUninterruptibly(3, TimeUnit.MILLISECONDS);
+ Uninterruptibles.sleepUninterruptibly(3, MILLISECONDS);
return extents.subList(index, extents.size()).stream().limit(73);
}
diff --git a/core/src/test/java/org/apache/accumulo/core/conf/ConfigurationTypeHelperTest.java b/core/src/test/java/org/apache/accumulo/core/conf/ConfigurationTypeHelperTest.java
index 01fdc73..bbfb5aa 100644
--- a/core/src/test/java/org/apache/accumulo/core/conf/ConfigurationTypeHelperTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/conf/ConfigurationTypeHelperTest.java
@@ -18,6 +18,10 @@
*/
package org.apache.accumulo.core.conf;
+import static java.util.concurrent.TimeUnit.DAYS;
+import static java.util.concurrent.TimeUnit.HOURS;
+import static java.util.concurrent.TimeUnit.MINUTES;
+import static java.util.concurrent.TimeUnit.SECONDS;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -80,11 +84,11 @@ public class ConfigurationTypeHelperTest {
@Test
public void testGetTimeInMillis() {
- assertEquals(42L * 24 * 60 * 60 * 1000, ConfigurationTypeHelper.getTimeInMillis("42d"));
- assertEquals(42L * 60 * 60 * 1000, ConfigurationTypeHelper.getTimeInMillis("42h"));
- assertEquals(42L * 60 * 1000, ConfigurationTypeHelper.getTimeInMillis("42m"));
- assertEquals(42L * 1000, ConfigurationTypeHelper.getTimeInMillis("42s"));
- assertEquals(42L * 1000, ConfigurationTypeHelper.getTimeInMillis("42"));
+ assertEquals(DAYS.toMillis(42), ConfigurationTypeHelper.getTimeInMillis("42d"));
+ assertEquals(HOURS.toMillis(42), ConfigurationTypeHelper.getTimeInMillis("42h"));
+ assertEquals(MINUTES.toMillis(42), ConfigurationTypeHelper.getTimeInMillis("42m"));
+ assertEquals(SECONDS.toMillis(42), ConfigurationTypeHelper.getTimeInMillis("42s"));
+ assertEquals(SECONDS.toMillis(42), ConfigurationTypeHelper.getTimeInMillis("42"));
assertEquals(42L, ConfigurationTypeHelper.getTimeInMillis("42ms"));
}
diff --git a/core/src/test/java/org/apache/accumulo/core/file/rfile/MultiThreadedRFileTest.java b/core/src/test/java/org/apache/accumulo/core/file/rfile/MultiThreadedRFileTest.java
index 6229c07..0358c66 100644
--- a/core/src/test/java/org/apache/accumulo/core/file/rfile/MultiThreadedRFileTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/file/rfile/MultiThreadedRFileTest.java
@@ -18,6 +18,8 @@
*/
package org.apache.accumulo.core.file.rfile;
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
+import static java.util.concurrent.TimeUnit.SECONDS;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -35,7 +37,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
import org.apache.accumulo.core.client.sample.Sampler;
import org.apache.accumulo.core.conf.AccumuloConfiguration;
@@ -233,7 +234,7 @@ public class MultiThreadedRFileTest {
int maxThreads = 10;
String name = "MultiThreadedRFileTestThread";
ThreadPoolExecutor pool = ThreadPools.createThreadPool(maxThreads + 1, maxThreads + 1, 5 * 60,
- TimeUnit.SECONDS, name, false);
+ SECONDS, name, false);
try {
Runnable runnable = () -> {
try {
@@ -252,7 +253,7 @@ public class MultiThreadedRFileTest {
} finally {
pool.shutdown();
try {
- pool.awaitTermination(Long.MAX_VALUE, TimeUnit.MILLISECONDS);
+ pool.awaitTermination(Long.MAX_VALUE, MILLISECONDS);
} catch (InterruptedException e) {
e.printStackTrace();
}
diff --git a/core/src/test/java/org/apache/accumulo/core/file/rfile/bcfile/CompressionTest.java b/core/src/test/java/org/apache/accumulo/core/file/rfile/bcfile/CompressionTest.java
index 09b38d1..d9757a1 100644
--- a/core/src/test/java/org/apache/accumulo/core/file/rfile/bcfile/CompressionTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/file/rfile/bcfile/CompressionTest.java
@@ -18,6 +18,7 @@
*/
package org.apache.accumulo.core.file.rfile.bcfile;
+import static java.util.concurrent.TimeUnit.SECONDS;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
@@ -31,7 +32,6 @@ import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
import org.apache.accumulo.core.file.rfile.bcfile.Compression.Algorithm;
import org.apache.hadoop.conf.Configuration;
@@ -187,7 +187,7 @@ public class CompressionTest {
assertNotNull(codec, al + " should not be null");
- while (!service.awaitTermination(1, TimeUnit.SECONDS)) {
+ while (!service.awaitTermination(1, SECONDS)) {
// wait
}
@@ -225,7 +225,7 @@ public class CompressionTest {
service.shutdown();
- while (!service.awaitTermination(1, TimeUnit.SECONDS)) {
+ while (!service.awaitTermination(1, SECONDS)) {
// wait
}
@@ -274,7 +274,7 @@ public class CompressionTest {
assertEquals(1, testSet.size(), al + " created too many codecs");
service.shutdown();
- while (!service.awaitTermination(1, TimeUnit.SECONDS)) {
+ while (!service.awaitTermination(1, SECONDS)) {
// wait
}
diff --git a/core/src/test/java/org/apache/accumulo/core/rpc/TTimeoutTransportTest.java b/core/src/test/java/org/apache/accumulo/core/rpc/TTimeoutTransportTest.java
index 0393d81..e020ee0 100644
--- a/core/src/test/java/org/apache/accumulo/core/rpc/TTimeoutTransportTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/rpc/TTimeoutTransportTest.java
@@ -18,6 +18,7 @@
*/
package org.apache.accumulo.core.rpc;
+import static java.util.concurrent.TimeUnit.MINUTES;
import static org.easymock.EasyMock.createMock;
import static org.easymock.EasyMock.createMockBuilder;
import static org.easymock.EasyMock.expect;
@@ -75,7 +76,7 @@ public class TTimeoutTransportTest {
@Test
public void testFailedInputStreamClosesSocket() throws IOException {
- long timeout = 2 * 60_000; // 2 mins
+ long timeout = MINUTES.toMillis(2);
SocketAddress addr = createMock(SocketAddress.class);
Socket s = createMock(Socket.class);
TTimeoutTransport timeoutTransport = createMockBuilder(TTimeoutTransport.class)
@@ -105,7 +106,7 @@ public class TTimeoutTransportTest {
@Test
public void testFailedOutputStreamClosesSocket() throws IOException {
- long timeout = 2 * 60_000; // 2 mins
+ long timeout = MINUTES.toMillis(2);
SocketAddress addr = createMock(SocketAddress.class);
Socket s = createMock(Socket.class);
InputStream is = createMock(InputStream.class);
diff --git a/core/src/test/java/org/apache/accumulo/core/util/OpTimerTest.java b/core/src/test/java/org/apache/accumulo/core/util/OpTimerTest.java
index 2c08c63..0205bf6 100644
--- a/core/src/test/java/org/apache/accumulo/core/util/OpTimerTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/util/OpTimerTest.java
@@ -18,13 +18,13 @@
*/
package org.apache.accumulo.core.util;
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
+import static java.util.concurrent.TimeUnit.SECONDS;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
-import java.util.concurrent.TimeUnit;
-
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -56,8 +56,7 @@ public class OpTimerTest {
long tValue = timer.now();
- log.debug("Time value before reset {}",
- String.format("%.3f ms", timer.scale(TimeUnit.MILLISECONDS)));
+ log.debug("Time value before reset {}", String.format("%.3f ms", timer.scale(MILLISECONDS)));
timer.reset().start();
@@ -76,8 +75,7 @@ public class OpTimerTest {
timer.reset();
- log.debug("Time value after reset {}",
- String.format("%.3f ms", timer.scale(TimeUnit.MILLISECONDS)));
+ log.debug("Time value after reset {}", String.format("%.3f ms", timer.scale(MILLISECONDS)));
assertEquals(0, timer.now());
@@ -163,7 +161,7 @@ public class OpTimerTest {
long tValue = timer.now();
log.debug("Time value after first stop {}",
- String.format("%.3f ms", timer.scale(TimeUnit.MILLISECONDS)));
+ String.format("%.3f ms", timer.scale(MILLISECONDS)));
timer.start();
@@ -177,7 +175,7 @@ public class OpTimerTest {
timer.stop();
log.debug("Time value after second stop {}",
- String.format("%.3f ms", timer.scale(TimeUnit.MILLISECONDS)));
+ String.format("%.3f ms", timer.scale(MILLISECONDS)));
assertTrue(tValue < timer.now());
@@ -201,9 +199,9 @@ public class OpTimerTest {
long tValue = timer.now();
- assertEquals(tValue / 1000000.0, timer.scale(TimeUnit.MILLISECONDS), 0.00000001);
+ assertEquals(tValue / 1000000.0, timer.scale(MILLISECONDS), 0.00000001);
- assertEquals(tValue / 1000000000.0, timer.scale(TimeUnit.SECONDS), 0.00000001);
+ assertEquals(tValue / 1000000000.0, timer.scale(SECONDS), 0.00000001);
}
}
diff --git a/server/base/src/main/java/org/apache/accumulo/server/ServerContext.java b/server/base/src/main/java/org/apache/accumulo/server/ServerContext.java
index a225852..406310f 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/ServerContext.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/ServerContext.java
@@ -20,6 +20,8 @@ package org.apache.accumulo.server;
import static com.google.common.base.Preconditions.checkArgument;
import static java.nio.charset.StandardCharsets.UTF_8;
+import static java.util.concurrent.TimeUnit.MINUTES;
+import static java.util.concurrent.TimeUnit.SECONDS;
import static org.apache.accumulo.fate.util.UtilWaitThread.sleepUninterruptibly;
import java.io.File;
@@ -322,7 +324,7 @@ public class ServerContext extends ClientContext {
break;
} catch (InterruptedException | KeeperException ex) {
log.info("Waiting for accumulo to be initialized");
- sleepUninterruptibly(1, TimeUnit.SECONDS);
+ sleepUninterruptibly(1, SECONDS);
}
}
log.info("ZooKeeper connected and initialized, attempting to talk to HDFS");
@@ -358,7 +360,7 @@ public class ServerContext extends ClientContext {
log.info("Backing off due to failure; current sleep period is {} seconds", sleep / 1000.);
sleepUninterruptibly(sleep, TimeUnit.MILLISECONDS);
/* Back off to give transient failures more time to clear. */
- sleep = Math.min(60_000, sleep * 2);
+ sleep = Math.min(MINUTES.toMillis(1), sleep * 2);
}
log.info("Connected to HDFS");
}
@@ -434,7 +436,7 @@ public class ServerContext extends ClientContext {
} catch (Exception t) {
log.error("", t);
}
- }, 1000, 10 * 60_000, TimeUnit.MILLISECONDS);
+ }, SECONDS.toMillis(1), MINUTES.toMillis(10), TimeUnit.MILLISECONDS);
}
/**
diff --git a/server/base/src/main/java/org/apache/accumulo/server/client/BulkImporter.java b/server/base/src/main/java/org/apache/accumulo/server/client/BulkImporter.java
index 2737cda..a290c85 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/client/BulkImporter.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/client/BulkImporter.java
@@ -18,6 +18,7 @@
*/
package org.apache.accumulo.server.client;
+import static java.util.concurrent.TimeUnit.MINUTES;
import static org.apache.accumulo.fate.util.UtilWaitThread.sleepUninterruptibly;
import java.io.IOException;
@@ -176,7 +177,7 @@ public class BulkImporter {
long sleepTime = 2_000;
while (!assignmentFailures.isEmpty()) {
- sleepTime = Math.min(sleepTime * 2, 60_000);
+ sleepTime = Math.min(sleepTime * 2, MINUTES.toMillis(1));
locator.invalidateCache();
// assumption about assignment failures is that it caused by a split
// happening or a missing location
diff --git a/server/base/src/main/java/org/apache/accumulo/server/manager/LiveTServerSet.java b/server/base/src/main/java/org/apache/accumulo/server/manager/LiveTServerSet.java
index c58069f..d0ce0bf 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/manager/LiveTServerSet.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/manager/LiveTServerSet.java
@@ -19,6 +19,7 @@
package org.apache.accumulo.server.manager;
import static java.nio.charset.StandardCharsets.UTF_8;
+import static java.util.concurrent.TimeUnit.MINUTES;
import static org.apache.accumulo.fate.zookeeper.ZooUtil.NodeMissingPolicy.SKIP;
import java.nio.ByteBuffer;
@@ -310,7 +311,7 @@ public class LiveTServerSet implements Watcher {
Long firstSeen = locklessServers.get(zPath);
if (firstSeen == null) {
locklessServers.put(zPath, System.currentTimeMillis());
- } else if (System.currentTimeMillis() - firstSeen > 10 * 60_000) {
+ } else if (System.currentTimeMillis() - firstSeen > MINUTES.toMillis(10)) {
deleteServerNode(path + "/" + zPath);
locklessServers.remove(zPath);
}
diff --git a/server/base/src/main/java/org/apache/accumulo/server/master/balancer/HostRegexTableLoadBalancer.java b/server/base/src/main/java/org/apache/accumulo/server/master/balancer/HostRegexTableLoadBalancer.java
index 9cfce8c..12b5ed7 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/master/balancer/HostRegexTableLoadBalancer.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/master/balancer/HostRegexTableLoadBalancer.java
@@ -18,6 +18,8 @@
*/
package org.apache.accumulo.server.master.balancer;
+import static java.util.concurrent.TimeUnit.HOURS;
+
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.security.SecureRandom;
@@ -32,7 +34,6 @@ import java.util.Map.Entry;
import java.util.Set;
import java.util.SortedMap;
import java.util.TreeMap;
-import java.util.concurrent.TimeUnit;
import java.util.regex.Pattern;
import org.apache.accumulo.core.client.admin.TableOperations;
@@ -176,7 +177,6 @@ public class HostRegexTableLoadBalancer extends TableLoadBalancer {
}
}
- private static final long ONE_HOUR = 60 * 60_000;
private static final Set<KeyExtent> EMPTY_MIGRATIONS = Collections.emptySet();
private volatile long lastOOBCheck = System.currentTimeMillis();
private Map<String,SortedMap<TServerInstance,TabletServerStatus>> pools = new HashMap<>();
@@ -335,7 +335,7 @@ public class HostRegexTableLoadBalancer extends TableLoadBalancer {
this.hrtlbConf = context.getConfiguration().newDeriver(HrtlbConf::new);
tablesRegExCache =
- CacheBuilder.newBuilder().expireAfterAccess(1, TimeUnit.HOURS).build(new CacheLoader<>() {
+ CacheBuilder.newBuilder().expireAfterAccess(1, HOURS).build(new CacheLoader<>() {
@Override
public Deriver<Map<String,String>> load(TableId key) throws Exception {
return context.getTableConfiguration(key)
@@ -520,7 +520,7 @@ public class HostRegexTableLoadBalancer extends TableLoadBalancer {
if (newMigrations.isEmpty()) {
tableToTimeSinceNoMigrations.remove(s);
} else if (tableToTimeSinceNoMigrations.containsKey(s)) {
- if ((now - tableToTimeSinceNoMigrations.get(s)) > ONE_HOUR) {
+ if ((now - tableToTimeSinceNoMigrations.get(s)) > HOURS.toMillis(1)) {
LOG.warn("We have been consistently producing migrations for {}: {}", tableName,
Iterables.limit(newMigrations, 10));
}
diff --git a/server/base/src/main/java/org/apache/accumulo/server/zookeeper/DistributedWorkQueue.java b/server/base/src/main/java/org/apache/accumulo/server/zookeeper/DistributedWorkQueue.java
index 40a92c6..8b382f0 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/zookeeper/DistributedWorkQueue.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/zookeeper/DistributedWorkQueue.java
@@ -18,7 +18,9 @@
*/
package org.apache.accumulo.server.zookeeper;
+import static java.lang.Math.toIntExact;
import static java.nio.charset.StandardCharsets.UTF_8;
+import static java.util.concurrent.TimeUnit.MINUTES;
import java.security.SecureRandom;
import java.util.ArrayList;
@@ -165,7 +167,8 @@ public class DistributedWorkQueue {
public DistributedWorkQueue(String path, AccumuloConfiguration config, ServerContext context) {
// Preserve the old delay and period
- this(path, config, context, random.nextInt(60_000), 60_000);
+ this(path, config, context, random.nextInt(toIntExact(MINUTES.toMillis(1))),
+ MINUTES.toMillis(1));
}
public DistributedWorkQueue(String path, AccumuloConfiguration config, ServerContext context,
diff --git a/server/base/src/test/java/org/apache/accumulo/server/security/delegation/AuthenticationTokenSecretManagerTest.java b/server/base/src/test/java/org/apache/accumulo/server/security/delegation/AuthenticationTokenSecretManagerTest.java
index 7fcd911..bc44dbf 100644
--- a/server/base/src/test/java/org/apache/accumulo/server/security/delegation/AuthenticationTokenSecretManagerTest.java
+++ b/server/base/src/test/java/org/apache/accumulo/server/security/delegation/AuthenticationTokenSecretManagerTest.java
@@ -18,6 +18,8 @@
*/
package org.apache.accumulo.server.security.delegation;
+import static java.util.concurrent.TimeUnit.HOURS;
+import static java.util.concurrent.TimeUnit.MINUTES;
import static org.easymock.EasyMock.createMock;
import static org.easymock.EasyMock.expectLastCall;
import static org.easymock.EasyMock.replay;
@@ -81,7 +83,7 @@ public class AuthenticationTokenSecretManagerTest {
@Test
public void testAddKey() {
// 1 minute
- long tokenLifetime = 60_000;
+ long tokenLifetime = MINUTES.toMillis(1);
AuthenticationTokenSecretManager secretManager =
new AuthenticationTokenSecretManager(instanceId, tokenLifetime);
@@ -108,7 +110,7 @@ public class AuthenticationTokenSecretManagerTest {
@Test
public void testRemoveKey() {
// 1 minute
- long tokenLifetime = 60_000;
+ long tokenLifetime = MINUTES.toMillis(1);
AuthenticationTokenSecretManager secretManager =
new AuthenticationTokenSecretManager(instanceId, tokenLifetime);
@@ -132,7 +134,7 @@ public class AuthenticationTokenSecretManagerTest {
long then = System.currentTimeMillis();
// 1 minute
- long tokenLifetime = 60_000;
+ long tokenLifetime = MINUTES.toMillis(1);
AuthenticationTokenSecretManager secretManager =
new AuthenticationTokenSecretManager(instanceId, tokenLifetime);
@@ -176,7 +178,7 @@ public class AuthenticationTokenSecretManagerTest {
long then = System.currentTimeMillis();
// 1 minute
- long tokenLifetime = 60_000;
+ long tokenLifetime = MINUTES.toMillis(1);
AuthenticationTokenSecretManager secretManager =
new AuthenticationTokenSecretManager(instanceId, tokenLifetime);
@@ -247,7 +249,7 @@ public class AuthenticationTokenSecretManagerTest {
// start of the test
long then = System.currentTimeMillis();
- long tokenLifetime = 60_000;
+ long tokenLifetime = MINUTES.toMillis(1);
AuthenticationTokenSecretManager secretManager =
new AuthenticationTokenSecretManager(instanceId, tokenLifetime);
@@ -275,7 +277,7 @@ public class AuthenticationTokenSecretManagerTest {
// start of the test
long then = System.currentTimeMillis();
- long tokenLifetime = 60_000;
+ long tokenLifetime = MINUTES.toMillis(1);
AuthenticationTokenSecretManager secretManager =
new AuthenticationTokenSecretManager(instanceId, tokenLifetime);
@@ -363,7 +365,7 @@ public class AuthenticationTokenSecretManagerTest {
long then = System.currentTimeMillis();
// 1 hr
- long tokenLifetime = 60 * 60_000;
+ long tokenLifetime = HOURS.toMillis(1);
AuthenticationTokenSecretManager secretManager =
new AuthenticationTokenSecretManager(instanceId, tokenLifetime);
@@ -372,7 +374,7 @@ public class AuthenticationTokenSecretManagerTest {
.addKey(new AuthenticationKey(1, then, then + tokenLifetime, keyGen.generateKey()));
// 1 minute
- cfg.setTokenLifetime(1, TimeUnit.MINUTES);
+ cfg.setTokenLifetime(1, MINUTES);
String principal = "user@EXAMPLE.COM";
Entry<Token<AuthenticationTokenIdentifier>,AuthenticationTokenIdentifier> pair =
@@ -399,7 +401,7 @@ public class AuthenticationTokenSecretManagerTest {
long then = System.currentTimeMillis();
// 1 hr
- long tokenLifetime = 60 * 60_000;
+ long tokenLifetime = HOURS.toMillis(1);
AuthenticationTokenSecretManager secretManager =
new AuthenticationTokenSecretManager(instanceId, tokenLifetime);
diff --git a/server/base/src/test/java/org/apache/accumulo/server/security/delegation/ZooAuthenticationKeyWatcherTest.java b/server/base/src/test/java/org/apache/accumulo/server/security/delegation/ZooAuthenticationKeyWatcherTest.java
index 3f830f4..a749b63 100644
--- a/server/base/src/test/java/org/apache/accumulo/server/security/delegation/ZooAuthenticationKeyWatcherTest.java
+++ b/server/base/src/test/java/org/apache/accumulo/server/security/delegation/ZooAuthenticationKeyWatcherTest.java
@@ -18,6 +18,7 @@
*/
package org.apache.accumulo.server.security.delegation;
+import static java.util.concurrent.TimeUnit.DAYS;
import static org.easymock.EasyMock.createMock;
import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.replay;
@@ -66,7 +67,7 @@ public class ZooAuthenticationKeyWatcherTest {
private ZooReader zk;
private InstanceId instanceId;
private String baseNode;
- private long tokenLifetime = 7 * 24 * 60 * 60_000; // 7days
+ private long tokenLifetime = DAYS.toMillis(7);
private AuthenticationTokenSecretManager secretManager;
private ZooAuthenticationKeyWatcher keyWatcher;
diff --git a/server/compactor/src/main/java/org/apache/accumulo/compactor/Compactor.java b/server/compactor/src/main/java/org/apache/accumulo/compactor/Compactor.java
index eebf869..14b0545 100644
--- a/server/compactor/src/main/java/org/apache/accumulo/compactor/Compactor.java
+++ b/server/compactor/src/main/java/org/apache/accumulo/compactor/Compactor.java
@@ -19,6 +19,7 @@
package org.apache.accumulo.compactor;
import static java.nio.charset.StandardCharsets.UTF_8;
+import static java.util.concurrent.TimeUnit.MINUTES;
import static org.apache.accumulo.fate.util.UtilWaitThread.sleepUninterruptibly;
import java.io.IOException;
@@ -133,7 +134,7 @@ public class Compactor extends AbstractServer implements MetricsProducer, Compac
private static final Logger LOG = LoggerFactory.getLogger(Compactor.class);
private static final long TIME_BETWEEN_GC_CHECKS = 5000;
- private static final long TIME_BETWEEN_CANCEL_CHECKS = 5 * 60_000;
+ private static final long TIME_BETWEEN_CANCEL_CHECKS = MINUTES.toMillis(5);
private static final long TEN_MEGABYTES = 10485760;
private static final CompactionCoordinatorService.Client.Factory COORDINATOR_CLIENT_FACTORY =
diff --git a/server/manager/src/main/java/org/apache/accumulo/manager/ManagerTime.java b/server/manager/src/main/java/org/apache/accumulo/manager/ManagerTime.java
index c168d7e..41077bd 100644
--- a/server/manager/src/main/java/org/apache/accumulo/manager/ManagerTime.java
+++ b/server/manager/src/main/java/org/apache/accumulo/manager/ManagerTime.java
@@ -65,8 +65,8 @@ public class ManagerTime {
}
ThreadPools.createGeneralScheduledExecutorService(conf).scheduleWithFixedDelay(
- Threads.createNamedRunnable("Manager time keeper", () -> run()), 0,
- MILLISECONDS.convert(10, SECONDS), MILLISECONDS);
+ Threads.createNamedRunnable("Manager time keeper", () -> run()), 0, SECONDS.toMillis(10),
+ MILLISECONDS);
}
/**
@@ -75,7 +75,7 @@ public class ManagerTime {
* @return Approximate total duration this cluster has had a Manager, in milliseconds.
*/
public long getTime() {
- return MILLISECONDS.convert(System.nanoTime() + skewAmount.get(), NANOSECONDS);
+ return NANOSECONDS.toMillis(System.nanoTime() + skewAmount.get());
}
public void run() {
diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/Monitor.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/Monitor.java
index 4de7e11..9f22197 100644
--- a/server/monitor/src/main/java/org/apache/accumulo/monitor/Monitor.java
+++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/Monitor.java
@@ -19,6 +19,7 @@
package org.apache.accumulo.monitor;
import static java.nio.charset.StandardCharsets.UTF_8;
+import static java.util.concurrent.TimeUnit.HOURS;
import static org.apache.accumulo.fate.util.UtilWaitThread.sleepUninterruptibly;
import java.net.InetAddress;
@@ -134,7 +135,7 @@ public class Monitor extends AbstractServer implements HighlyAvailableService {
return Collections.synchronizedList(new LinkedList<>() {
private static final long serialVersionUID = 1L;
- private final long maxDelta = 60 * 60_000;
+ private final long maxDelta = HOURS.toMillis(1);
@Override
public boolean add(Pair<Long,T> obj) {
diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/AssignmentHandler.java b/server/tserver/src/main/java/org/apache/accumulo/tserver/AssignmentHandler.java
index 1945f26..df7f5fd 100644
--- a/server/tserver/src/main/java/org/apache/accumulo/tserver/AssignmentHandler.java
+++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/AssignmentHandler.java
@@ -18,6 +18,7 @@
*/
package org.apache.accumulo.tserver;
+import static java.util.concurrent.TimeUnit.MINUTES;
import static org.apache.accumulo.server.problems.ProblemType.TABLET_LOAD;
import java.util.Arrays;
@@ -217,7 +218,7 @@ class AssignmentHandler implements Runnable {
}
log.warn("failed to open tablet {} reporting failure to manager", extent);
server.enqueueManagerMessage(new TabletStatusMessage(TabletLoadState.LOAD_FAILURE, extent));
- long reschedule = Math.min((1L << Math.min(32, retryAttempt)) * 1000, 10 * 60_000L);
+ long reschedule = Math.min((1L << Math.min(32, retryAttempt)) * 1000, MINUTES.toMillis(10));
log.warn(String.format("rescheduling tablet load in %.2f seconds", reschedule / 1000.));
this.server.getContext().getScheduledExecutor().schedule(new Runnable() {
@Override
diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/ThriftClientHandler.java b/server/tserver/src/main/java/org/apache/accumulo/tserver/ThriftClientHandler.java
index 2da71b7..772014e 100644
--- a/server/tserver/src/main/java/org/apache/accumulo/tserver/ThriftClientHandler.java
+++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/ThriftClientHandler.java
@@ -19,6 +19,7 @@
package org.apache.accumulo.tserver;
import static java.nio.charset.StandardCharsets.UTF_8;
+import static java.util.concurrent.TimeUnit.MINUTES;
import static java.util.stream.Collectors.toList;
import static org.apache.accumulo.fate.util.UtilWaitThread.sleepUninterruptibly;
@@ -165,7 +166,7 @@ public class ThriftClientHandler extends ClientServiceHandler implements TabletC
private static final Logger log = LoggerFactory.getLogger(ThriftClientHandler.class);
private static final long MAX_TIME_TO_WAIT_FOR_SCAN_RESULT_MILLIS = 1000;
- private static final long RECENTLY_SPLIT_MILLIES = 60_000;
+ private static final long RECENTLY_SPLIT_MILLIES = MINUTES.toMillis(1);
private final TabletServer server;
private final WriteTracker writeTracker = new WriteTracker();
private final RowLocks rowLocks = new RowLocks();
diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/UnloadTabletHandler.java b/server/tserver/src/main/java/org/apache/accumulo/tserver/UnloadTabletHandler.java
index cf35d26..74a0a9d 100644
--- a/server/tserver/src/main/java/org/apache/accumulo/tserver/UnloadTabletHandler.java
+++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/UnloadTabletHandler.java
@@ -18,7 +18,6 @@
*/
package org.apache.accumulo.tserver;
-import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static java.util.concurrent.TimeUnit.NANOSECONDS;
import org.apache.accumulo.core.conf.Property;
@@ -48,7 +47,7 @@ class UnloadTabletHandler implements Runnable {
this.extent = extent;
this.goalState = goalState;
this.server = server;
- this.requestTimeSkew = requestTime - MILLISECONDS.convert(System.nanoTime(), NANOSECONDS);
+ this.requestTimeSkew = requestTime - NANOSECONDS.toMillis(System.nanoTime());
}
@Override
@@ -122,7 +121,7 @@ class UnloadTabletHandler implements Runnable {
TabletStateStore.unassign(server.getContext(), tls, null);
} else {
TabletStateStore.suspend(server.getContext(), tls, null,
- requestTimeSkew + MILLISECONDS.convert(System.nanoTime(), NANOSECONDS));
+ requestTimeSkew + NANOSECONDS.toMillis(System.nanoTime()));
}
} catch (DistributedStoreException ex) {
log.warn("Unable to update storage", ex);
diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/compactions/CompactionManager.java b/server/tserver/src/main/java/org/apache/accumulo/tserver/compactions/CompactionManager.java
index 35d9d7d..754b2c6 100644
--- a/server/tserver/src/main/java/org/apache/accumulo/tserver/compactions/CompactionManager.java
+++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/compactions/CompactionManager.java
@@ -18,6 +18,9 @@
*/
package org.apache.accumulo.tserver.compactions;
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
+import static java.util.concurrent.TimeUnit.MINUTES;
+import static java.util.concurrent.TimeUnit.NANOSECONDS;
import static org.apache.accumulo.core.util.compaction.CompactionServicesConfig.DEFAULT_SERVICE;
import java.util.Collection;
@@ -29,7 +32,6 @@ import java.util.Objects;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import org.apache.accumulo.core.conf.Property;
@@ -101,17 +103,15 @@ public class CompactionManager {
long increment = Math.max(1, maxTimeBetweenChecks / 10);
- var retryFactory = Retry.builder().infiniteRetries()
- .retryAfter(increment, TimeUnit.MILLISECONDS).incrementBy(increment, TimeUnit.MILLISECONDS)
- .maxWait(maxTimeBetweenChecks, TimeUnit.MILLISECONDS).backOffFactor(1.07)
- .logInterval(1, TimeUnit.MINUTES).createFactory();
+ var retryFactory = Retry.builder().infiniteRetries().retryAfter(increment, MILLISECONDS)
+ .incrementBy(increment, MILLISECONDS).maxWait(maxTimeBetweenChecks, MILLISECONDS)
+ .backOffFactor(1.07).logInterval(1, MINUTES).createFactory();
var retry = retryFactory.createRetry();
Compactable last = null;
while (true) {
try {
- long passed = TimeUnit.MILLISECONDS.convert(System.nanoTime() - lastCheckAllTime,
- TimeUnit.NANOSECONDS);
+ long passed = NANOSECONDS.toMillis(System.nanoTime() - lastCheckAllTime);
if (passed >= maxTimeBetweenChecks) {
// take a snapshot of what is currently running
HashSet<ExternalCompactionId> runningEcids =
@@ -127,8 +127,7 @@ public class CompactionManager {
// still exists
runningExternalCompactions.keySet().removeAll(runningEcids);
} else {
- var compactable =
- compactablesToCheck.poll(maxTimeBetweenChecks - passed, TimeUnit.MILLISECONDS);
+ var compactable = compactablesToCheck.poll(maxTimeBetweenChecks - passed, MILLISECONDS);
if (compactable != null) {
last = compactable;
submitCompaction(compactable);
@@ -225,7 +224,7 @@ public class CompactionManager {
private synchronized void checkForConfigChanges(boolean force) {
try {
final long secondsSinceLastCheck =
- TimeUnit.SECONDS.convert(System.nanoTime() - lastConfigCheckTime, TimeUnit.NANOSECONDS);
+ NANOSECONDS.toSeconds(System.nanoTime() - lastConfigCheckTime);
if (!force && (secondsSinceLastCheck < 1)) {
return;
}
diff --git a/server/tserver/src/test/java/org/apache/accumulo/tserver/memory/LargestFirstMemoryManagerTest.java b/server/tserver/src/test/java/org/apache/accumulo/tserver/memory/LargestFirstMemoryManagerTest.java
index 0216faf..2d839a3 100644
--- a/server/tserver/src/test/java/org/apache/accumulo/tserver/memory/LargestFirstMemoryManagerTest.java
+++ b/server/tserver/src/test/java/org/apache/accumulo/tserver/memory/LargestFirstMemoryManagerTest.java
@@ -18,6 +18,7 @@
*/
package org.apache.accumulo.tserver.memory;
+import static java.util.concurrent.TimeUnit.MINUTES;
import static org.easymock.EasyMock.createMock;
import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.replay;
@@ -43,12 +44,11 @@ public class LargestFirstMemoryManagerTest {
public Timeout timeout = Timeout.seconds(60);
private static final long ZERO = LargestFirstMemoryManager.ZERO_TIME;
- private static final long LATER = ZERO + 20 * 60_000;
+ private static final long LATER = ZERO + MINUTES.toMillis(20);
private static final long ONE_GIG = 1024 * 1024 * 1024;
private static final long ONE_MEG = 1024 * 1024;
private static final long HALF_GIG = ONE_GIG / 2;
private static final long QGIG = ONE_GIG / 4;
- private static final long ONE_MINUTE = 60_000;
private ServerContext context;
@@ -158,17 +158,17 @@ public class LargestFirstMemoryManagerTest {
t(k("b"), ZERO, QGIG + 1, 0), t(k("c"), ZERO, 0, QGIG + 2)));
assertEquals(0, tabletsToMinorCompact.size());
// not going to bother compacting any more
- mgr.currentTime += ONE_MINUTE;
+ mgr.currentTime += MINUTES.toMillis(1);
tabletsToMinorCompact = mgr.tabletsToMinorCompact(tablets(t(k("a"), ZERO, QGIG, 0),
t(k("b"), ZERO, QGIG + 1, 0), t(k("c"), ZERO, 0, QGIG + 2)));
assertEquals(0, tabletsToMinorCompact.size());
// now do nothing
- mgr.currentTime += ONE_MINUTE;
+ mgr.currentTime += MINUTES.toMillis(1);
tabletsToMinorCompact = mgr.tabletsToMinorCompact(
tablets(t(k("a"), ZERO, QGIG, 0), t(k("b"), ZERO, 0, 0), t(k("c"), ZERO, 0, 0)));
assertEquals(0, tabletsToMinorCompact.size());
// on no! more data, this time we compact because we've adjusted
- mgr.currentTime += ONE_MINUTE;
+ mgr.currentTime += MINUTES.toMillis(1);
tabletsToMinorCompact = mgr.tabletsToMinorCompact(
tablets(t(k("a"), ZERO, QGIG, 0), t(k("b"), ZERO, QGIG + 1, 0), t(k("c"), ZERO, 0, 0)));
assertEquals(1, tabletsToMinorCompact.size());
@@ -207,7 +207,7 @@ public class LargestFirstMemoryManagerTest {
@Override
protected long getMinCIdleThreshold(KeyExtent extent) {
- return 15 * 60_000;
+ return MINUTES.toMillis(15);
}
@Override
diff --git a/start/src/main/java/org/apache/accumulo/start/classloader/vfs/AccumuloReloadingVFSClassLoader.java b/start/src/main/java/org/apache/accumulo/start/classloader/vfs/AccumuloReloadingVFSClassLoader.java
index 2f1baff..56d9f93 100644
--- a/start/src/main/java/org/apache/accumulo/start/classloader/vfs/AccumuloReloadingVFSClassLoader.java
+++ b/start/src/main/java/org/apache/accumulo/start/classloader/vfs/AccumuloReloadingVFSClassLoader.java
@@ -18,6 +18,7 @@
*/
package org.apache.accumulo.start.classloader.vfs;
+import static java.util.concurrent.TimeUnit.MINUTES;
import static java.util.concurrent.TimeUnit.SECONDS;
import java.util.ArrayList;
@@ -52,7 +53,7 @@ public class AccumuloReloadingVFSClassLoader implements FileListener, ReloadingC
// set to 5 mins. The rationale behind this large time is to avoid a gazillion tservers all asking
// the name node for info too frequently.
- private static final int DEFAULT_TIMEOUT = 5 * 60_000;
+ private static final long DEFAULT_TIMEOUT = MINUTES.toMillis(5);
private volatile long maxWaitInterval = 60000;
diff --git a/test/src/main/java/org/apache/accumulo/test/GetManagerStats.java b/test/src/main/java/org/apache/accumulo/test/GetManagerStats.java
index fb1063b..cb2a5dd 100644
--- a/test/src/main/java/org/apache/accumulo/test/GetManagerStats.java
+++ b/test/src/main/java/org/apache/accumulo/test/GetManagerStats.java
@@ -19,11 +19,11 @@
package org.apache.accumulo.test;
import static com.google.common.util.concurrent.Uninterruptibles.sleepUninterruptibly;
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map.Entry;
-import java.util.concurrent.TimeUnit;
import org.apache.accumulo.core.clientImpl.ManagerClient;
import org.apache.accumulo.core.clientImpl.thrift.ThriftNotActiveServiceException;
@@ -51,7 +51,7 @@ public class GetManagerStats {
break;
} catch (ThriftNotActiveServiceException e) {
// Let it loop, fetching a new location
- sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
+ sleepUninterruptibly(100, MILLISECONDS);
} finally {
if (client != null) {
ManagerClient.close(client, context);
diff --git a/test/src/main/java/org/apache/accumulo/test/InterruptibleScannersIT.java b/test/src/main/java/org/apache/accumulo/test/InterruptibleScannersIT.java
index 98b64ac..c5c1cc3 100644
--- a/test/src/main/java/org/apache/accumulo/test/InterruptibleScannersIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/InterruptibleScannersIT.java
@@ -18,6 +18,7 @@
*/
package org.apache.accumulo.test;
+import static java.util.concurrent.TimeUnit.MINUTES;
import static org.junit.Assert.assertThrows;
import java.util.ArrayList;
@@ -60,7 +61,7 @@ public class InterruptibleScannersIT extends AccumuloClusterHarness {
try (Scanner scanner = client.createScanner(tableName, Authorizations.EMPTY)) {
final IteratorSetting cfg = new IteratorSetting(100, SlowIterator.class);
// Wait long enough to be sure we can catch it, but not indefinitely.
- SlowIterator.setSeekSleepTime(cfg, 60_000);
+ SlowIterator.setSeekSleepTime(cfg, MINUTES.toMillis(1));
scanner.addScanIterator(cfg);
// create a thread to interrupt the slow scan
final Thread scanThread = Thread.currentThread();
diff --git a/test/src/main/java/org/apache/accumulo/test/SplitRecoveryIT.java b/test/src/main/java/org/apache/accumulo/test/SplitRecoveryIT.java
index 47379d0..2241389 100644
--- a/test/src/main/java/org/apache/accumulo/test/SplitRecoveryIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/SplitRecoveryIT.java
@@ -18,11 +18,11 @@
*/
package org.apache.accumulo.test;
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static org.apache.accumulo.fate.util.UtilWaitThread.sleepUninterruptibly;
import static org.junit.Assert.assertEquals;
import java.util.Map.Entry;
-import java.util.concurrent.TimeUnit;
import org.apache.accumulo.core.client.Accumulo;
import org.apache.accumulo.core.client.AccumuloClient;
@@ -87,7 +87,7 @@ public class SplitRecoveryIT extends AccumuloClusterHarness {
// take the table offline
client.tableOperations().offline(tableName);
while (!isOffline(tableName, client))
- sleepUninterruptibly(200, TimeUnit.MILLISECONDS);
+ sleepUninterruptibly(200, MILLISECONDS);
// poke a partial split into the metadata table
client.securityOperations().grantTablePermission(getAdminPrincipal(), MetadataTable.NAME,
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/FateConcurrencyIT.java b/test/src/main/java/org/apache/accumulo/test/functional/FateConcurrencyIT.java
index b5e2cde..6853a62 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/FateConcurrencyIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/FateConcurrencyIT.java
@@ -18,6 +18,9 @@
*/
package org.apache.accumulo.test.functional;
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
+import static java.util.concurrent.TimeUnit.MINUTES;
+import static java.util.concurrent.TimeUnit.NANOSECONDS;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
@@ -29,7 +32,6 @@ import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import org.apache.accumulo.core.Constants;
@@ -91,7 +93,7 @@ public class FateConcurrencyIT extends AccumuloClusterHarness {
client = Accumulo.newClient().from(getClientProps()).build();
context = (ClientContext) client;
secret = cluster.getSiteConfiguration().get(Property.INSTANCE_SECRET);
- maxWaitMillis = Math.max(60_000, defaultTimeoutSeconds() * 1000 / 2);
+ maxWaitMillis = Math.max(MINUTES.toMillis(1), defaultTimeoutSeconds() * 1000 / 2);
}
@After
@@ -133,8 +135,7 @@ public class FateConcurrencyIT extends AccumuloClusterHarness {
OnlineOpTiming timing1 = task.get();
- log.trace("Online 1 in {} ms",
- TimeUnit.MILLISECONDS.convert(timing1.runningTime(), TimeUnit.NANOSECONDS));
+ log.trace("Online 1 in {} ms", NANOSECONDS.toMillis(timing1.runningTime()));
assertEquals("verify table is still online", TableState.ONLINE, getTableState(tableName));
@@ -149,8 +150,7 @@ public class FateConcurrencyIT extends AccumuloClusterHarness {
OnlineOpTiming timing2 = task.get();
- log.trace("Online 2 in {} ms",
- TimeUnit.MILLISECONDS.convert(timing2.runningTime(), TimeUnit.NANOSECONDS));
+ log.trace("Online 2 in {} ms", NANOSECONDS.toMillis(timing2.runningTime()));
assertEquals("verify table is back online", TableState.ONLINE, getTableState(tableName));
@@ -167,8 +167,8 @@ public class FateConcurrencyIT extends AccumuloClusterHarness {
OnlineOpTiming timing3 = task.get();
- assertTrue("online should take less time than expected compaction time", timing3.runningTime()
- < TimeUnit.NANOSECONDS.convert(NUM_ROWS * SLOW_SCAN_SLEEP_MS, TimeUnit.MILLISECONDS));
+ assertTrue("online should take less time than expected compaction time",
+ timing3.runningTime() < MILLISECONDS.toNanos(NUM_ROWS * SLOW_SCAN_SLEEP_MS));
assertEquals("verify table is still online", TableState.ONLINE, getTableState(tableName));
@@ -178,12 +178,9 @@ public class FateConcurrencyIT extends AccumuloClusterHarness {
client.tableOperations().cancelCompaction(tableName);
log.debug("Success: Timing results for online commands.");
- log.debug("Time for unblocked online {} ms",
- TimeUnit.MILLISECONDS.convert(timing1.runningTime(), TimeUnit.NANOSECONDS));
- log.debug("Time for online when offline {} ms",
- TimeUnit.MILLISECONDS.convert(timing2.runningTime(), TimeUnit.NANOSECONDS));
- log.debug("Time for blocked online {} ms",
- TimeUnit.MILLISECONDS.convert(timing3.runningTime(), TimeUnit.NANOSECONDS));
+ log.debug("Time for unblocked online {} ms", NANOSECONDS.toMillis(timing1.runningTime()));
+ log.debug("Time for online when offline {} ms", NANOSECONDS.toMillis(timing2.runningTime()));
+ log.debug("Time for blocked online {} ms", NANOSECONDS.toMillis(timing3.runningTime()));
// block if compaction still running
slowOps.blockWhileCompactionRunning();
@@ -467,8 +464,7 @@ public class FateConcurrencyIT extends AccumuloClusterHarness {
// stop timing
status.setComplete();
- log.trace("Online completed in {} ms",
- TimeUnit.MILLISECONDS.convert(status.runningTime(), TimeUnit.NANOSECONDS));
+ log.trace("Online completed in {} ms", NANOSECONDS.toMillis(status.runningTime()));
return status;
}
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/KerberosIT.java b/test/src/main/java/org/apache/accumulo/test/functional/KerberosIT.java
index 28f7808..c81f21e 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/KerberosIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/KerberosIT.java
@@ -18,6 +18,7 @@
*/
package org.apache.accumulo.test.functional;
+import static java.util.concurrent.TimeUnit.MINUTES;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
@@ -615,14 +616,14 @@ public class KerberosIT extends AccumuloITBase {
log.info("Created client as {}", rootUser.getPrincipal());
assertEquals(rootUser.getPrincipal(), client.whoami());
- return client.securityOperations().getDelegationToken(
- new DelegationTokenConfig().setTokenLifetime(5, TimeUnit.MINUTES));
+ return client.securityOperations()
+ .getDelegationToken(new DelegationTokenConfig().setTokenLifetime(5, MINUTES));
}
});
AuthenticationTokenIdentifier identifier = ((DelegationTokenImpl) dt).getIdentifier();
assertTrue("Expected identifier to expire in no more than 5 minutes: " + identifier,
- identifier.getExpirationDate() - identifier.getIssueDate() <= (5 * 60_000));
+ identifier.getExpirationDate() - identifier.getIssueDate() <= MINUTES.toMillis(5));
}
@Test
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/KerberosRenewalIT.java b/test/src/main/java/org/apache/accumulo/test/functional/KerberosRenewalIT.java
index 117eb9c..bbea019 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/KerberosRenewalIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/KerberosRenewalIT.java
@@ -18,6 +18,7 @@
*/
package org.apache.accumulo.test.functional;
+import static java.util.concurrent.TimeUnit.MINUTES;
import static org.junit.Assert.assertEquals;
import java.util.Map;
@@ -75,9 +76,10 @@ public class KerberosRenewalIT extends AccumuloITBase {
private static String krbEnabledForITs = null;
private static ClusterUser rootUser;
- private static final long TICKET_LIFETIME = 6 * 60_000; // Anything less seems to fail when
- // generating the ticket
- private static final long TICKET_TEST_LIFETIME = 8 * 60_000; // Run a test for 8 mins
+ private static final long TICKET_LIFETIME = MINUTES.toMillis(6); // Anything less seems to fail
+ // when
+ // generating the ticket
+ private static final long TICKET_TEST_LIFETIME = MINUTES.toMillis(8); // Run a test for 8 mins
private static final long TEST_DURATION = 9 * 60_000; // The test should finish within 9 mins
@BeforeClass
diff --git a/test/src/main/java/org/apache/accumulo/test/manager/SuspendedTabletsIT.java b/test/src/main/java/org/apache/accumulo/test/manager/SuspendedTabletsIT.java
index b616ba0..4d17c4c 100644
--- a/test/src/main/java/org/apache/accumulo/test/manager/SuspendedTabletsIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/manager/SuspendedTabletsIT.java
@@ -18,7 +18,6 @@
*/
package org.apache.accumulo.test.manager;
-import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@@ -229,7 +228,7 @@ public class SuspendedTabletsIT extends ConfigurableMacBase {
if (count == 0) {
return;
} else {
- Thread.sleep(MILLISECONDS.convert(2, SECONDS));
+ Thread.sleep(SECONDS.toMillis(2));
}
}
throw new IllegalStateException("Tablet servers didn't die!");