org.sdnplatform.sync.internal.rpc
Class RPCChannelHandler

java.lang.Object
  extended by org.jboss.netty.channel.SimpleChannelHandler
      extended by org.jboss.netty.handler.timeout.IdleStateAwareChannelHandler
          extended by org.sdnplatform.sync.internal.rpc.AbstractRPCChannelHandler
              extended by org.sdnplatform.sync.internal.rpc.RPCChannelHandler
All Implemented Interfaces:
org.jboss.netty.channel.ChannelDownstreamHandler, org.jboss.netty.channel.ChannelHandler, org.jboss.netty.channel.ChannelUpstreamHandler

public class RPCChannelHandler
extends AbstractRPCChannelHandler

Channel handler for the RPC service

Author:
readams

Nested Class Summary
protected static class RPCChannelHandler.TVersionIterable
           
 
Nested classes/interfaces inherited from class org.sdnplatform.sync.internal.rpc.AbstractRPCChannelHandler
AbstractRPCChannelHandler.ChannelState
 
Nested classes/interfaces inherited from interface org.jboss.netty.channel.ChannelHandler
org.jboss.netty.channel.ChannelHandler.Sharable
 
Field Summary
protected  boolean isClientConnection
           
protected static org.slf4j.Logger logger
           
protected  Node remoteNode
           
protected  RPCService rpcService
           
protected  SyncManager syncManager
           
 
Fields inherited from class org.sdnplatform.sync.internal.rpc.AbstractRPCChannelHandler
channelState, currentChallenge
 
Constructor Summary
RPCChannelHandler(SyncManager syncManager, RPCService rpcService)
           
 
Method Summary
 void channelDisconnected(org.jboss.netty.channel.ChannelHandlerContext ctx, org.jboss.netty.channel.ChannelStateEvent e)
           
 void channelOpen(org.jboss.netty.channel.ChannelHandlerContext ctx, org.jboss.netty.channel.ChannelStateEvent e)
           
protected  AuthScheme getAuthScheme()
          Get the type of authentication to use for this connection
protected  SyncMessage getError(int transactionId, java.lang.Exception error, MessageType type)
          Generate an error message from the provided transaction ID and exception
protected  java.lang.Short getLocalNodeId()
          Get the node ID for the local node if appropriate
protected  java.lang.String getLocalNodeIdString()
          Get the node ID for the local node as a string for use output
protected  java.lang.Short getRemoteNodeId()
          Get the node ID for the remote node if its connected
protected  java.lang.String getRemoteNodeIdString()
          Get the node ID for the remote node if its connected as a string for use output
protected  byte[] getSharedSecret()
          Get a shared secret to be used for authentication handshake.
protected  int getTransactionId()
          Get a transaction ID suitable for sending an async message
protected  void handleClusterJoinRequest(ClusterJoinRequestMessage request, org.jboss.netty.channel.Channel channel)
           
protected  void handleCursorRequest(CursorRequestMessage request, org.jboss.netty.channel.Channel channel)
           
protected  void handleDeleteRequest(DeleteRequestMessage request, org.jboss.netty.channel.Channel channel)
           
protected  void handleError(ErrorMessage error, org.jboss.netty.channel.Channel channel)
           
protected  void handleFullSyncRequest(FullSyncRequestMessage request, org.jboss.netty.channel.Channel channel)
           
protected  void handleGetRequest(GetRequestMessage request, org.jboss.netty.channel.Channel channel)
           
protected  void handleHello(HelloMessage hello, org.jboss.netty.channel.Channel channel)
           
protected  void handlePutRequest(PutRequestMessage request, org.jboss.netty.channel.Channel channel)
           
protected  void handleRegisterRequest(RegisterRequestMessage request, org.jboss.netty.channel.Channel channel)
           
protected  void handleSyncOffer(SyncOfferMessage request, org.jboss.netty.channel.Channel channel)
           
protected  void handleSyncRequest(SyncRequestMessage request, org.jboss.netty.channel.Channel channel)
           
protected  void handleSyncValue(SyncValueMessage request, org.jboss.netty.channel.Channel channel)
           
protected  void handleSyncValueResponse(SyncValueResponseMessage message, org.jboss.netty.channel.Channel channel)
           
 void messageReceived(org.jboss.netty.channel.ChannelHandlerContext ctx, org.jboss.netty.channel.MessageEvent e)
           
protected  void startAntientropy()
           
protected  void updateCounter(IDebugCounter counter, int incr)
           
 
Methods inherited from class org.sdnplatform.sync.internal.rpc.AbstractRPCChannelHandler
channelConnected, channelIdle, error, exceptionCaught, handleClusterJoinResponse, handleCursorResponse, handleDeleteResponse, handleEchoRequest, handleGetResponse, handlePutResponse, handleRegisterResponse, handleSMAuthenticated, handleSyncMessage, handleUnknownMessage, handshake, handshakeChallengeResponse, unexpectedMessage
 
Methods inherited from class org.jboss.netty.handler.timeout.IdleStateAwareChannelHandler
handleUpstream
 
Methods inherited from class org.jboss.netty.channel.SimpleChannelHandler
bindRequested, channelBound, channelClosed, channelInterestChanged, channelUnbound, childChannelClosed, childChannelOpen, closeRequested, connectRequested, disconnectRequested, handleDownstream, setInterestOpsRequested, unbindRequested, writeComplete, writeRequested
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected static final org.slf4j.Logger logger

syncManager

protected SyncManager syncManager

rpcService

protected RPCService rpcService

remoteNode

protected Node remoteNode

isClientConnection

protected boolean isClientConnection
Constructor Detail

RPCChannelHandler

public RPCChannelHandler(SyncManager syncManager,
                         RPCService rpcService)
Method Detail

channelOpen

public void channelOpen(org.jboss.netty.channel.ChannelHandlerContext ctx,
                        org.jboss.netty.channel.ChannelStateEvent e)
                 throws java.lang.Exception
Overrides:
channelOpen in class org.jboss.netty.channel.SimpleChannelHandler
Throws:
java.lang.Exception

channelDisconnected

public void channelDisconnected(org.jboss.netty.channel.ChannelHandlerContext ctx,
                                org.jboss.netty.channel.ChannelStateEvent e)
                         throws java.lang.Exception
Overrides:
channelDisconnected in class org.jboss.netty.channel.SimpleChannelHandler
Throws:
java.lang.Exception

messageReceived

public void messageReceived(org.jboss.netty.channel.ChannelHandlerContext ctx,
                            org.jboss.netty.channel.MessageEvent e)
                     throws java.lang.Exception
Overrides:
messageReceived in class AbstractRPCChannelHandler
Throws:
java.lang.Exception

handleHello

protected void handleHello(HelloMessage hello,
                           org.jboss.netty.channel.Channel channel)
Overrides:
handleHello in class AbstractRPCChannelHandler

handleGetRequest

protected void handleGetRequest(GetRequestMessage request,
                                org.jboss.netty.channel.Channel channel)
Overrides:
handleGetRequest in class AbstractRPCChannelHandler

handlePutRequest

protected void handlePutRequest(PutRequestMessage request,
                                org.jboss.netty.channel.Channel channel)
Overrides:
handlePutRequest in class AbstractRPCChannelHandler

handleDeleteRequest

protected void handleDeleteRequest(DeleteRequestMessage request,
                                   org.jboss.netty.channel.Channel channel)
Overrides:
handleDeleteRequest in class AbstractRPCChannelHandler

handleSyncValue

protected void handleSyncValue(SyncValueMessage request,
                               org.jboss.netty.channel.Channel channel)
Overrides:
handleSyncValue in class AbstractRPCChannelHandler

handleSyncValueResponse

protected void handleSyncValueResponse(SyncValueResponseMessage message,
                                       org.jboss.netty.channel.Channel channel)
Overrides:
handleSyncValueResponse in class AbstractRPCChannelHandler

handleSyncOffer

protected void handleSyncOffer(SyncOfferMessage request,
                               org.jboss.netty.channel.Channel channel)
Overrides:
handleSyncOffer in class AbstractRPCChannelHandler

handleSyncRequest

protected void handleSyncRequest(SyncRequestMessage request,
                                 org.jboss.netty.channel.Channel channel)
Overrides:
handleSyncRequest in class AbstractRPCChannelHandler

handleFullSyncRequest

protected void handleFullSyncRequest(FullSyncRequestMessage request,
                                     org.jboss.netty.channel.Channel channel)
Overrides:
handleFullSyncRequest in class AbstractRPCChannelHandler

handleCursorRequest

protected void handleCursorRequest(CursorRequestMessage request,
                                   org.jboss.netty.channel.Channel channel)
Overrides:
handleCursorRequest in class AbstractRPCChannelHandler

handleRegisterRequest

protected void handleRegisterRequest(RegisterRequestMessage request,
                                     org.jboss.netty.channel.Channel channel)
Overrides:
handleRegisterRequest in class AbstractRPCChannelHandler

handleClusterJoinRequest

protected void handleClusterJoinRequest(ClusterJoinRequestMessage request,
                                        org.jboss.netty.channel.Channel channel)
Overrides:
handleClusterJoinRequest in class AbstractRPCChannelHandler

handleError

protected void handleError(ErrorMessage error,
                           org.jboss.netty.channel.Channel channel)
Overrides:
handleError in class AbstractRPCChannelHandler

getLocalNodeId

protected java.lang.Short getLocalNodeId()
Description copied from class: AbstractRPCChannelHandler
Get the node ID for the local node if appropriate

Specified by:
getLocalNodeId in class AbstractRPCChannelHandler
Returns:
the node ID. Null if this is a client

getRemoteNodeId

protected java.lang.Short getRemoteNodeId()
Description copied from class: AbstractRPCChannelHandler
Get the node ID for the remote node if its connected

Specified by:
getRemoteNodeId in class AbstractRPCChannelHandler
Returns:
the node ID

getLocalNodeIdString

protected java.lang.String getLocalNodeIdString()
Description copied from class: AbstractRPCChannelHandler
Get the node ID for the local node as a string for use output

Overrides:
getLocalNodeIdString in class AbstractRPCChannelHandler
Returns:
the node ID

getRemoteNodeIdString

protected java.lang.String getRemoteNodeIdString()
Description copied from class: AbstractRPCChannelHandler
Get the node ID for the remote node if its connected as a string for use output

Overrides:
getRemoteNodeIdString in class AbstractRPCChannelHandler
Returns:
the node ID

getTransactionId

protected int getTransactionId()
Description copied from class: AbstractRPCChannelHandler
Get a transaction ID suitable for sending an async message

Specified by:
getTransactionId in class AbstractRPCChannelHandler
Returns:
the unique transaction ID

getAuthScheme

protected AuthScheme getAuthScheme()
Description copied from class: AbstractRPCChannelHandler
Get the type of authentication to use for this connection

Specified by:
getAuthScheme in class AbstractRPCChannelHandler

getSharedSecret

protected byte[] getSharedSecret()
                          throws AuthException
Description copied from class: AbstractRPCChannelHandler
Get a shared secret to be used for authentication handshake. Throwing an exception will cause authentication to fail

Specified by:
getSharedSecret in class AbstractRPCChannelHandler
Returns:
the shared secret
Throws:
AuthException

getError

protected SyncMessage getError(int transactionId,
                               java.lang.Exception error,
                               MessageType type)
Description copied from class: AbstractRPCChannelHandler
Generate an error message from the provided transaction ID and exception

Overrides:
getError in class AbstractRPCChannelHandler
Parameters:
transactionId - the transaction Id
error - the exception
type - the type of the message that generated the error
Returns:
the SyncError message

updateCounter

protected void updateCounter(IDebugCounter counter,
                             int incr)

startAntientropy

protected void startAntientropy()