public abstract class BaseOperationImpl extends SpyObject implements Operation
Modifier and Type | Field and Description |
---|---|
protected OperationCallback |
callback |
static OperationStatus |
CANCELLED
Status object for canceled operations.
|
protected java.util.Collection<MemcachedNode> |
notMyVbucketNodes |
static OperationStatus |
TIMED_OUT |
Constructor and Description |
---|
BaseOperationImpl() |
Modifier and Type | Method and Description |
---|---|
void |
cancel()
Cancel this operation.
|
java.nio.ByteBuffer |
getBuffer()
Get the write buffer for this operation.
|
OperationCallback |
getCallback()
Get the operation callback associated with this operation.
|
OperationException |
getException()
Get the exception that occurred (or null if no exception occurred).
|
MemcachedNode |
getHandlingNode()
Get the node that should've been handling this operation.
|
OperationState |
getState()
Get the current state of this operation.
|
protected void |
handleError(OperationErrorType eType,
java.lang.String line) |
void |
handleRead(java.nio.ByteBuffer data)
Handle a raw data read.
|
boolean |
hasErrored()
True if an error occurred while processing this operation.
|
abstract void |
initialize()
Initialize this operation.
|
boolean |
isCancelled()
Has this operation been cancelled?
|
boolean |
isTimedOut()
True if the operation has timed out.
|
boolean |
isTimedOut(long ttlMillis)
True if the operation has timed out.
|
boolean |
isTimedOutUnsent()
True if the operation has timed out and has not been sent.
|
abstract void |
readFromBuffer(java.nio.ByteBuffer data)
Read data from the given byte buffer and dispatch to the appropriate read
mechanism.
|
protected void |
setBuffer(java.nio.ByteBuffer to)
Set the write buffer for this operation.
|
protected void |
setCallback(OperationCallback to)
Set the callback for this instance.
|
void |
setHandlingNode(MemcachedNode to)
Set a reference to the node that will be/is handling this operation.
|
void |
timeOut()
Mark this operation as one which has exceeded its timeout value.
|
protected void |
transitionState(OperationState newState)
Transition the state of this operation to the given state.
|
protected void |
wasCancelled()
This is called on each subclass whenever an operation was cancelled.
|
void |
writeComplete()
Invoked after having written all of the bytes from the supplied output
buffer.
|
void |
writing()
Invoked when we start writing all of the bytes from this operation to
the sockets write buffer.
|
public static final OperationStatus CANCELLED
public static final OperationStatus TIMED_OUT
protected OperationCallback callback
protected java.util.Collection<MemcachedNode> notMyVbucketNodes
public final OperationCallback getCallback()
getCallback
in interface Operation
protected void setCallback(OperationCallback to)
public final boolean isCancelled()
Operation
isCancelled
in interface Operation
public final boolean hasErrored()
Operation
hasErrored
in interface Operation
public final OperationException getException()
Operation
getException
in interface Operation
public final void cancel()
Operation
protected void wasCancelled()
public final OperationState getState()
Operation
public final java.nio.ByteBuffer getBuffer()
Operation
protected final void setBuffer(java.nio.ByteBuffer to)
protected final void transitionState(OperationState newState)
public final void writing()
Operation
public final void writeComplete()
Operation
writeComplete
in interface Operation
public abstract void initialize()
Operation
initialize
in interface Operation
public abstract void readFromBuffer(java.nio.ByteBuffer data) throws java.io.IOException
Operation
readFromBuffer
in interface Operation
java.io.IOException
protected void handleError(OperationErrorType eType, java.lang.String line) throws java.io.IOException
java.io.IOException
public void handleRead(java.nio.ByteBuffer data)
Operation
handleRead
in interface Operation
public MemcachedNode getHandlingNode()
Operation
getHandlingNode
in interface Operation
public void setHandlingNode(MemcachedNode to)
Operation
setHandlingNode
in interface Operation
to
- a memcached nodepublic void timeOut()
Operation
public boolean isTimedOut()
Operation
A timed out operation may or may not have been sent to the server already, but it exceeded either the specified or the default timeout value.
isTimedOut
in interface Operation
public boolean isTimedOut(long ttlMillis)
Operation
A timed out operation may or may not have been sent to the server already, but it exceeded either the specified or the default timeout value.
In the rare case this may be called with a longer timeout value after having been called with a shorter value that caused the operation to be timed out, an IllegalArgumentException may be thrown.
isTimedOut
in interface Operation
ttlMillis
- the max amount of time an operation may have existed since
its creation in milliseconds.public boolean isTimedOutUnsent()
Operation
isTimedOutUnsent
in interface Operation
Copyright © 2006-2009 Dustin Sallings, 2009-2013 Couchbase, Inc.