當前位置: 首頁>>代碼示例>>Java>>正文


Java IdleStateEvent類代碼示例

本文整理匯總了Java中org.jboss.netty.handler.timeout.IdleStateEvent的典型用法代碼示例。如果您正苦於以下問題:Java IdleStateEvent類的具體用法?Java IdleStateEvent怎麽用?Java IdleStateEvent使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


IdleStateEvent類屬於org.jboss.netty.handler.timeout包,在下文中一共展示了IdleStateEvent類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: channelIdle

import org.jboss.netty.handler.timeout.IdleStateEvent; //導入依賴的package包/類
@Override
public void channelIdle(ChannelHandlerContext ctx, IdleStateEvent e) throws Exception {
    if (!isHandshakeComplete()) {
        return;
    }

    if (e.getState() == IdleState.READER_IDLE) {
        // When no message is received on channel for read timeout, then close
        // the channel
        log.info("Disconnecting client {} due to read timeout", getClientInfoString());
        ctx.getChannel().close();
    } else if (e.getState() == IdleState.WRITER_IDLE) {
        // Send keep alive message
        log.debug("Sending keep alive message due to IdleState timeout " + pc.toString());
        pc.sendMessage(Collections.singletonList(pc.factory().buildKeepaliveMsg().build()));
    }
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:18,代碼來源:PcepChannelHandler.java

示例2: channelIdle

import org.jboss.netty.handler.timeout.IdleStateEvent; //導入依賴的package包/類
@Override
public void channelIdle(ChannelHandlerContext ctx, IdleStateEvent e) throws Exception {
    if (e.getState() == IdleState.WRITER_IDLE) {
        Channel channel = e.getChannel();
        if (channel != null) {
            //寫空閑  則發送心跳數據
            channel.write(Heartbeat.getSingleton());
        } else {
            logger.warn("writer idle on channel({}), but hsfChannel is not managed.", e.getChannel());
        }
    } else if (e.getState() == IdleState.READER_IDLE) {
        //讀空閑 則斷開連接
        logger.error("channel:{} is time out.", e.getChannel());
        handleUpstream(ctx, new DefaultExceptionEvent(e.getChannel(), new SocketTimeoutException(
            "force to close channel(" + ctx.getChannel().getRemoteAddress() + "), reason: time out.")));
        e.getChannel().close();
    }
    super.channelIdle(ctx, e);
}
 
開發者ID:sunguangran,項目名稱:navi,代碼行數:20,代碼來源:StateCheckChannelHandler.java

示例3: channelIdle

import org.jboss.netty.handler.timeout.IdleStateEvent; //導入依賴的package包/類
private void channelIdle(ChannelHandlerContext ctx, IdleStateEvent e) {
    if (e.getState() == IdleState.READER_IDLE) {
        Object a = ctx.getChannel().getAttachment();
        // connect/login timeout
        if (a == null || a instanceof ChannelFuture) {
            ctx.getChannel().close();
            return;
        }
        ChannelData d = (ChannelData)a;
        if (d.timer.elapsed() > TimeUnit.MILLISECONDS.convert(60, TimeUnit.SECONDS)) {
            ctx.getChannel().close();
        } else {
            ctx.sendDownstream(new DownstreamMessageEvent(ctx.getChannel(),
                    new DefaultChannelFuture(ctx.getChannel(), false), PING, null));
        }
    }
}
 
開發者ID:redbooth,項目名稱:jssmp,代碼行數:18,代碼來源:SSMPRequestDecoder.java

示例4: channelIdle

import org.jboss.netty.handler.timeout.IdleStateEvent; //導入依賴的package包/類
@Override
public void channelIdle(ChannelHandlerContext ctx, IdleStateEvent e) throws Exception {

    // check if the client did nothing for too long
    if (e.getState().equals(IdleState.ALL_IDLE)) {
        ImapSession session = (ImapSession) attributes.get(ctx.getChannel());
        InetSocketAddress address = (InetSocketAddress) ctx.getChannel().getRemoteAddress();

        session.getLog().info("Logout client " + address.getHostName() + " (" + address.getAddress().getHostAddress() + ") because it idled for too long...");

        // logout the client
        session.logout();

        // close the channel
        ctx.getChannel().close();

    }
    super.channelIdle(ctx, e);
}
 
開發者ID:twachan,項目名稱:James,代碼行數:20,代碼來源:ImapIdleStateHandler.java

示例5: channelIdle

import org.jboss.netty.handler.timeout.IdleStateEvent; //導入依賴的package包/類
@Override
public void channelIdle(ChannelHandlerContext ctx, IdleStateEvent e)
    throws Exception {
  if (e.getState() == IdleState.ALL_IDLE) {
    e.getChannel().close();
  }
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:8,代碼來源:RpcProgramPortmap.java

示例6: channelIdle

import org.jboss.netty.handler.timeout.IdleStateEvent; //導入依賴的package包/類
@Override
public void channelIdle(ChannelHandlerContext ctx, IdleStateEvent e)
        throws Exception {
    OFFactory factory = (ofVersion == OFVersion.OF_13) ? factory13 : factory10;
    OFMessage m = factory.buildEchoRequest().build();
    log.debug("Sending Echo Request on idle channel: {}",
            e.getChannel().getPipeline().getLast().toString());
    e.getChannel().write(Collections.singletonList(m));
    // XXX S some problems here -- echo request has no transaction id, and
    // echo reply is not correlated to the echo request.
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:12,代碼來源:OFChannelHandler.java

示例7: channelIdle

import org.jboss.netty.handler.timeout.IdleStateEvent; //導入依賴的package包/類
@Override
public void channelIdle(ChannelHandlerContext ctx,
                        IdleStateEvent e) throws Exception {
    // send an echo request
    EchoRequestMessage m = new EchoRequestMessage();
    AsyncMessageHeader header = new AsyncMessageHeader();
    header.setTransactionId(getTransactionId());
    m.setHeader(header);
    SyncMessage bsm = new SyncMessage(MessageType.ECHO_REQUEST);
    bsm.setEchoRequest(m);
    ctx.getChannel().write(bsm);
}
 
開發者ID:nsg-ethz,項目名稱:iTAP-controller,代碼行數:13,代碼來源:AbstractRPCChannelHandler.java

示例8: channelIdle

import org.jboss.netty.handler.timeout.IdleStateEvent; //導入依賴的package包/類
@Override
public void channelIdle(ChannelHandlerContext ctx, IdleStateEvent e)
		throws Exception {

	log.debug("channelIdle on OFChannelHandler {}", String.format("%08x", System.identityHashCode(this)));
	OFChannelHandler handler = ctx.getPipeline().get(OFChannelHandler.class);
	handler.sendEchoRequest();
}
 
開發者ID:nsg-ethz,項目名稱:iTAP-controller,代碼行數:9,代碼來源:OFChannelHandler.java

示例9: channelIdle

import org.jboss.netty.handler.timeout.IdleStateEvent; //導入依賴的package包/類
@Override
public void channelIdle(ChannelHandlerContext context, IdleStateEvent idleStateEvent) {
	final String remoteAddress = idleStateEvent.getChannel().getRemoteAddress().toString();

	idleStateEvent.getChannel().close().addListener(future -> {
		if (future.isSuccess()) {
			logger.debug("channel closed: {}", remoteAddress);
		} else {
			logger.debug("channel failed to close: {}", remoteAddress);
		}
	});
}
 
開發者ID:iceize,項目名稱:netty-http-3.x,代碼行數:13,代碼來源:HttpTimeoutHandler.java

示例10: channelIdle

import org.jboss.netty.handler.timeout.IdleStateEvent; //導入依賴的package包/類
@Override
public void channelIdle(ChannelHandlerContext ctx, IdleStateEvent e) throws Exception {
	 super.channelIdle(ctx, e);  

	 if(e.getState() == IdleState.ALL_IDLE) {
		 e.getChannel().close();
		 System.out.println("idle channel was closed!");
	 }
   }
 
開發者ID:tangaiyun,項目名稱:Netty-Resteasy-Spring,代碼行數:10,代碼來源:HealthCheckHandler.java

示例11: channelIdle

import org.jboss.netty.handler.timeout.IdleStateEvent; //導入依賴的package包/類
@Override
public void channelIdle(ChannelHandlerContext ctx, IdleStateEvent e) {
    logger.info("In IDLE event handler for TCP...");
    
    //there are 3 states. READER/WRITER/ALL
    if (e.getState() == IdleState.ALL_IDLE){
        int statusCodeInt = 0;
        String statusCode = statusCodeInt + " SUCCESSFUL";
        String errMsg="idleTimeout to finish";
        
        tcpWorker.onComplete(tcpWorker.responseSb.toString(), false, 
                errMsg, errMsg, statusCode, statusCodeInt);
    }
}
 
開發者ID:eBay,項目名稱:parallec,代碼行數:15,代碼來源:TcpWorker.java

示例12: channelIdle

import org.jboss.netty.handler.timeout.IdleStateEvent; //導入依賴的package包/類
/**
 * this case is like a read timeout where did not get anything from the
 * server for a long time.
 * 
 * For UDP need to mark as error
 * 
 * @see org.jboss.netty.handler.timeout.IdleStateAwareChannelHandler#channelIdle
 *      (org.jboss.netty.channel.ChannelHandlerContext,
 *      org.jboss.netty.handler.timeout.IdleStateEvent)
 */
@Override
public void channelIdle(ChannelHandlerContext ctx, IdleStateEvent e) {
    logger.debug("In IDLE event handler for UDP..timeout.");

    // there are 3 states. READER/WRITER/ALL
    if (e.getState() == IdleState.ALL_IDLE) {
        int statusCodeInt = 1;
        String statusCode = statusCodeInt + " FAILURE";
        String errMsg = "UDP idle (read) timeout";

        udpWorker.onComplete(udpWorker.responseSb.toString(), true,
                errMsg, errMsg, statusCode, statusCodeInt);
    }
}
 
開發者ID:eBay,項目名稱:parallec,代碼行數:25,代碼來源:UdpWorker.java

示例13: channelIdle

import org.jboss.netty.handler.timeout.IdleStateEvent; //導入依賴的package包/類
@Override
public void channelIdle(ChannelHandlerContext ctx, IdleStateEvent e)
        throws Exception {
    List<OFMessage> msglist = new ArrayList<OFMessage>(1);
    msglist.add(factory.getMessage(OFType.ECHO_REQUEST));
    e.getChannel().write(msglist);
}
 
開發者ID:vishalshubham,項目名稱:Multipath-Hedera-system-in-Floodlight-controller,代碼行數:8,代碼來源:Controller.java

示例14: handleUpstream

import org.jboss.netty.handler.timeout.IdleStateEvent; //導入依賴的package包/類
@Override
public void handleUpstream(ChannelHandlerContext ctx, ChannelEvent e) throws Exception {
    if (e instanceof IdleStateEvent) {
        channelIdle(ctx, (IdleStateEvent) e);
    } else {
        super.handleUpstream(ctx, e);
    }
}
 
開發者ID:redbooth,項目名稱:jssmp,代碼行數:9,代碼來源:SSMPResponseDecoder.java

示例15: channelIdle

import org.jboss.netty.handler.timeout.IdleStateEvent; //導入依賴的package包/類
public void channelIdle(ChannelHandlerContext ctx, IdleStateEvent e) {
    if (e.getState() == IdleState.READER_IDLE) {
        if (_timer.elapsed() > TimeUnit.MILLISECONDS.convert(60, TimeUnit.SECONDS)) {
            ctx.getChannel().close();
        } else {
            L.debug("send ping");
            ctx.sendDownstream(new DownstreamMessageEvent(ctx.getChannel(),
                    new DefaultChannelFuture(ctx.getChannel(), false), PING, null));
        }
    }
}
 
開發者ID:redbooth,項目名稱:jssmp,代碼行數:12,代碼來源:SSMPResponseDecoder.java


注:本文中的org.jboss.netty.handler.timeout.IdleStateEvent類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。