org.apache.cassandra.service

## Class AbstractWriteResponseHandler<T>

- java.lang.Object
- - org.apache.cassandra.service.AbstractWriteResponseHandler<T>

All Implemented Interfaces:
  IAsyncCallback<T>, IAsyncCallbackWithFailure<T>

Direct Known Subclasses:
  DatacenterSyncWriteResponseHandler, WriteResponseHandler

    public abstract class AbstractWriteResponseHandler<T>
    extends java.lang.Object
    implements IAsyncCallbackWithFailure<T>

### Field Summary

Fields
`protected java.lang.Runnable` `callback`
`ConsistencyLevel` `consistencyLevel`
`protected Keyspace` `keyspace`
`protected static org.slf4j.Logger` `logger`
`protected java.util.Collection<java.net.InetAddress>` `naturalEndpoints`
`protected java.util.Collection<java.net.InetAddress>` `pendingEndpoints`
`protected long` `start`

### Fields inherited from interface org.apache.cassandra.net.IAsyncCallback

`isAlive`

### Constructor Summary

Constructors
`protected` `AbstractWriteResponseHandler(Keyspace keyspace, java.util.Collection<java.net.InetAddress> naturalEndpoints, java.util.Collection<java.net.InetAddress> pendingEndpoints, ConsistencyLevel consistencyLevel, java.lang.Runnable callback, WriteType writeType)`

### Method Summary

All Methods Instance Methods Abstract Methods Concrete Methods
`protected abstract int` `ackCount()`
`void` `assureSufficientLiveNodes()`
`void` `get()`
`void` `onFailure(java.net.InetAddress from)` Called when there is an exception on the remote node or timeout happens
`abstract void` `response(MessageIn<T> msg)` null message means "response from local write"
`protected void` `signal()`
`protected int` `totalBlockFor()`
`protected int` `totalEndpoints()`
`protected boolean` `waitingFor(java.net.InetAddress from)`

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

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

### Methods inherited from interface org.apache.cassandra.net.IAsyncCallback

`isLatencyForSnitch`

### Field Detail

#### logger

    protected static final org.slf4j.Logger logger

#### keyspace

    protected final Keyspace keyspace

#### start

    protected final long start

#### naturalEndpoints

    protected final java.util.Collection<java.net.InetAddress> naturalEndpoints

#### consistencyLevel

    public final ConsistencyLevel consistencyLevel

#### callback

    protected final java.lang.Runnable callback

#### pendingEndpoints

    protected final java.util.Collection<java.net.InetAddress> pendingEndpoints

### Constructor Detail

#### AbstractWriteResponseHandler

    protected AbstractWriteResponseHandler(Keyspace keyspace,
                                           java.util.Collection<java.net.InetAddress> naturalEndpoints,
                                           java.util.Collection<java.net.InetAddress> pendingEndpoints,
                                           ConsistencyLevel consistencyLevel,
                                           java.lang.Runnable callback,
                                           WriteType writeType)

Parameters:
  `callback` - A callback to be called when the write is successful.

### Method Detail

#### get

    public void get()
             throws WriteTimeoutException,
                    WriteFailureException

Throws:
  `WriteTimeoutException`
  `WriteFailureException`

#### totalBlockFor

    protected int totalBlockFor()

Returns:
  the minimum number of endpoints that must reply.

#### totalEndpoints

    protected int totalEndpoints()

Returns:
  the total number of endpoints the request has been sent to.

#### waitingFor

    protected boolean waitingFor(java.net.InetAddress from)

Returns:
  true if the message counts towards the totalBlockFor() threshold

#### ackCount

    protected abstract int ackCount()

Returns:
  number of responses received

#### response

    public abstract void response(MessageIn<T> msg)

null message means "response from local write"

Specified by:
  `response` in interface `IAsyncCallback<T>`
Parameters:
  `msg` - response received.

#### assureSufficientLiveNodes

    public void assureSufficientLiveNodes()
                                   throws UnavailableException

Throws:
  `UnavailableException`

#### signal

    protected void signal()

#### onFailure

    public void onFailure(java.net.InetAddress from)

Description copied from interface: `IAsyncCallbackWithFailure`
Called when there is an exception on the remote node or timeout happens

Specified by:
  `onFailure` in interface `IAsyncCallbackWithFailure<T>`