ThrottledAsyncChecker (Apache Hadoop HDFS 3.5.0 API)
Description: declaration: package: org.apache.hadoop.hdfs.server.datanode.checker, class: ThrottledAsyncChecker

Package org.apache.hadoop.hdfs.server.datanode.checker

# Class ThrottledAsyncChecker<K,V>

java.lang.Object
org.apache.hadoop.hdfs.server.datanode.checker.ThrottledAsyncChecker<K,V>

All Implemented Interfaces:
  `AsyncChecker<K,V>`

@Private @Unstable public class ThrottledAsyncChecker<K,V> extends Object implements AsyncChecker<K,V>
An implementation of `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.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final org.slf4j.Logger`
  `LOG`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ThrottledAsyncChecker(org.apache.hadoop.util.Timer timer, long minMsBetweenChecks, long diskCheckTimeout, ExecutorService executorService)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `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, TimeUnit timeUnit)`
  Cancel all executing checks and wait for them to complete.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### LOG

    public static final org.slf4j.Logger LOG

- ## Constructor Details

  - ### ThrottledAsyncChecker

    public ThrottledAsyncChecker(org.apache.hadoop.util.Timer timer, long minMsBetweenChecks, long diskCheckTimeout, ExecutorService executorService)

- ## Method Details

  - ### schedule

    public 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. Multiple concurrent checks for the same object will receive the same Future.
    Specified by:
      `schedule` in interface `AsyncChecker<K,V>`
    Parameters:
      `target` - object to be checked.
      `context` - the interpretation of the context depends on the target.
    Returns:
      returns a `of ListenableFuture` that can be used to retrieve the result of the asynchronous check.

  - ### shutdownAndWait

    public void shutdownAndWait(long timeout, TimeUnit timeUnit) throws InterruptedException
    Cancel all executing checks and wait for them to complete. First attempts a graceful cancellation, then cancels forcefully. Waits for the supplied timeout after both attempts. See `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.
    Specified by:
      `shutdownAndWait` in interface `AsyncChecker<K,V>`
    Throws:
      `InterruptedException`