Java Code Examples for io.netty.handler.timeout.IdleStateEvent#ALL_IDLE_STATE_EVENT
The following examples show how to use
io.netty.handler.timeout.IdleStateEvent#ALL_IDLE_STATE_EVENT .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FastdfsHandler.java From azeroth with Apache License 2.0 | 6 votes |
@Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception { // read idle event. if (evt == IdleStateEvent.FIRST_READER_IDLE_STATE_EVENT || evt == IdleStateEvent.READER_IDLE_STATE_EVENT) { if (null != operation) { throw new FastdfsReadTimeoutException( String.format("execute %s read timeout.", operation)); } return; } // all idle event. if (evt == IdleStateEvent.FIRST_ALL_IDLE_STATE_EVENT || evt == IdleStateEvent.ALL_IDLE_STATE_EVENT) { throw new FastdfsTimeoutException("fastdfs channel was idle timeout."); } }
Example 2
Source File: FastdfsHandler.java From fastdfs-client with Apache License 2.0 | 6 votes |
@Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception { FastdfsOperation<?> operation = ctx.channel().attr(OPERATION_KEY).get(); // read idle event. if (evt == IdleStateEvent.FIRST_READER_IDLE_STATE_EVENT || evt == IdleStateEvent.READER_IDLE_STATE_EVENT) { if (null != operation) { throw new FastdfsReadTimeoutException( String.format( "execute %s read timeout.", operation ) ); } } // all idle event. if (evt == IdleStateEvent.FIRST_ALL_IDLE_STATE_EVENT || evt == IdleStateEvent.ALL_IDLE_STATE_EVENT) { throw new FastdfsTimeoutException("fastdfs channel was idle timeout."); } }
Example 3
Source File: IdleStateChecker.java From Jupiter with Apache License 2.0 | 5 votes |
@Override public void run(Timeout timeout) throws Exception { if (timeout.isCancelled() || !ctx.channel().isOpen()) { return; } long nextDelay = allIdleTimeMillis; if (!reading) { long lastIoTime = Math.max(lastReadTime, lastWriteTime); nextDelay -= SystemClock.millisClock().now() - lastIoTime; } if (nextDelay <= 0) { // Both reader and writer are idle - set a new timeout and // notify the callback. allIdleTimeout = timer.newTimeout(this, allIdleTimeMillis, TimeUnit.MILLISECONDS); try { IdleStateEvent event; if (firstAllIdleEvent) { firstAllIdleEvent = false; event = IdleStateEvent.FIRST_ALL_IDLE_STATE_EVENT; } else { event = IdleStateEvent.ALL_IDLE_STATE_EVENT; } channelIdle(ctx, event); } catch (Throwable t) { ctx.fireExceptionCaught(t); } } else { // Either read or write occurred before the timeout - set a new // timeout with shorter delay. allIdleTimeout = timer.newTimeout(this, nextDelay, TimeUnit.MILLISECONDS); } }