
@ChannelPipelineCoverage(value="all") public class WriteTimeoutHandler extends SimpleChannelDownstreamHandler implements ExternalResourceReleasable
WriteTimeoutException when no data was written within a
certain period of time.
// An example configuration that implements 30-second write timeout:
ChannelPipeline p = ...;
Timer timer = new HashedWheelTimer();
p.addLast("timeout", new WriteTimeoutHandler(timer, 30));
p.addLast("handler", new MyHandler());
// To shut down, call releaseExternalResources() or Timer.stop().
ReadTimeoutHandler,
IdleStateHandler| Constructor and Description |
|---|
WriteTimeoutHandler(Timer timer,
int timeoutSeconds)
Creates a new instance.
|
WriteTimeoutHandler(Timer timer,
long timeout,
TimeUnit unit)
Creates a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
protected long |
getTimeoutMillis(MessageEvent e) |
void |
releaseExternalResources()
Stops the
Timer which was specified in the constructor of this
handler. |
void |
writeRequested(ChannelHandlerContext ctx,
MessageEvent e)
Invoked when
Channel.write(Object) is called. |
protected void |
writeTimedOut(ChannelHandlerContext ctx) |
bindRequested, closeRequested, connectRequested, disconnectRequested, handleDownstream, setInterestOpsRequested, unbindRequestedpublic WriteTimeoutHandler(Timer timer, int timeoutSeconds)
timer - the Timer that is used to trigger the scheduled event.
The recommended Timer implementation is HashedWheelTimer.timeoutSeconds - write timeout in secondspublic void releaseExternalResources()
Timer which was specified in the constructor of this
handler. You should not call this method if the Timer is in use
by other objects.releaseExternalResources in interface ExternalResourceReleasableprotected long getTimeoutMillis(MessageEvent e)
public void writeRequested(ChannelHandlerContext ctx, MessageEvent e) throws Exception
SimpleChannelDownstreamHandlerChannel.write(Object) is called.writeRequested in class SimpleChannelDownstreamHandlerExceptionprotected void writeTimedOut(ChannelHandlerContext ctx) throws Exception
ExceptionCopyright © 2008-2013 JBoss, by Red Hat. All Rights Reserved.