Class OperationImpl

All Implemented Interfaces:
Operation
Direct Known Subclasses:
GetAndTouchOperationImpl, GetlOperationImpl, GetsOperationImpl, KeyStatsOperationImpl, MultiGetOperationImpl, OptimizedSetImpl, ReplicaGetOperationImpl, ReplicaGetsOperationImpl, SASLBaseOperationImpl, StatsOperationImpl, TapOperationImpl, TouchOperationImpl

public abstract class OperationImpl extends BaseOperationImpl implements Operation
Base class for binary operations.
  • Field Details

    • REQ_MAGIC

      protected static final byte REQ_MAGIC
      See Also:
    • RES_MAGIC

      protected static final byte RES_MAGIC
      See Also:
    • DUMMY_OPCODE

      protected static final byte DUMMY_OPCODE
      See Also:
    • MIN_RECV_PACKET

      protected static final int MIN_RECV_PACKET
      See Also:
    • SUCCESS

      protected static final int SUCCESS
      Error code for operations.
      See Also:
    • ERR_NOT_FOUND

      protected static final int ERR_NOT_FOUND
      See Also:
    • ERR_EXISTS

      protected static final int ERR_EXISTS
      See Also:
    • ERR_2BIG

      protected static final int ERR_2BIG
      See Also:
    • ERR_INVAL

      protected static final int ERR_INVAL
      See Also:
    • ERR_NOT_STORED

      protected static final int ERR_NOT_STORED
      See Also:
    • ERR_DELTA_BADVAL

      protected static final int ERR_DELTA_BADVAL
      See Also:
    • ERR_NOT_MY_VBUCKET

      protected static final int ERR_NOT_MY_VBUCKET
      See Also:
    • ERR_UNKNOWN_COMMAND

      protected static final int ERR_UNKNOWN_COMMAND
      See Also:
    • ERR_NO_MEM

      protected static final int ERR_NO_MEM
      See Also:
    • ERR_NOT_SUPPORTED

      protected static final int ERR_NOT_SUPPORTED
      See Also:
    • ERR_INTERNAL

      protected static final int ERR_INTERNAL
      See Also:
    • ERR_BUSY

      protected static final int ERR_BUSY
      See Also:
    • ERR_TEMP_FAIL

      protected static final int ERR_TEMP_FAIL
      See Also:
    • 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 Details

    • OperationImpl

      protected OperationImpl(byte c, int o, OperationCallback cb)
      Construct with opaque.
      Parameters:
      o - the opaque value.
      cb -
  • Method Details

    • resetInput

      protected void resetInput()
    • readFromBuffer

      public void readFromBuffer(ByteBuffer buffer) throws IOException
      Read from the incoming ByteBuffer. Reading from the buffer is done in stages, depending on how much data can be read at once. First, the header is read and then parsed (24 bytes, indicated by MIN_RECV_PACKET). Then, the payload is read (if one is available for this operation and can be loaded fully).
      Specified by:
      readFromBuffer in interface Operation
      Specified by:
      readFromBuffer in class BaseOperationImpl
      Parameters:
      buffer - the buffer to read from.
      Throws:
      IOException - if an error happened during parsing/reading.
    • finishedPayload

      protected void finishedPayload(byte[] pl) throws IOException
      Throws:
      IOException
    • getStatusForErrorCode

      protected OperationStatus getStatusForErrorCode(int errCode, byte[] errPl) throws 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:
      IOException
    • decodePayload

      protected void decodePayload(byte[] pl)
      Decode the given payload for this command.
      Parameters:
      pl - the payload.
    • 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(String key, long cas, byte[] val, Object... extraHeaders)
      Prepare the buffer for sending.
      Parameters:
      key - the key (for keyed ops).
      cas - the cas value.
      val - the data payload.
      extraHeaders - any additional headers that need to be sent.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getErrorMsg

      public byte[] getErrorMsg()
      Description copied from interface: Operation
      Returns the raw bytes of the error message content.
      Specified by:
      getErrorMsg in interface Operation
      Returns:
      the raw error message content.