com.thimbleware.jmemcached.protocol
Class MemcachedCommandHandler<CACHE_ELEMENT extends CacheElement>
java.lang.Object
org.jboss.netty.channel.SimpleChannelUpstreamHandler
com.thimbleware.jmemcached.protocol.MemcachedCommandHandler<CACHE_ELEMENT>
- All Implemented Interfaces:
- org.jboss.netty.channel.ChannelHandler, org.jboss.netty.channel.ChannelUpstreamHandler
@ChannelHandler.Sharable
public final class MemcachedCommandHandler<CACHE_ELEMENT extends CacheElement>
- extends org.jboss.netty.channel.SimpleChannelUpstreamHandler
The actual command handler, which is responsible for processing the CommandMessage instances
that are inbound from the protocol decoders.
One instance is shared among the entire pipeline, since this handler is stateless, apart from some globals
for the entire daemon.
The command handler produces ResponseMessages which are destined for the response encoder.
| Nested classes/interfaces inherited from interface org.jboss.netty.channel.ChannelHandler |
org.jboss.netty.channel.ChannelHandler.Sharable |
|
Field Summary |
java.util.concurrent.atomic.AtomicInteger |
curr_conns
|
int |
idle_limit
|
java.util.concurrent.atomic.AtomicInteger |
total_conns
|
boolean |
verbose
|
java.lang.String |
version
The following state variables are universal for the entire daemon. |
|
Constructor Summary |
MemcachedCommandHandler(Cache cache,
java.lang.String memcachedVersion,
boolean verbosity,
int idle,
org.jboss.netty.channel.group.DefaultChannelGroup channelGroup)
Construct the server session handler |
|
Method Summary |
void |
channelClosed(org.jboss.netty.channel.ChannelHandlerContext channelHandlerContext,
org.jboss.netty.channel.ChannelStateEvent channelStateEvent)
On close we manage some statistics, and remove this connection from the channel group. |
void |
channelOpen(org.jboss.netty.channel.ChannelHandlerContext channelHandlerContext,
org.jboss.netty.channel.ChannelStateEvent channelStateEvent)
On open we manage some statistics, and add this connection to the channel group. |
protected void |
handleAdd(org.jboss.netty.channel.ChannelHandlerContext channelHandlerContext,
CommandMessage<CACHE_ELEMENT> command,
org.jboss.netty.channel.Channel channel)
|
protected void |
handleAppend(org.jboss.netty.channel.ChannelHandlerContext channelHandlerContext,
CommandMessage<CACHE_ELEMENT> command,
org.jboss.netty.channel.Channel channel)
|
protected void |
handleCas(org.jboss.netty.channel.ChannelHandlerContext channelHandlerContext,
CommandMessage<CACHE_ELEMENT> command,
org.jboss.netty.channel.Channel channel)
|
protected void |
handleDecr(org.jboss.netty.channel.ChannelHandlerContext channelHandlerContext,
CommandMessage<CACHE_ELEMENT> command,
org.jboss.netty.channel.Channel channel)
|
protected void |
handleDelete(org.jboss.netty.channel.ChannelHandlerContext channelHandlerContext,
CommandMessage<CACHE_ELEMENT> command,
org.jboss.netty.channel.Channel channel)
|
protected void |
handleFlush(org.jboss.netty.channel.ChannelHandlerContext channelHandlerContext,
CommandMessage<CACHE_ELEMENT> command,
org.jboss.netty.channel.Channel channel)
|
protected void |
handleGets(org.jboss.netty.channel.ChannelHandlerContext channelHandlerContext,
CommandMessage<CACHE_ELEMENT> command,
org.jboss.netty.channel.Channel channel)
|
protected void |
handleIncr(org.jboss.netty.channel.ChannelHandlerContext channelHandlerContext,
CommandMessage<CACHE_ELEMENT> command,
org.jboss.netty.channel.Channel channel)
|
protected void |
handleNoOp(org.jboss.netty.channel.ChannelHandlerContext channelHandlerContext,
CommandMessage<CACHE_ELEMENT> command)
|
protected void |
handlePrepend(org.jboss.netty.channel.ChannelHandlerContext channelHandlerContext,
CommandMessage<CACHE_ELEMENT> command,
org.jboss.netty.channel.Channel channel)
|
protected void |
handleQuit(org.jboss.netty.channel.Channel channel)
|
protected void |
handleReplace(org.jboss.netty.channel.ChannelHandlerContext channelHandlerContext,
CommandMessage<CACHE_ELEMENT> command,
org.jboss.netty.channel.Channel channel)
|
protected void |
handleSet(org.jboss.netty.channel.ChannelHandlerContext channelHandlerContext,
CommandMessage<CACHE_ELEMENT> command,
org.jboss.netty.channel.Channel channel)
|
protected void |
handleStats(org.jboss.netty.channel.ChannelHandlerContext channelHandlerContext,
CommandMessage<CACHE_ELEMENT> command,
int cmdKeysSize,
org.jboss.netty.channel.Channel channel)
|
protected void |
handleVerbosity(org.jboss.netty.channel.ChannelHandlerContext channelHandlerContext,
CommandMessage command,
org.jboss.netty.channel.Channel channel)
|
protected void |
handleVersion(org.jboss.netty.channel.ChannelHandlerContext channelHandlerContext,
CommandMessage<CACHE_ELEMENT> command,
org.jboss.netty.channel.Channel channel)
|
void |
messageReceived(org.jboss.netty.channel.ChannelHandlerContext channelHandlerContext,
org.jboss.netty.channel.MessageEvent messageEvent)
The actual meat of the matter. |
| Methods inherited from class org.jboss.netty.channel.SimpleChannelUpstreamHandler |
channelBound, channelConnected, channelDisconnected, channelInterestChanged, channelUnbound, childChannelClosed, childChannelOpen, exceptionCaught, handleUpstream, writeComplete |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
curr_conns
public final java.util.concurrent.atomic.AtomicInteger curr_conns
total_conns
public final java.util.concurrent.atomic.AtomicInteger total_conns
version
public final java.lang.String version
- The following state variables are universal for the entire daemon. These are used for statistics gathering.
In order for these values to work properly, the handler _must_ be declared with a ChannelPipelineCoverage
of "all".
idle_limit
public final int idle_limit
verbose
public final boolean verbose
MemcachedCommandHandler
public MemcachedCommandHandler(Cache cache,
java.lang.String memcachedVersion,
boolean verbosity,
int idle,
org.jboss.netty.channel.group.DefaultChannelGroup channelGroup)
- Construct the server session handler
- Parameters:
cache - the cache to usememcachedVersion - the version string to return to clientsverbosity - verbosity level for debuggingidle - how long sessions can be idle forchannelGroup -
channelOpen
public void channelOpen(org.jboss.netty.channel.ChannelHandlerContext channelHandlerContext,
org.jboss.netty.channel.ChannelStateEvent channelStateEvent)
throws java.lang.Exception
- On open we manage some statistics, and add this connection to the channel group.
- Overrides:
channelOpen in class org.jboss.netty.channel.SimpleChannelUpstreamHandler
- Parameters:
channelHandlerContext - channelStateEvent -
- Throws:
java.lang.Exception
channelClosed
public void channelClosed(org.jboss.netty.channel.ChannelHandlerContext channelHandlerContext,
org.jboss.netty.channel.ChannelStateEvent channelStateEvent)
throws java.lang.Exception
- On close we manage some statistics, and remove this connection from the channel group.
- Overrides:
channelClosed in class org.jboss.netty.channel.SimpleChannelUpstreamHandler
- Parameters:
channelHandlerContext - channelStateEvent -
- Throws:
java.lang.Exception
messageReceived
public void messageReceived(org.jboss.netty.channel.ChannelHandlerContext channelHandlerContext,
org.jboss.netty.channel.MessageEvent messageEvent)
throws java.lang.Exception
- The actual meat of the matter. Turn CommandMessages into executions against the physical cache, and then
pass on the downstream messages.
- Overrides:
messageReceived in class org.jboss.netty.channel.SimpleChannelUpstreamHandler
- Parameters:
channelHandlerContext - messageEvent -
- Throws:
java.lang.Exception
handleNoOp
protected void handleNoOp(org.jboss.netty.channel.ChannelHandlerContext channelHandlerContext,
CommandMessage<CACHE_ELEMENT> command)
handleFlush
protected void handleFlush(org.jboss.netty.channel.ChannelHandlerContext channelHandlerContext,
CommandMessage<CACHE_ELEMENT> command,
org.jboss.netty.channel.Channel channel)
handleVerbosity
protected void handleVerbosity(org.jboss.netty.channel.ChannelHandlerContext channelHandlerContext,
CommandMessage command,
org.jboss.netty.channel.Channel channel)
handleQuit
protected void handleQuit(org.jboss.netty.channel.Channel channel)
handleVersion
protected void handleVersion(org.jboss.netty.channel.ChannelHandlerContext channelHandlerContext,
CommandMessage<CACHE_ELEMENT> command,
org.jboss.netty.channel.Channel channel)
handleStats
protected void handleStats(org.jboss.netty.channel.ChannelHandlerContext channelHandlerContext,
CommandMessage<CACHE_ELEMENT> command,
int cmdKeysSize,
org.jboss.netty.channel.Channel channel)
handleDelete
protected void handleDelete(org.jboss.netty.channel.ChannelHandlerContext channelHandlerContext,
CommandMessage<CACHE_ELEMENT> command,
org.jboss.netty.channel.Channel channel)
handleDecr
protected void handleDecr(org.jboss.netty.channel.ChannelHandlerContext channelHandlerContext,
CommandMessage<CACHE_ELEMENT> command,
org.jboss.netty.channel.Channel channel)
handleIncr
protected void handleIncr(org.jboss.netty.channel.ChannelHandlerContext channelHandlerContext,
CommandMessage<CACHE_ELEMENT> command,
org.jboss.netty.channel.Channel channel)
handlePrepend
protected void handlePrepend(org.jboss.netty.channel.ChannelHandlerContext channelHandlerContext,
CommandMessage<CACHE_ELEMENT> command,
org.jboss.netty.channel.Channel channel)
handleAppend
protected void handleAppend(org.jboss.netty.channel.ChannelHandlerContext channelHandlerContext,
CommandMessage<CACHE_ELEMENT> command,
org.jboss.netty.channel.Channel channel)
handleReplace
protected void handleReplace(org.jboss.netty.channel.ChannelHandlerContext channelHandlerContext,
CommandMessage<CACHE_ELEMENT> command,
org.jboss.netty.channel.Channel channel)
handleAdd
protected void handleAdd(org.jboss.netty.channel.ChannelHandlerContext channelHandlerContext,
CommandMessage<CACHE_ELEMENT> command,
org.jboss.netty.channel.Channel channel)
handleCas
protected void handleCas(org.jboss.netty.channel.ChannelHandlerContext channelHandlerContext,
CommandMessage<CACHE_ELEMENT> command,
org.jboss.netty.channel.Channel channel)
handleSet
protected void handleSet(org.jboss.netty.channel.ChannelHandlerContext channelHandlerContext,
CommandMessage<CACHE_ELEMENT> command,
org.jboss.netty.channel.Channel channel)
handleGets
protected void handleGets(org.jboss.netty.channel.ChannelHandlerContext channelHandlerContext,
CommandMessage<CACHE_ELEMENT> command,
org.jboss.netty.channel.Channel channel)
Copyright © 2008-2011 ThimbleWare. All Rights Reserved.