net.spy.memcached.protocol.binary
Class GetsOperationImpl

java.lang.Object
  extended by net.spy.memcached.compat.SpyObject
      extended by net.spy.memcached.protocol.BaseOperationImpl
          extended by net.spy.memcached.protocol.binary.GetsOperationImpl
All Implemented Interfaces:
GetsOperation, KeyedOperation, Operation, VBucketAware

public class GetsOperationImpl
extends BaseOperationImpl
implements GetsOperation

Implementation of the gets operation.


Nested Class Summary
 
Nested classes/interfaces inherited from interface net.spy.memcached.ops.GetsOperation
GetsOperation.Callback
 
Field Summary
protected static byte DUMMY_OPCODE
           
protected static byte[] EMPTY_BYTES
           
protected static int ERR_2BIG
           
protected static int ERR_BUSY
           
protected static int ERR_DELTA_BADVAL
           
protected static int ERR_EXISTS
           
protected static int ERR_INTERNAL
           
protected static int ERR_INVAL
           
protected static int ERR_NO_MEM
           
protected static int ERR_NOT_FOUND
           
protected static int ERR_NOT_MY_VBUCKET
           
protected static int ERR_NOT_STORED
           
protected static int ERR_NOT_SUPPORTED
           
protected static int ERR_TEMP_FAIL
           
protected static int ERR_UNKNOWN_COMMAND
           
protected  int errorCode
           
protected  java.lang.String key
           
protected  int keyLen
           
protected static int MIN_RECV_PACKET
           
protected  int opaque
           
protected static byte REQ_MAGIC
           
protected static byte RES_MAGIC
           
protected  long responseCas
           
protected  byte responseCmd
           
protected  int responseOpaque
           
protected static OperationStatus STATUS_OK
           
protected static int SUCCESS
          Error code for operations.
protected  short vbucket
           
 
Fields inherited from class net.spy.memcached.protocol.BaseOperationImpl
callback, CANCELLED, notMyVbucketNodes, TIMED_OUT
 
Constructor Summary
GetsOperationImpl(java.lang.String k, GetsOperation.Callback cb)
           
 
Method Summary
 void addNotMyVbucketNode(MemcachedNode node)
           
protected  void decodePayload(byte[] pl)
          Decode the given payload for this command.
protected  void finishedPayload(byte[] pl)
           
 java.util.Collection<java.lang.String> getKeys()
          Get the keys requested in this GetOperation.
 java.util.Collection<MemcachedNode> getNotMyVbucketNodes()
           
protected  OperationStatus getStatusForErrorCode(int errCode, byte[] errPl)
          Get the OperationStatus object for the given error code.
 short getVBucket(java.lang.String k)
           
 void initialize()
          Initialize this operation.
protected  boolean opaqueIsValid()
          Validate an opaque value from the header.
protected  void prepareBuffer(java.lang.String key, long cas, byte[] val, java.lang.Object... extraHeaders)
          Prepare a send buffer.
 void readFromBuffer(java.nio.ByteBuffer b)
          Read data from the given byte buffer and dispatch to the appropriate read mechanism.
protected  void resetInput()
           
 void setNotMyVbucketNodes(java.util.Collection<MemcachedNode> nodes)
           
 void setVBucket(java.lang.String k, short vb)
           
 java.lang.String toString()
           
 
Methods inherited from class net.spy.memcached.protocol.BaseOperationImpl
cancel, getBuffer, getCallback, getException, getHandlingNode, getState, handleError, handleRead, hasErrored, isCancelled, isTimedOut, isTimedOut, isTimedOutUnsent, setBuffer, setCallback, setHandlingNode, timeOut, transitionState, wasCancelled, writeComplete, writing
 
Methods inherited from class net.spy.memcached.compat.SpyObject
getLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface net.spy.memcached.ops.KeyedOperation
getKeys
 
Methods inherited from interface net.spy.memcached.ops.Operation
cancel, getBuffer, getCallback, getException, getHandlingNode, getState, handleRead, hasErrored, isCancelled, isTimedOut, isTimedOut, isTimedOutUnsent, readFromBuffer, setHandlingNode, timeOut, writeComplete, writing
 

Field Detail

key

protected final java.lang.String key

REQ_MAGIC

protected static final byte REQ_MAGIC
See Also:
Constant Field Values

RES_MAGIC

protected static final byte RES_MAGIC
See Also:
Constant Field Values

DUMMY_OPCODE

protected static final byte DUMMY_OPCODE
See Also:
Constant Field Values

MIN_RECV_PACKET

protected static final int MIN_RECV_PACKET
See Also:
Constant Field Values

SUCCESS

protected static final int SUCCESS
Error code for operations.

See Also:
Constant Field Values

ERR_NOT_FOUND

protected static final int ERR_NOT_FOUND
See Also:
Constant Field Values

ERR_EXISTS

protected static final int ERR_EXISTS
See Also:
Constant Field Values

ERR_2BIG

protected static final int ERR_2BIG
See Also:
Constant Field Values

ERR_INVAL

protected static final int ERR_INVAL
See Also:
Constant Field Values

ERR_NOT_STORED

protected static final int ERR_NOT_STORED
See Also:
Constant Field Values

ERR_DELTA_BADVAL

protected static final int ERR_DELTA_BADVAL
See Also:
Constant Field Values

ERR_NOT_MY_VBUCKET

protected static final int ERR_NOT_MY_VBUCKET
See Also:
Constant Field Values

ERR_UNKNOWN_COMMAND

protected static final int ERR_UNKNOWN_COMMAND
See Also:
Constant Field Values

ERR_NO_MEM

protected static final int ERR_NO_MEM
See Also:
Constant Field Values

ERR_NOT_SUPPORTED

protected static final int ERR_NOT_SUPPORTED
See Also:
Constant Field Values

ERR_INTERNAL

protected static final int ERR_INTERNAL
See Also:
Constant Field Values

ERR_BUSY

protected static final int ERR_BUSY
See Also:
Constant Field Values

ERR_TEMP_FAIL

protected static final int ERR_TEMP_FAIL
See Also:
Constant Field Values

EMPTY_BYTES

protected static final byte[] EMPTY_BYTES

STATUS_OK

protected static final OperationStatus STATUS_OK

vbucket

protected short vbucket

opaque

protected final int opaque

keyLen

protected int keyLen

responseCmd

protected byte responseCmd

errorCode

protected int errorCode

responseOpaque

protected int responseOpaque

responseCas

protected long responseCas
Constructor Detail

GetsOperationImpl

public GetsOperationImpl(java.lang.String k,
                         GetsOperation.Callback cb)
Method Detail

initialize

public void initialize()
Description copied from interface: Operation
Initialize this operation. This is used to prepare output byte buffers and stuff.

Specified by:
initialize in interface Operation
Specified by:
initialize in class BaseOperationImpl

decodePayload

protected void decodePayload(byte[] pl)
Decode the given payload for this command.

Parameters:
pl - the payload.

getKeys

public java.util.Collection<java.lang.String> getKeys()
Description copied from interface: KeyedOperation
Get the keys requested in this GetOperation.

Specified by:
getKeys in interface KeyedOperation

getNotMyVbucketNodes

public java.util.Collection<MemcachedNode> getNotMyVbucketNodes()
Specified by:
getNotMyVbucketNodes in interface VBucketAware

addNotMyVbucketNode

public void addNotMyVbucketNode(MemcachedNode node)
Specified by:
addNotMyVbucketNode in interface VBucketAware

setNotMyVbucketNodes

public void setNotMyVbucketNodes(java.util.Collection<MemcachedNode> nodes)
Specified by:
setNotMyVbucketNodes in interface VBucketAware

setVBucket

public void setVBucket(java.lang.String k,
                       short vb)
Specified by:
setVBucket in interface VBucketAware

getVBucket

public short getVBucket(java.lang.String k)
Specified by:
getVBucket in interface VBucketAware

toString

public java.lang.String toString()

resetInput

protected void resetInput()

readFromBuffer

public void readFromBuffer(java.nio.ByteBuffer b)
                    throws java.io.IOException
Description copied from interface: Operation
Read data from the given byte buffer and dispatch to the appropriate read mechanism.

Specified by:
readFromBuffer in interface Operation
Specified by:
readFromBuffer in class BaseOperationImpl
Throws:
java.io.IOException

finishedPayload

protected void finishedPayload(byte[] pl)
                        throws java.io.IOException
Throws:
java.io.IOException

getStatusForErrorCode

protected OperationStatus getStatusForErrorCode(int errCode,
                                                byte[] errPl)
                                         throws java.io.IOException
Get the OperationStatus object for the given error code.

Parameters:
errCode - the error code
Returns:
the status to return, or null if this is an exceptional case
Throws:
java.io.IOException

opaqueIsValid

protected boolean opaqueIsValid()
Validate an opaque value from the header. This may be overridden from a subclass where the opaque isn't expected to always be the same as the request opaque.


prepareBuffer

protected void prepareBuffer(java.lang.String key,
                             long cas,
                             byte[] val,
                             java.lang.Object... extraHeaders)
Prepare a send buffer.

Parameters:
key - the key (for keyed ops)
cas - the cas value
val - the data payload
extraHeaders - any additional headers that need to be sent


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