org.apache.cassandra.service

## Class AbstractReadExecutor

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

-     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.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected ReadCommand` | `command`
    `protected ReadCallback<ReadResponse,Row>` | `handler`
    `protected RowDigestResolver` | `resolver`
    `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
    `Row` | `get()` wait for an answer.
    `abstract java.util.Collection<java.net.InetAddress>` | `getContactedReplicas()` Get the replicas involved in the [finished] request.
    `static AbstractReadExecutor` | `getReadExecutor(ReadCommand command, ConsistencyLevel consistencyLevel)`
    `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

    - #### resolver

          protected final RowDigestResolver resolver

    - #### handler

          protected final ReadCallback<ReadResponse,Row> 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 Row 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(ReadCommand command,
                                                             ConsistencyLevel consistencyLevel)
                                                      throws UnavailableException

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

Copyright © 2018 The Apache Software Foundation