AbstractReadExecutor (apache-cassandra API)
Date: 2018-02-14

org.apache.cassandra.service

## Class AbstractReadExecutor

- java.lang.Object
- - org.apache.cassandra.service.AbstractReadExecutor

- Direct Known Subclasses:
    AbstractReadExecutor.NeverSpeculatingReadExecutor

      public abstract class AbstractReadExecutor
      extends java.lang.Object

  Sends a read request to the replicas needed to satisfy a given ConsistencyLevel. Optionally, may perform additional requests to provide redundancy against replica failure: AlwaysSpeculatingReadExecutor will always send a request to one extra replica, while SpeculatingReadExecutor will wait until it looks like the original request is in danger of timing out before performing extra reads.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `AbstractReadExecutor.NeverSpeculatingReadExecutor`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected ReadCommand` | `command`
    `protected ReadCallback` | `handler`
    `protected java.util.List<java.net.InetAddress>` | `targetReplicas`
    `protected TraceState` | `traceState`

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `abstract void` | `executeAsync()` send the initial set of requests
    `PartitionIterator` | `get()` wait for an answer.
    `abstract java.util.Collection<java.net.InetAddress>` | `getContactedReplicas()` Get the replicas involved in the [finished] request.
    `static AbstractReadExecutor` | `getReadExecutor(SinglePartitionReadCommand command, ConsistencyLevel consistencyLevel, long queryStartNanoTime)`
    `protected void` | `makeDataRequests(java.lang.Iterable<java.net.InetAddress> endpoints)`
    `protected void` | `makeDigestRequests(java.lang.Iterable<java.net.InetAddress> endpoints)`
    `abstract void` | `maybeTryAdditionalReplicas()` Perform additional requests if it looks like the original will time out.

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

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

- - ### Field Detail

    - #### command

          protected final ReadCommand command

    - #### targetReplicas

          protected final java.util.List<java.net.InetAddress> targetReplicas

    - #### handler

          protected final ReadCallback handler

    - #### traceState

          protected final TraceState traceState

  - ### Method Detail

    - #### makeDataRequests

          protected void makeDataRequests(java.lang.Iterable<java.net.InetAddress> endpoints)

    - #### makeDigestRequests

          protected void makeDigestRequests(java.lang.Iterable<java.net.InetAddress> endpoints)

    - #### maybeTryAdditionalReplicas

          public abstract void maybeTryAdditionalReplicas()

      Perform additional requests if it looks like the original will time out. May block while it waits to see if the original requests are answered first.

    - #### getContactedReplicas

          public abstract java.util.Collection<java.net.InetAddress> getContactedReplicas()

      Get the replicas involved in the [finished] request.
      Returns:
        target replicas + the extra replica, *IF* we speculated.

    - #### executeAsync

          public abstract void executeAsync()

      send the initial set of requests

    - #### get

          public PartitionIterator get()
                                throws ReadFailureException,
                                       ReadTimeoutException,
                                       DigestMismatchException

      wait for an answer. Blocks until success or timeout, so it is caller's responsibility to call maybeTryAdditionalReplicas first.
      Throws:
        `ReadFailureException`
        `ReadTimeoutException`
        `DigestMismatchException`

    - #### getReadExecutor

          public static AbstractReadExecutor getReadExecutor(SinglePartitionReadCommand command,
                                                             ConsistencyLevel consistencyLevel,
                                                             long queryStartNanoTime)
                                                      throws UnavailableException

      Returns:
        an executor appropriate for the configured speculative read policy
      Throws:
        `UnavailableException`

Copyright © 2018 The Apache Software Foundation