net.tomp2p.connection
Class ReplyTimeoutHandler

java.lang.Object
  extended by org.jboss.netty.channel.SimpleChannelHandler
      extended by net.tomp2p.connection.ReplyTimeoutHandler
All Implemented Interfaces:
org.jboss.netty.channel.ChannelDownstreamHandler, org.jboss.netty.channel.ChannelHandler, org.jboss.netty.channel.ChannelUpstreamHandler

public class ReplyTimeoutHandler
extends org.jboss.netty.channel.SimpleChannelHandler

Code inspired by Netty's TimeoutHandlers from Trustin Lee and adapted/extended to a reply timeout handler. Timer starts if write has been called and is reset if a read occurs afterwards. Since we initialize if the channel is open, a TCP timeout will also include the connection attempt.


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.jboss.netty.channel.ChannelHandler
org.jboss.netty.channel.ChannelHandler.Sharable
 
Constructor Summary
ReplyTimeoutHandler(org.jboss.netty.util.Timer timer, long timeoutMillis, PeerAddress remotePeer)
           
 
Method Summary
 void cancel()
           
 void channelOpen(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)
           
 void messageReceived(org.jboss.netty.channel.ChannelHandlerContext ctx, org.jboss.netty.channel.MessageEvent e)
           
 void writeComplete(org.jboss.netty.channel.ChannelHandlerContext ctx, org.jboss.netty.channel.WriteCompletionEvent e)
           
 
Methods inherited from class org.jboss.netty.channel.SimpleChannelHandler
bindRequested, channelBound, channelClosed, channelConnected, channelDisconnected, channelInterestChanged, channelUnbound, childChannelClosed, childChannelOpen, closeRequested, connectRequested, disconnectRequested, handleDownstream, handleUpstream, setInterestOpsRequested, unbindRequested, writeRequested
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReplyTimeoutHandler

public ReplyTimeoutHandler(org.jboss.netty.util.Timer timer,
                           long timeoutMillis,
                           PeerAddress remotePeer)
Method Detail

channelOpen

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

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

writeComplete

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

exceptionCaught

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

cancel

public void cancel()


Copyright © 2013. All Rights Reserved.