GigaSpaces XAP 9.0 API

org.openspaces.memcached.protocol
Class MemcachedCommandHandler

java.lang.Object
  extended by org.jboss.netty.channel.SimpleChannelUpstreamHandler
      extended by org.openspaces.memcached.protocol.MemcachedCommandHandler
All Implemented Interfaces:
org.jboss.netty.channel.ChannelHandler, org.jboss.netty.channel.ChannelUpstreamHandler

@ChannelHandler.Sharable
public final class MemcachedCommandHandler
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 Class Summary
 
Nested classes/interfaces inherited from interface org.jboss.netty.channel.ChannelHandler
org.jboss.netty.channel.ChannelHandler.Sharable
 
Field Summary
 AtomicInteger curr_conns
           
 int idle_limit
           
protected static Log logger
           
 AtomicInteger total_conns
           
 boolean verbose
           
 String version
          The following state variables are universal for the entire daemon.
 
Constructor Summary
MemcachedCommandHandler(SpaceCache cache, 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 command, org.jboss.netty.channel.Channel channel)
           
protected  void handleAppend(org.jboss.netty.channel.ChannelHandlerContext channelHandlerContext, CommandMessage command, org.jboss.netty.channel.Channel channel)
           
protected  void handleCas(org.jboss.netty.channel.ChannelHandlerContext channelHandlerContext, CommandMessage command, org.jboss.netty.channel.Channel channel)
           
protected  void handleDecr(org.jboss.netty.channel.ChannelHandlerContext channelHandlerContext, CommandMessage command, org.jboss.netty.channel.Channel channel)
           
protected  void handleDelete(org.jboss.netty.channel.ChannelHandlerContext channelHandlerContext, CommandMessage command, org.jboss.netty.channel.Channel channel)
           
protected  void handleFlush(org.jboss.netty.channel.ChannelHandlerContext channelHandlerContext, CommandMessage command, org.jboss.netty.channel.Channel channel)
           
protected  void handleGets(org.jboss.netty.channel.ChannelHandlerContext channelHandlerContext, CommandMessage command, org.jboss.netty.channel.Channel channel)
           
protected  void handleIncr(org.jboss.netty.channel.ChannelHandlerContext channelHandlerContext, CommandMessage command, org.jboss.netty.channel.Channel channel)
           
protected  void handleNoOp(org.jboss.netty.channel.ChannelHandlerContext channelHandlerContext, CommandMessage command)
           
protected  void handlePrepend(org.jboss.netty.channel.ChannelHandlerContext channelHandlerContext, CommandMessage 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 command, org.jboss.netty.channel.Channel channel)
           
protected  void handleSet(org.jboss.netty.channel.ChannelHandlerContext channelHandlerContext, CommandMessage command, org.jboss.netty.channel.Channel channel)
           
protected  void handleStats(org.jboss.netty.channel.ChannelHandlerContext channelHandlerContext, CommandMessage 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 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
 

Field Detail

logger

protected static final Log logger

curr_conns

public final AtomicInteger curr_conns

total_conns

public final AtomicInteger total_conns

version

public final 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
Constructor Detail

MemcachedCommandHandler

public MemcachedCommandHandler(SpaceCache cache,
                               String memcachedVersion,
                               boolean verbosity,
                               int idle,
                               org.jboss.netty.channel.group.DefaultChannelGroup channelGroup)
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
channelGroup -
Method Detail

channelOpen

public void channelOpen(org.jboss.netty.channel.ChannelHandlerContext channelHandlerContext,
                        org.jboss.netty.channel.ChannelStateEvent channelStateEvent)
                 throws 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:
Exception

channelClosed

public void channelClosed(org.jboss.netty.channel.ChannelHandlerContext channelHandlerContext,
                          org.jboss.netty.channel.ChannelStateEvent channelStateEvent)
                   throws 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:
Exception

messageReceived

public void messageReceived(org.jboss.netty.channel.ChannelHandlerContext channelHandlerContext,
                            org.jboss.netty.channel.MessageEvent messageEvent)
                     throws 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:
Exception

handleNoOp

protected void handleNoOp(org.jboss.netty.channel.ChannelHandlerContext channelHandlerContext,
                          CommandMessage command)

handleFlush

protected void handleFlush(org.jboss.netty.channel.ChannelHandlerContext channelHandlerContext,
                           CommandMessage 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 command,
                             org.jboss.netty.channel.Channel channel)

handleStats

protected void handleStats(org.jboss.netty.channel.ChannelHandlerContext channelHandlerContext,
                           CommandMessage command,
                           int cmdKeysSize,
                           org.jboss.netty.channel.Channel channel)

handleDelete

protected void handleDelete(org.jboss.netty.channel.ChannelHandlerContext channelHandlerContext,
                            CommandMessage command,
                            org.jboss.netty.channel.Channel channel)

handleDecr

protected void handleDecr(org.jboss.netty.channel.ChannelHandlerContext channelHandlerContext,
                          CommandMessage command,
                          org.jboss.netty.channel.Channel channel)

handleIncr

protected void handleIncr(org.jboss.netty.channel.ChannelHandlerContext channelHandlerContext,
                          CommandMessage command,
                          org.jboss.netty.channel.Channel channel)

handlePrepend

protected void handlePrepend(org.jboss.netty.channel.ChannelHandlerContext channelHandlerContext,
                             CommandMessage command,
                             org.jboss.netty.channel.Channel channel)

handleAppend

protected void handleAppend(org.jboss.netty.channel.ChannelHandlerContext channelHandlerContext,
                            CommandMessage command,
                            org.jboss.netty.channel.Channel channel)

handleReplace

protected void handleReplace(org.jboss.netty.channel.ChannelHandlerContext channelHandlerContext,
                             CommandMessage command,
                             org.jboss.netty.channel.Channel channel)

handleAdd

protected void handleAdd(org.jboss.netty.channel.ChannelHandlerContext channelHandlerContext,
                         CommandMessage command,
                         org.jboss.netty.channel.Channel channel)

handleCas

protected void handleCas(org.jboss.netty.channel.ChannelHandlerContext channelHandlerContext,
                         CommandMessage command,
                         org.jboss.netty.channel.Channel channel)

handleSet

protected void handleSet(org.jboss.netty.channel.ChannelHandlerContext channelHandlerContext,
                         CommandMessage command,
                         org.jboss.netty.channel.Channel channel)

handleGets

protected void handleGets(org.jboss.netty.channel.ChannelHandlerContext channelHandlerContext,
                          CommandMessage command,
                          org.jboss.netty.channel.Channel channel)

GigaSpaces XAP 9.0 API

Copyright © GigaSpaces.