Package net.spy.memcached.ops
Interface Operation
- All Known Subinterfaces:
CASOperation,ConcatenationOperation,DeleteConfigOperation,DeleteOperation,FlushOperation,GetAndTouchOperation,GetConfigOperation,GetlOperation,GetOperation,GetsOperation,KeyedOperation,MutatorOperation,NoopOperation,ObserveOperation,ReplicaGetOperation,ReplicaGetsOperation,SASLAuthOperation,SASLMechsOperation,SASLStepOperation,SetConfigOperation,StatsOperation,StoreOperation,TapOperation,TouchOperation,UnlockOperation,VersionOperation
- All Known Implementing Classes:
BaseGetOpImpl,BaseOperationImpl,ConcatenationOperationImpl,GetAndTouchOperationImpl,GetAndTouchOperationImpl,GetlOperationImpl,GetsOperationImpl,KeyStatsOperationImpl,MultiGetOperationImpl,OperationImpl,OptimizedSetImpl,RefreshCertOperationImpl,ReplicaGetOperationImpl,ReplicaGetsOperationImpl,SASLAuthOperationImpl,SASLBaseOperationImpl,SASLStepOperationImpl,StatsOperationImpl,TapAckOperationImpl,TapBackfillOperationImpl,TapCustomOperationImpl,TapDumpOperationImpl,TapOperationImpl,TouchOperationImpl
public interface Operation
Base interface for all operations.
-
Method Summary
Modifier and TypeMethodDescriptionvoidAdd the clone from this operation.voidcancel()Cancel this operation.Get the write buffer for this operation.Get the callback for this get operation.intReturns the number of times this operation has been cloned.byte[]Returns the raw bytes of the error message content.Get the exception that occurred (or null if no exception occurred).Get the node that should've been handling this operation.getState()Get the current state of this operation.longReturns the timestamp from the point where the WRITE was completed.voidhandleRead(ByteBuffer data) Handle a raw data read.booleanTrue if an error occurred while processing this operation.voidInitialize this operation.booleanHas this operation been cancelled?booleanTrue if the operation has timed out.booleanisTimedOut(long ttlMillis) True if the operation has timed out.booleanTrue if the operation has timed out and has not been sent.voidreadFromBuffer(ByteBuffer data) Read data from the given byte buffer and dispatch to the appropriate read mechanism.voidsetCloneCount(int count) Sets the clone count for this operation.voidSet a reference to the node that will be/is handling this operation.voidtimeOut()Mark this operation as one which has exceeded its timeout value.voidInvoked after having written all of the bytes from the supplied output buffer.voidwriting()Invoked when we start writing all of the bytes from this operation to the sockets write buffer.
-
Method Details
-
isCancelled
boolean isCancelled()Has this operation been cancelled? -
hasErrored
boolean hasErrored()True if an error occurred while processing this operation. -
getException
OperationException getException()Get the exception that occurred (or null if no exception occurred). -
getCallback
OperationCallback getCallback()Get the callback for this get operation. -
cancel
void cancel()Cancel this operation. -
getState
OperationState getState()Get the current state of this operation. -
getBuffer
ByteBuffer getBuffer()Get the write buffer for this operation. -
writing
void writing()Invoked when we start writing all of the bytes from this operation to the sockets write buffer. -
writeComplete
void writeComplete()Invoked after having written all of the bytes from the supplied output buffer. -
initialize
void initialize()Initialize this operation. This is used to prepare output byte buffers and stuff. -
readFromBuffer
Read data from the given byte buffer and dispatch to the appropriate read mechanism.- Throws:
IOException
-
handleRead
Handle a raw data read. -
getHandlingNode
MemcachedNode getHandlingNode()Get the node that should've been handling this operation. -
setHandlingNode
Set a reference to the node that will be/is handling this operation.- Parameters:
to- a memcached node
-
timeOut
void timeOut()Mark this operation as one which has exceeded its timeout value. -
isTimedOut
boolean isTimedOut()True if the operation has timed out.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
boolean isTimedOut(long ttlMillis) True if the operation has timed out. The ttl allows the caller to specify how long the operation should have been given since its creation, returning true if the operation has exceeded that time period.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.
- Parameters:
ttlMillis- the max amount of time an operation may have existed since its creation in milliseconds.
-
isTimedOutUnsent
boolean isTimedOutUnsent()True if the operation has timed out and has not been sent. If the client has timed out this operation and knows it has not been written to the network, this will be true. -
getWriteCompleteTimestamp
long getWriteCompleteTimestamp()Returns the timestamp from the point where the WRITE was completed. This can be used to calculate the roundtrip time of the operation. -
getErrorMsg
byte[] getErrorMsg()Returns the raw bytes of the error message content.- Returns:
- the raw error message content.
-
addClone
Add the clone from this operation.- Parameters:
op- the cloned operation.
-
getCloneCount
int getCloneCount()Returns the number of times this operation has been cloned.- Returns:
- the number of clones.
-
setCloneCount
void setCloneCount(int count) Sets the clone count for this operation.
-