Example usage for io.netty.handler.timeout IdleStateEvent isFirst

List of usage examples for io.netty.handler.timeout IdleStateEvent isFirst

Introduction

In this page you can find the example usage for io.netty.handler.timeout IdleStateEvent isFirst.

Prototype

public boolean isFirst() 

Source Link

Document

Returns true if this was the first event for the IdleState

Usage

From source file:com.linecorp.armeria.internal.IdleTimeoutHandler.java

License:Apache License

@Override
protected final void channelIdle(ChannelHandlerContext ctx, IdleStateEvent evt) throws Exception {
    if (!evt.isFirst()) {
        return;//from w w w . j  ava2s .c  o m
    }

    if (!hasRequestsInProgress(ctx)) {
        logger.debug("{} Closing an idle {} connection", ctx.channel(), name);
        ctx.close();
    }
}

From source file:org.apache.tajo.rpc.MonitorClientHandler.java

License:Apache License

@Override
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
    if (enableMonitor && evt instanceof IdleStateEvent) {
        IdleStateEvent e = (IdleStateEvent) evt;
        if (e.state() == IdleState.READER_IDLE && !e.isFirst()) {
            /* trigger expired event */
            LOG.info("Server has not respond " + ctx.channel());
            ctx.fireUserEventTriggered(MonitorStateEvent.MONITOR_EXPIRED_STATE_EVENT);
        } else if (e.state() == IdleState.WRITER_IDLE) {
            /* send ping packet to remote server */
            if (LOG.isDebugEnabled()) {
                LOG.debug("sending ping request " + ctx.channel());
            }// www. j a v  a2s  . c  o  m
            ctx.writeAndFlush(ping.duplicate().retain());
        }
    }
    super.userEventTriggered(ctx, evt);
}

From source file:org.opendaylight.openflowjava.protocol.impl.core.IdleHandler.java

License:Open Source License

@Override
protected void channelIdle(ChannelHandlerContext ctx, IdleStateEvent evt) throws Exception {
    if ((evt.state() == IdleState.READER_IDLE) && (evt.isFirst())) {
        LOGGER.debug("Switch idle");
        SwitchIdleEventBuilder builder = new SwitchIdleEventBuilder();
        builder.setInfo("Switch idle");
        ctx.fireChannelRead(builder.build());
    }/*from  w  w w . j  a  va 2 s .c  o  m*/
}