ServerSessionHandler Class Reference

Inherits org::apache::mina::common::IoHandler.

Collaboration diagram for ServerSessionHandler:

Collaboration graph
[legend]

List of all members.

Public Member Functions

void exceptionCaught (IoSession session, Throwable cause) throws CharacterCodingException
void messageReceived (IoSession session, Object message) throws CharacterCodingException
void messageSent (IoSession session, Object message)
 ServerSessionHandler (Cache cache, String memcachedVersion, boolean verbosity, int idle)
void sessionClosed (IoSession session)
void sessionCreated (IoSession session)
void sessionIdle (IoSession session, IdleStatus status)
void sessionOpened (IoSession session)

Public Attributes

int curr_conns
int idle_limit
int started
int total_conns
boolean verbose
String version

Static Public Attributes

static long bytes_read
static long bytes_written
static long curr_bytes
static CharsetEncoder ENCODER = Charset.forName("US-ASCII").newEncoder()

Protected Member Functions

String add (MCElement e)
String append (MCElement element)
String cas (Long cas_key, MCElement e)
String delete (String key, int time)
String flush_all (int expire)
boolean flush_all ()
MCElement get (String key)
String get_add (String key, int mod)
String getStoreResponseString (Cache.StoreResponse storeResponse)
void initStats ()
boolean is_there (String key)
final int Now ()
String prepend (MCElement element)
String replace (MCElement e)
String set (MCElement e)
String stat (String arg)

Protected Attributes

Cache cache

Package Attributes

final Logger logger = LoggerFactory.getLogger(ServerSessionHandler.class)

Private Member Functions

String getDeleteResponseString (Cache.DeleteResponse deleteResponse)


Detailed Description

The heart of the daemon, responsible for handling the creation and destruction of network sessions, keeping cache statistics, and (most importantly) processing inbound (parsed) commands and then passing on a response message for output.

Constructor & Destructor Documentation

ServerSessionHandler ( Cache  cache,
String  memcachedVersion,
boolean  verbosity,
int  idle 
)

Construct the server session handler

Parameters:
cache the cache to use
memcachedVersion the version string to return to clients
verbosity verbosity level for debugging
idle how long sessions can be idle for


Member Function Documentation

String add ( MCElement  e  )  [protected]

Add an element to the cache

Parameters:
e the element to add
Returns:
the message response string

String append ( MCElement  element  )  [protected]

Append bytes to an element in the cache

Parameters:
element the element to append to
Returns:
the message response string

String cas ( Long  cas_key,
MCElement  e 
) [protected]

Check and set an element in the cache

Parameters:
cas_key the unique cas id for the element, to match against
e the element to set
Returns:
the message response string

the message response string

String delete ( String  key,
int  time 
) [protected]

Handle the deletion of an item from the cache.

Parameters:
key the key for the item
time only delete the element if time (time in seconds)
Returns:
the message response

void exceptionCaught ( IoSession  session,
Throwable  cause 
) throws CharacterCodingException

Triggered when an exception is caught by the protocol handler

Parameters:
session the MINA session
cause the exception

String flush_all ( int  expire  )  [protected]

Flush all cache entries with a timestamp after a given expiration time

Parameters:
expire the flush time in seconds
Returns:
command response

boolean flush_all (  )  [protected]

Flush all cache entries

Returns:
command response

MCElement get ( String  key  )  [protected]

Get an element from the cache

Parameters:
key the key for the element to lookup
Returns:
the element, or 'null' in case of cache miss.

String get_add ( String  key,
int  mod 
) [protected]

Increment an (integer) element in the cache

Parameters:
key the key to increment
mod the amount to add to the value
Returns:
the message response

String getDeleteResponseString ( Cache.DeleteResponse  deleteResponse  )  [private]

String getStoreResponseString ( Cache.StoreResponse  storeResponse  )  [protected]

Find the string response message which is equivalent to a response to a set/add/replace message in the cache

Parameters:
storeResponse the response code
Returns:
the string to output on the network

void initStats (  )  [protected]

Initialize all statistic counters

boolean is_there ( String  key  )  [protected]

Check whether an element is in the cache and non-expired

Parameters:
key the key for the element to lookup
Returns:
whether the element is in the cache and is live

void messageReceived ( IoSession  session,
Object  message 
) throws CharacterCodingException

Handle the reception of an inbound command, which has already been pre-processed by the CommandDecoder.

Parameters:
session the MINA session
message the message itself
Exceptions:
CharacterCodingException 

void messageSent ( IoSession  session,
Object  message 
)

Called on message delivery.

Parameters:
session the MINA session
message the message sent

final int Now (  )  [protected]

Returns:
the current time in seconds (from epoch), used for expiries, etc.

String prepend ( MCElement  element  )  [protected]

Prepend bytes to an element in the cache

Parameters:
element the element to append to
Returns:
the message response string

String replace ( MCElement  e  )  [protected]

Replace an element in the cache

Parameters:
e the element to replace
Returns:
the message response string

void sessionClosed ( IoSession  session  ) 

Handle the closing of a session.

Parameters:
session the MINA session object

void sessionCreated ( IoSession  session  ) 

Handle the creation of a new protocol session.

Parameters:
session the MINA session object

void sessionIdle ( IoSession  session,
IdleStatus  status 
)

Triggered when a session has gone idle.

Parameters:
session the MINA session
status the idle status

void sessionOpened ( IoSession  session  ) 

Handle the opening of a new session.

Parameters:
session the MINA session object

String set ( MCElement  e  )  [protected]

Set an element in the cache

Parameters:
e the element to set
Returns:
the message response string

String stat ( String  arg  )  [protected]

Return runtime statistics

Parameters:
arg additional arguments to the stats command
Returns:
the full command response


Member Data Documentation

long bytes_read [static]

long bytes_written [static]

Cache cache [protected]

long curr_bytes [static]

CharsetEncoder ENCODER = Charset.forName("US-ASCII").newEncoder() [static]

final Logger logger = LoggerFactory.getLogger(ServerSessionHandler.class) [package]

int started

boolean verbose


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