AsyncChecker<K,V>@Private @Unstable public class ThrottledAsyncChecker<K,V> extends java.lang.Object implements AsyncChecker<K,V>
AsyncChecker that skips checking recently
checked objects. It will enforce at least minMsBetweenChecks
milliseconds between two successive checks of any one object.
It is assumed that the total number of Checkable objects in the system
is small, (not more than a few dozen) since the checker uses O(Checkables)
storage and also potentially O(Checkables) threads.
minMsBetweenChecks should be configured reasonably
by the caller to avoid spinning up too many threads frequently.| Modifier and Type | Field | Description |
|---|---|---|
static org.slf4j.Logger |
LOG |
| Constructor | Description |
|---|---|
ThrottledAsyncChecker(org.apache.hadoop.util.Timer timer,
long minMsBetweenChecks,
long diskCheckTimeout,
java.util.concurrent.ExecutorService executorService) |
| Modifier and Type | Method | Description |
|---|---|---|
java.util.Optional<org.apache.hadoop.thirdparty.com.google.common.util.concurrent.ListenableFuture<V>> |
schedule(Checkable<K,V> target,
K context) |
See
AsyncChecker.schedule(org.apache.hadoop.hdfs.server.datanode.checker.Checkable<K, V>, K)
If the object has been checked recently then the check will
be skipped. |
void |
shutdownAndWait(long timeout,
java.util.concurrent.TimeUnit timeUnit) |
Cancel all executing checks and wait for them to complete.
|
public ThrottledAsyncChecker(org.apache.hadoop.util.Timer timer,
long minMsBetweenChecks,
long diskCheckTimeout,
java.util.concurrent.ExecutorService executorService)
public java.util.Optional<org.apache.hadoop.thirdparty.com.google.common.util.concurrent.ListenableFuture<V>> schedule(Checkable<K,V> target, K context)
AsyncChecker.schedule(org.apache.hadoop.hdfs.server.datanode.checker.Checkable<K, V>, K)
If the object has been checked recently then the check will
be skipped. Multiple concurrent checks for the same object
will receive the same Future.schedule in interface AsyncChecker<K,V>target - object to be checked.context - the interpretation of the context depends on the
target.of ListenableFuture that can be used to
retrieve the result of the asynchronous check.public void shutdownAndWait(long timeout,
java.util.concurrent.TimeUnit timeUnit)
throws java.lang.InterruptedException
ExecutorService.awaitTermination(long, java.util.concurrent.TimeUnit) for a description of
the parameters..
The results of in-progress checks are not useful during shutdown,
so we optimize for faster shutdown by interrupt all actively
executing checks.shutdownAndWait in interface AsyncChecker<K,V>java.lang.InterruptedExceptionCopyright © 2008–2025 Apache Software Foundation. All rights reserved.