net.tomp2p.rpc
Class RequestHandlerTCP<K extends FutureResponse>

java.lang.Object
  extended by org.jboss.netty.channel.SimpleChannelHandler
      extended by net.tomp2p.rpc.RequestHandlerTCP<K>
All Implemented Interfaces:
org.jboss.netty.channel.ChannelDownstreamHandler, org.jboss.netty.channel.ChannelHandler, org.jboss.netty.channel.ChannelUpstreamHandler

public class RequestHandlerTCP<K extends FutureResponse>
extends org.jboss.netty.channel.SimpleChannelHandler

Is able to send TCP messages (as a request) and processes incoming replies. It is important that this class handles close() because if we shutdown the connections, the we need to notify the futures. In case of error set the peer to offline. A similar class is RequestHandlerUDP, which is used for UDP.

Author:
Thomas Bocek

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.jboss.netty.channel.ChannelHandler
org.jboss.netty.channel.ChannelHandler.Sharable
 
Constructor Summary
RequestHandlerTCP(K futureResponse, PeerBean peerBean, ConnectionBean connectionBean, Message message)
           
 
Method Summary
 void channelClosed(org.jboss.netty.channel.ChannelHandlerContext ctx, org.jboss.netty.channel.ChannelStateEvent e)
           
 void exceptionCaught(org.jboss.netty.channel.ChannelHandlerContext ctx, org.jboss.netty.channel.ExceptionEvent e)
           
 K fireAndForgetTCP(ChannelCreator channelCreator)
           
 K fireAndForgetTCP(ChannelCreator channelCreator, int idleTCPMillis)
           
 K getFutureResponse()
           
protected  PeerMap getPeerMap()
           
 void messageReceived(org.jboss.netty.channel.ChannelHandlerContext ctx, org.jboss.netty.channel.MessageEvent e)
           
 K sendTCP(ChannelCreator channelCreator)
           
 K sendTCP(ChannelCreator channelCreator, int idleTCPMillis)
           
 void setKeepAlive(boolean isKeepAlive)
           
 
Methods inherited from class org.jboss.netty.channel.SimpleChannelHandler
bindRequested, channelBound, channelConnected, channelDisconnected, channelInterestChanged, channelOpen, channelUnbound, childChannelClosed, childChannelOpen, closeRequested, connectRequested, disconnectRequested, handleDownstream, handleUpstream, setInterestOpsRequested, unbindRequested, writeComplete, writeRequested
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RequestHandlerTCP

public RequestHandlerTCP(K futureResponse,
                         PeerBean peerBean,
                         ConnectionBean connectionBean,
                         Message message)
Parameters:
objectHolder - the bean representing the node this handler belongs to
Method Detail

getFutureResponse

public K getFutureResponse()

sendTCP

public K sendTCP(ChannelCreator channelCreator)

sendTCP

public K sendTCP(ChannelCreator channelCreator,
                 int idleTCPMillis)

fireAndForgetTCP

public K fireAndForgetTCP(ChannelCreator channelCreator)

fireAndForgetTCP

public K fireAndForgetTCP(ChannelCreator channelCreator,
                          int idleTCPMillis)

getPeerMap

protected PeerMap getPeerMap()

setKeepAlive

public void setKeepAlive(boolean isKeepAlive)

exceptionCaught

public void exceptionCaught(org.jboss.netty.channel.ChannelHandlerContext ctx,
                            org.jboss.netty.channel.ExceptionEvent e)
Overrides:
exceptionCaught in class org.jboss.netty.channel.SimpleChannelHandler

messageReceived

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

channelClosed

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


Copyright © 2013. All Rights Reserved.