|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.thimbleware.jmemcached.ServerSessionHandler
public final class ServerSessionHandler
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.
| Field Summary | |
|---|---|
static long |
bytes_read
|
static long |
bytes_written
|
protected Cache |
cache
|
static long |
curr_bytes
|
int |
curr_conns
|
static java.nio.charset.CharsetEncoder |
ENCODER
|
int |
idle_limit
|
int |
started
|
int |
total_conns
|
boolean |
verbose
|
java.lang.String |
version
|
| Constructor Summary | |
|---|---|
ServerSessionHandler(Cache cache,
java.lang.String memcachedVersion,
boolean verbosity,
int idle)
Construct the server session handler |
|
| Method Summary | |
|---|---|
protected java.lang.String |
add(MCElement e)
Add an element to the cache |
protected java.lang.String |
delete(java.lang.String key,
int time)
Handle the deletion of an item from the cache. |
void |
exceptionCaught(org.apache.mina.common.IoSession session,
java.lang.Throwable cause)
Triggered when an exception is caught by the protocol handler |
protected boolean |
flush_all()
Flush all cache entries |
protected java.lang.String |
flush_all(int expire)
Flush all cache entries with a timestamp after a given expiration time |
protected java.lang.String |
get_add(java.lang.String key,
int mod)
Increment an (integer) element inthe cache |
protected MCElement |
get(java.lang.String key)
Get an element from the cache |
protected void |
initStats()
Initialize all statistic counters |
protected boolean |
is_there(java.lang.String key)
Check whether an element is in the cache and non-expired |
void |
messageReceived(org.apache.mina.common.IoSession session,
java.lang.Object message)
Handle the reception of an inbound command, which has already been pre-processed by the CommandDecoder. |
void |
messageSent(org.apache.mina.common.IoSession session,
java.lang.Object message)
Called on message delivery. |
protected int |
Now()
|
protected java.lang.String |
replace(MCElement e)
Replace an element in the cache |
void |
sessionClosed(org.apache.mina.common.IoSession session)
Handle the closing of a session. |
void |
sessionCreated(org.apache.mina.common.IoSession session)
Handle the creation of a new protocol session. |
void |
sessionIdle(org.apache.mina.common.IoSession session,
org.apache.mina.common.IdleStatus status)
Triggered when a session has gone idle. |
void |
sessionOpened(org.apache.mina.common.IoSession session)
Handle the opening of a new session. |
protected java.lang.String |
set(MCElement e)
Set an element in the cache |
protected java.lang.String |
stat(java.lang.String arg)
Return runtime statistics |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public java.lang.String version
public int curr_conns
public int total_conns
public int started
public static long bytes_read
public static long bytes_written
public static long curr_bytes
public int idle_limit
public boolean verbose
public static java.nio.charset.CharsetEncoder ENCODER
protected Cache cache
| Constructor Detail |
|---|
public ServerSessionHandler(Cache cache,
java.lang.String memcachedVersion,
boolean verbosity,
int idle)
cache - the cache to usememcachedVersion - the version string to return to clientsverbosity - verbosity level for debuggingidle - how long sessions can be idle for| Method Detail |
|---|
public void sessionCreated(org.apache.mina.common.IoSession session)
sessionCreated in interface org.apache.mina.common.IoHandlersession - the MINA session objectpublic void sessionOpened(org.apache.mina.common.IoSession session)
sessionOpened in interface org.apache.mina.common.IoHandlersession - the MINA session objectpublic void sessionClosed(org.apache.mina.common.IoSession session)
sessionClosed in interface org.apache.mina.common.IoHandlersession - the MINA session object
public void messageReceived(org.apache.mina.common.IoSession session,
java.lang.Object message)
throws java.nio.charset.CharacterCodingException
messageReceived in interface org.apache.mina.common.IoHandlersession - the MINA sessionmessage - the message itself
java.nio.charset.CharacterCodingException
public void messageSent(org.apache.mina.common.IoSession session,
java.lang.Object message)
messageSent in interface org.apache.mina.common.IoHandlersession - the MINA sessionmessage - the message sent
public void sessionIdle(org.apache.mina.common.IoSession session,
org.apache.mina.common.IdleStatus status)
sessionIdle in interface org.apache.mina.common.IoHandlersession - the MINA sessionstatus - the idle status
public void exceptionCaught(org.apache.mina.common.IoSession session,
java.lang.Throwable cause)
exceptionCaught in interface org.apache.mina.common.IoHandlersession - the MINA sessioncause - the exception
protected java.lang.String delete(java.lang.String key,
int time)
key - the key for the itemtime - only delete the element if time (time in seconds)
protected java.lang.String add(MCElement e)
e - the element to add
protected java.lang.String replace(MCElement e)
e - the element to replace
protected java.lang.String set(MCElement e)
e - the element to set
protected java.lang.String get_add(java.lang.String key,
int mod)
key - the key to incrementmod - the amount to add to the value
protected boolean is_there(java.lang.String key)
key - the key for the element to lookup
protected MCElement get(java.lang.String key)
key - the key for the element to lookup
protected final int Now()
protected void initStats()
protected java.lang.String stat(java.lang.String arg)
arg - additional arguments to the stats command
protected boolean flush_all()
protected java.lang.String flush_all(int expire)
expire - the flush time in seconds
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||