CommandDecoder Class Reference

Inherits org::apache::mina::filter::codec::demux::MessageDecoderAdapter.

Collaboration diagram for CommandDecoder:

Collaboration graph
[legend]

List of all members.

Classes

class  SessionStatus

Public Member Functions

final MessageDecoderResult decodable (IoSession session, ByteBuffer in)
final MessageDecoderResult decode (IoSession session, ByteBuffer in, ProtocolDecoderOutput out) throws Exception
final int Now ()

Static Public Attributes

static CharsetDecoder DECODER = Charset.forName("US-ASCII").newDecoder()

Package Types

enum  SessionState { ERROR, WAITING_FOR_DATA, READY }

Private Member Functions

SessionStatus continueSet (IoSession session, ProtocolDecoderOutput out, SessionStatus state, byte[] remainder)
SessionStatus processLine (List< String > parts, IoSession session, ProtocolDecoderOutput out)

Static Private Attributes

static final String SESSION_STATUS = "sessionStatus"
static final int THIRTY_DAYS = 60 * 60 * 24 * 30
static final int WORD_BUFFER_INIT_SIZE = 16


Detailed Description

MINA MessageDecoderAdapter responsible for parsing inbound lines from the memcached protocol session.

Member Enumeration Documentation

enum SessionState [package]

Possible states that the current session is in.

Enumerator:
ERROR 
WAITING_FOR_DATA 
READY 


Member Function Documentation

SessionStatus continueSet ( IoSession  session,
ProtocolDecoderOutput  out,
SessionStatus  state,
byte[]  remainder 
) [private]

Handles the continuation of a SET/ADD/REPLACE command with the data it was waiting for.

Parameters:
session the MINA IoSession
out the MINA protocol decoder output which we signal with the completed command
state the current session status (unused)
remainder the bytes picked up
Returns:
the new status to set the session to

final MessageDecoderResult decodable ( IoSession  session,
ByteBuffer  in 
)

Checks the specified buffer is decodable by this decoder.

In our case checks the session state to see if we are waiting for data. If we are, make sure that we actually have all the data we need.

Returns:
OK if this decoder can decode the specified buffer. NOT_OK if this decoder cannot decode the specified buffer. NEED_DATA if more data is required to determine if the specified buffer is decodable (OK) or not decodable NOT_OK.

final MessageDecoderResult decode ( IoSession  session,
ByteBuffer  in,
ProtocolDecoderOutput  out 
) throws Exception

Actually decodes inbound data from the memcached protocol session.

MINA invokes decode(IoSession, ByteBuffer, ProtocolDecoderOutput) method with read data, and then the decoder implementation puts decoded messages into ProtocolDecoderOutput.

Returns:
OK if finished decoding messages successfully. NEED_DATA if you need more data to finish decoding current message. NOT_OK if you cannot decode current message due to protocol specification violation.
Exceptions:
Exception if the read data violated protocol specification

final int Now (  ) 

Returns:
the current time in seconds

SessionStatus processLine ( List< String parts,
IoSession  session,
ProtocolDecoderOutput  out 
) [private]

Process an individual completel protocol line and either passes the command for processing by the session handler, or (in the case of SET-type commands) partially parses the command and sets the session into a state to wait for additional data.

Parameters:
parts the (originally space separated) parts of the command
session the MINA IoSession
out the MINA protocol decoder output to pass our command on to
Returns:
the session status we want to set the session to


Member Data Documentation

CharsetDecoder DECODER = Charset.forName("US-ASCII").newDecoder() [static]

final String SESSION_STATUS = "sessionStatus" [static, private]

final int THIRTY_DAYS = 60 * 60 * 24 * 30 [static, private]

final int WORD_BUFFER_INIT_SIZE = 16 [static, private]


The documentation for this class was generated from the following file:

Generated on Sat May 26 06:42:31 2012 for Project Wonder by  doxygen 1.5.8