Class AbstractWriteResponseHandler<T>

    • Field Detail

      • logger

        protected static final org.slf4j.Logger logger
      • callback

        protected final java.lang.Runnable callback
      • writeType

        protected final WriteType writeType
    • Constructor Detail

      • AbstractWriteResponseHandler

        protected AbstractWriteResponseHandler​(ReplicaPlan.ForWrite replicaPlan,
                                               java.lang.Runnable callback,
                                               WriteType writeType,
                                               java.util.function.Supplier<Mutation> hintOnFailure,
                                               Dispatcher.RequestTime requestTime)
        Parameters:
        callback - A callback to be called when the write is successful.
        hintOnFailure -
        requestTime -
    • Method Detail

      • 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.
      • 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.
      • 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
      • 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()
      • 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,
                                               java.lang.String localDC)
        Cheap Quorum backup. If we failed to reach quorum with our initial (full) nodes, reach out to other nodes.