AbstractReadExecutor (apache-cassandra API)
Date: 2014-10-21

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`

  - ### Method Summary

    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

  - ### 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 ReadTimeoutException,
                         DigestMismatchException

      wait for an answer. Blocks until success or timeout, so it is caller's responsibility to call maybeTryAdditionalReplicas first.
      Throws:
        `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 © 2014 The Apache Software Foundation