Class AbstractWriteResponseHandler<T>

java.lang.Object
org.apache.cassandra.service.AbstractWriteResponseHandler<T>
All Implemented Interfaces:
RequestCallback<T>
Direct Known Subclasses:
BatchlogResponseHandler, DatacenterSyncWriteResponseHandler, WriteResponseHandler

public abstract class AbstractWriteResponseHandler<T> extends Object implements RequestCallback<T>
  • Field Details

    • logger

      protected static final org.slf4j.Logger logger
    • replicaPlan

      protected final ReplicaPlan.ForWrite replicaPlan
    • callback

      protected final Runnable callback
    • writeType

      protected final WriteType writeType
  • Constructor Details

  • Method Details

    • get

      public void get() throws WriteTimeoutException, WriteFailureException
      Throws:
      WriteTimeoutException
      WriteFailureException
    • currentTimeoutNanos

      public final long currentTimeoutNanos()
    • setIdealCLResponseHandler

      public void setIdealCLResponseHandler(AbstractWriteResponseHandler handler)
      Set a delegate ideal CL write response handler. Note that this could be the same as this if the ideal CL and requested CL are the same.
    • logResponseToIdealCLDelegate

      protected final void logResponseToIdealCLDelegate(Message<T> m)
      This logs the response but doesn't do any further processing related to this write response handler on whether the CL was achieved. Only call this after the subclass has completed all it's processing since the subclass instance may be queried to find out if the CL was achieved.
    • logFailureOrTimeoutToIdealCLDelegate

      protected final void logFailureOrTimeoutToIdealCLDelegate()
    • expired

      public final void expired()
    • blockFor

      protected int blockFor()
      Returns:
      the minimum number of endpoints that must respond.
    • candidateReplicaCount

      protected int candidateReplicaCount()
      TODO: this method is brittle for its purpose of deciding when we should fail a query; this needs to be aware of which nodes are live/down
      Returns:
      the total number of endpoints the request can send to.
    • consistencyLevel

      public ConsistencyLevel consistencyLevel()
    • waitingFor

      protected boolean waitingFor(InetAddressAndPort from)
      Returns:
      true if the message counts towards the blockFor() threshold
    • ackCount

      protected abstract int ackCount()
      Returns:
      number of responses received
    • getRequestTime

      public Dispatcher.RequestTime getRequestTime()
    • onResponse

      public abstract void onResponse(Message<T> msg)
      null message means "response from local write"
      Specified by:
      onResponse in interface RequestCallback<T>
      Parameters:
      msg - response received.
    • signal

      protected void signal()
    • onFailure

      public void onFailure(InetAddressAndPort from, RequestFailureReason failureReason)
      Description copied from interface: RequestCallback
      Called when there is an exception on the remote node or timeout happens
      Specified by:
      onFailure in interface RequestCallback<T>
    • invokeOnFailure

      public boolean invokeOnFailure()
      Description copied from interface: RequestCallback
      Returns true if the callback handles failure reporting - in which case the remove host will be asked to report failures to us in the event of a problem processing the request. TODO: this is an error prone method, and we should be handling failures everywhere so we should probably just start doing that, and remove this method
      Specified by:
      invokeOnFailure in interface RequestCallback<T>
      Returns:
      true if the callback should be invoked on failure
    • maybeTryAdditionalReplicas

      public void maybeTryAdditionalReplicas(IMutation mutation, StorageProxy.WritePerformer writePerformer, String localDC)
      Cheap Quorum backup. If we failed to reach quorum with our initial (full) nodes, reach out to other nodes.