net.spy.memcached.ops
Interface Operation

All Known Subinterfaces:
CASOperation, ConcatenationOperation, DeleteOperation, FlushOperation, GetAndTouchOperation, GetlOperation, GetOperation, GetsOperation, KeyedOperation, MutatorOperation, NoopOperation, ObserveOperation, SASLAuthOperation, SASLMechsOperation, SASLStepOperation, StatsOperation, StoreOperation, TapOperation, UnlockOperation, VersionOperation
All Known Implementing Classes:
BaseOperationImpl, ConcatenationOperationImpl, GetAndTouchOperationImpl, GetAndTouchOperationImpl, GetlOperationImpl, GetsOperationImpl, OptimizedSetImpl, SASLAuthOperationImpl, SASLBaseOperationImpl, SASLStepOperationImpl, StatsOperationImpl, TapAckOperationImpl, TapBackfillOperationImpl, TapCustomOperationImpl, TapDumpOperationImpl, TapOperationImpl, TouchOperationImpl

public interface Operation

Base interface for all operations.


Method Summary
 void cancel()
          Cancel this operation.
 java.nio.ByteBuffer getBuffer()
          Get the write buffer for this operation.
 OperationCallback getCallback()
          Get the callback for this get 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.
 void handleRead(java.nio.ByteBuffer data)
          Handle a raw data read.
 boolean hasErrored()
          True if an error occurred while processing this operation.
 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.
 void readFromBuffer(java.nio.ByteBuffer data)
          Read data from the given byte buffer and dispatch to the appropriate read mechanism.
 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.
 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.
 

Method Detail

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

java.nio.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

void readFromBuffer(java.nio.ByteBuffer data)
                    throws java.io.IOException
Read data from the given byte buffer and dispatch to the appropriate read mechanism.

Throws:
java.io.IOException

handleRead

void handleRead(java.nio.ByteBuffer data)
Handle a raw data read.


getHandlingNode

MemcachedNode getHandlingNode()
Get the node that should've been handling this operation.


setHandlingNode

void setHandlingNode(MemcachedNode to)
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.



Copyright © 2006-2009 Dustin Sallings, 2009-2012 Couchbase, Inc.