org.jboss.netty.handler.timeout.IdleStateHandler Java Examples
The following examples show how to use
org.jboss.netty.handler.timeout.IdleStateHandler.
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: RPCPipelineFactory.java From floodlight_with_topoguard with Apache License 2.0 | 6 votes |
@Override public ChannelPipeline getPipeline() throws Exception { RPCChannelHandler channelHandler = new RPCChannelHandler(syncManager, rpcService); IdleStateHandler idleHandler = new IdleStateHandler(timer, 5, 10, 0); ReadTimeoutHandler readTimeoutHandler = new ReadTimeoutHandler(timer, 30); ChannelPipeline pipeline = Channels.pipeline(); pipeline.addLast("idle", idleHandler); pipeline.addLast("timeout", readTimeoutHandler); pipeline.addLast("handshaketimeout", new HandshakeTimeoutHandler(channelHandler, timer, 10)); pipeline.addLast("frameDecoder", new ThriftFrameDecoder(maxFrameSize)); pipeline.addLast("frameEncoder", new ThriftFrameEncoder()); pipeline.addLast("handler", channelHandler); return pipeline; }
Example #2
Source File: ControllerConnector.java From FlowSpaceFirewall with Apache License 2.0 | 6 votes |
/** * creates a new pipeline for interacting with the * controller. This is where the controllerHandler and * the timeouthandler come into play * @return the pipeline (ChannelPipeline) for a new Socket. */ private ChannelPipeline getPipeline(){ ChannelPipeline pipe = Channels.pipeline(); ChannelHandler idleHandler = new IdleStateHandler(timer, 20, 25, 0); ChannelHandler readTimeoutHandler = new ReadTimeoutHandler(timer, 30); OFControllerChannelHandler controllerHandler = new OFControllerChannelHandler(); pipe.addLast("ofmessagedecoder", new OFMessageDecoder()); pipe.addLast("ofmessageencoder", new OFMessageEncoder()); pipe.addLast("idle", idleHandler); pipe.addLast("timeout", readTimeoutHandler); pipe.addLast("handshaketimeout", new ControllerHandshakeTimeoutHandler(controllerHandler, timer, 15)); pipe.addLast("handler", controllerHandler); return pipe; }
Example #3
Source File: Portmap.java From hadoop with Apache License 2.0 | 5 votes |
void start(final int idleTimeMilliSeconds, final SocketAddress tcpAddress, final SocketAddress udpAddress) { tcpServer = new ServerBootstrap(new NioServerSocketChannelFactory( Executors.newCachedThreadPool(), Executors.newCachedThreadPool())); tcpServer.setPipelineFactory(new ChannelPipelineFactory() { private final HashedWheelTimer timer = new HashedWheelTimer(); private final IdleStateHandler idleStateHandler = new IdleStateHandler( timer, 0, 0, idleTimeMilliSeconds, TimeUnit.MILLISECONDS); @Override public ChannelPipeline getPipeline() throws Exception { return Channels.pipeline(RpcUtil.constructRpcFrameDecoder(), RpcUtil.STAGE_RPC_MESSAGE_PARSER, idleStateHandler, handler, RpcUtil.STAGE_RPC_TCP_RESPONSE); } }); udpServer = new ConnectionlessBootstrap(new NioDatagramChannelFactory( Executors.newCachedThreadPool())); udpServer.setPipeline(Channels.pipeline(RpcUtil.STAGE_RPC_MESSAGE_PARSER, handler, RpcUtil.STAGE_RPC_UDP_RESPONSE)); tcpChannel = tcpServer.bind(tcpAddress); udpChannel = udpServer.bind(udpAddress); allChannels.add(tcpChannel); allChannels.add(udpChannel); LOG.info("Portmap server started at tcp://" + tcpChannel.getLocalAddress() + ", udp://" + udpChannel.getLocalAddress()); }
Example #4
Source File: Portmap.java From big-c with Apache License 2.0 | 5 votes |
void start(final int idleTimeMilliSeconds, final SocketAddress tcpAddress, final SocketAddress udpAddress) { tcpServer = new ServerBootstrap(new NioServerSocketChannelFactory( Executors.newCachedThreadPool(), Executors.newCachedThreadPool())); tcpServer.setPipelineFactory(new ChannelPipelineFactory() { private final HashedWheelTimer timer = new HashedWheelTimer(); private final IdleStateHandler idleStateHandler = new IdleStateHandler( timer, 0, 0, idleTimeMilliSeconds, TimeUnit.MILLISECONDS); @Override public ChannelPipeline getPipeline() throws Exception { return Channels.pipeline(RpcUtil.constructRpcFrameDecoder(), RpcUtil.STAGE_RPC_MESSAGE_PARSER, idleStateHandler, handler, RpcUtil.STAGE_RPC_TCP_RESPONSE); } }); udpServer = new ConnectionlessBootstrap(new NioDatagramChannelFactory( Executors.newCachedThreadPool())); udpServer.setPipeline(Channels.pipeline(RpcUtil.STAGE_RPC_MESSAGE_PARSER, handler, RpcUtil.STAGE_RPC_UDP_RESPONSE)); tcpChannel = tcpServer.bind(tcpAddress); udpChannel = udpServer.bind(udpAddress); allChannels.add(tcpChannel); allChannels.add(udpChannel); LOG.info("Portmap server started at tcp://" + tcpChannel.getLocalAddress() + ", udp://" + udpChannel.getLocalAddress()); }
Example #5
Source File: OpenflowPipelineFactory.java From floodlight_with_topoguard with Apache License 2.0 | 5 votes |
public OpenflowPipelineFactory(Controller controller, ThreadPoolExecutor pipelineExecutor) { super(); this.controller = controller; this.pipelineExecutor = pipelineExecutor; this.timer = new HashedWheelTimer(); this.idleHandler = new IdleStateHandler(timer, 20, 25, 0); this.readTimeoutHandler = new ReadTimeoutHandler(timer, 30); }
Example #6
Source File: FpmManager.java From onos with Apache License 2.0 | 5 votes |
private void startServer() { HashedWheelTimer timer = new HashedWheelTimer( groupedThreads("onos/fpm", "fpm-timer-%d", log)); ChannelFactory channelFactory = new NioServerSocketChannelFactory( newCachedThreadPool(groupedThreads("onos/fpm", "sm-boss-%d", log)), newCachedThreadPool(groupedThreads("onos/fpm", "sm-worker-%d", log))); ChannelPipelineFactory pipelineFactory = () -> { // Allocate a new session per connection IdleStateHandler idleHandler = new IdleStateHandler(timer, IDLE_TIMEOUT_SECS, 0, 0); FpmSessionHandler fpmSessionHandler = new FpmSessionHandler(this, new InternalFpmListener()); FpmFrameDecoder fpmFrameDecoder = new FpmFrameDecoder(); // Setup the processing pipeline ChannelPipeline pipeline = Channels.pipeline(); pipeline.addLast("FpmFrameDecoder", fpmFrameDecoder); pipeline.addLast("idle", idleHandler); pipeline.addLast("FpmSession", fpmSessionHandler); return pipeline; }; InetSocketAddress listenAddress = new InetSocketAddress(FPM_PORT); serverBootstrap = new ServerBootstrap(channelFactory); serverBootstrap.setOption("child.reuseAddr", true); serverBootstrap.setOption("child.keepAlive", true); serverBootstrap.setOption("child.tcpNoDelay", true); serverBootstrap.setPipelineFactory(pipelineFactory); try { serverChannel = serverBootstrap.bind(listenAddress); allChannels.add(serverChannel); } catch (ChannelException e) { log.debug("Exception binding to FPM port {}: ", listenAddress.getPort(), e); stopServer(); } }
Example #7
Source File: ShuffleHandler.java From tez with Apache License 2.0 | 5 votes |
public HttpPipelineFactory(Configuration conf, Timer timer) throws Exception { SHUFFLE = getShuffle(conf); if (conf.getBoolean(SHUFFLE_SSL_ENABLED_KEY, SHUFFLE_SSL_ENABLED_DEFAULT)) { LOG.info("Encrypted shuffle is enabled."); sslFactory = new SSLFactory(SSLFactory.Mode.SERVER, conf); sslFactory.init(); } this.idleStateHandler = new IdleStateHandler(timer, 0, connectionKeepAliveTimeOut, 0); }
Example #8
Source File: IMAPServer.java From james-project with Apache License 2.0 | 4 votes |
@Override protected ChannelPipelineFactory createPipelineFactory(final ChannelGroup group) { return new ChannelPipelineFactory() { private final ChannelGroupHandler groupHandler = new ChannelGroupHandler(group); private final HashedWheelTimer timer = new HashedWheelTimer(); private final TimeUnit timeoutUnit = TimeUnit.SECONDS; @Override public ChannelPipeline getPipeline() throws Exception { ChannelPipeline pipeline = pipeline(); pipeline.addLast(GROUP_HANDLER, groupHandler); pipeline.addLast("idleHandler", new IdleStateHandler(timer, 0, 0, timeout, timeoutUnit)); pipeline.addLast(TIMEOUT_HANDLER, new ImapIdleStateHandler()); pipeline.addLast(CONNECTION_LIMIT_HANDLER, new ConnectionLimitUpstreamHandler(IMAPServer.this.connectionLimit)); pipeline.addLast(CONNECTION_LIMIT_PER_IP_HANDLER, new ConnectionPerIpLimitUpstreamHandler(IMAPServer.this.connPerIP)); // Add the text line decoder which limit the max line length, // don't strip the delimiter and use CRLF as delimiter // Use a SwitchableDelimiterBasedFrameDecoder, see JAMES-1436 pipeline.addLast(FRAMER, getFrameHandlerFactory().create(pipeline)); Encryption secure = getEncryption(); if (secure != null && !secure.isStartTLS()) { // We need to set clientMode to false. // See https://issues.apache.org/jira/browse/JAMES-1025 SSLEngine engine = secure.getContext().createSSLEngine(); engine.setUseClientMode(false); pipeline.addFirst(SSL_HANDLER, new SslHandler(engine)); } pipeline.addLast(CONNECTION_COUNT_HANDLER, getConnectionCountHandler()); pipeline.addLast(CHUNK_WRITE_HANDLER, new ChunkedWriteHandler()); ExecutionHandler ehandler = getExecutionHandler(); if (ehandler != null) { pipeline.addLast(EXECUTION_HANDLER, ehandler); } pipeline.addLast(REQUEST_DECODER, new ImapRequestFrameDecoder(decoder, inMemorySizeLimit, literalSizeLimit)); pipeline.addLast(CORE_HANDLER, createCoreHandler()); return pipeline; } }; }
Example #9
Source File: PcepChannelHandler.java From onos with Apache License 2.0 | 4 votes |
@Override void processPcepMessage(PcepChannelHandler h, PcepMessage m) throws IOException, PcepParseException { log.info("Message received in KEEPWAIT state"); //check for keep alive message if (m.getType() != PcepType.KEEP_ALIVE) { // When the message type is not keep alive message increment the wrong packet statistics h.processUnknownMsg(); log.error("Message is not KEEPALIVE message"); } else { // Set the client connected status h.pcepPacketStats.addInPacket(); log.debug("sending keep alive message in KEEPWAIT state"); h.pc = h.controller.getPcepClientInstance(h.thispccId, h.sessionId, h.pcepVersion, h.pcepPacketStats); //Get pc instance and set capabilities h.pc.setCapability(h.capability); // Initilialize DB sync status. h.pc.setLspDbSyncStatus(NOT_SYNCED); h.pc.setLabelDbSyncStatus(NOT_SYNCED); // set the status of pcc as connected h.pc.setConnected(true); h.pc.setChannel(h.channel); // set any other specific parameters to the pcc h.pc.setPcVersion(h.pcepVersion); h.pc.setPcSessionId(h.sessionId); h.pc.setPcKeepAliveTime(h.keepAliveTime); h.pc.setPcDeadTime(h.deadTime); int keepAliveTimer = h.keepAliveTime & BYTE_MASK; int deadTimer = h.deadTime & BYTE_MASK; if (0 == h.keepAliveTime) { h.deadTime = 0; } // handle keep alive and dead time if (keepAliveTimer != PcepPipelineFactory.DEFAULT_KEEP_ALIVE_TIME || deadTimer != PcepPipelineFactory.DEFAULT_DEAD_TIME) { h.channel.getPipeline().replace("idle", "idle", new IdleStateHandler(PcepPipelineFactory.TIMER, deadTimer, keepAliveTimer, 0)); } log.debug("Dead timer : " + deadTimer); log.debug("Keep alive time : " + keepAliveTimer); //set the state handshake completion. h.sendKeepAliveMessage(); h.pcepPacketStats.addOutPacket(); h.setHandshakeComplete(true); if (!h.pc.connectClient()) { disconnectDuplicate(h); } else { h.setState(ESTABLISHED); h.controller.peerStatus(h.peerAddr.toString(), PcepCfg.State.ESTABLISHED.toString(), h.sessionId); //Session is established, add a network configuration with LSR id and device capabilities. h.addNode(); } } }
Example #10
Source File: PcepPipelineFactory.java From onos with Apache License 2.0 | 4 votes |
public PcepPipelineFactory(Controller controller) { super(); this.controller = controller; this.idleHandler = new IdleStateHandler(TIMER, DEFAULT_DEAD_TIME, DEFAULT_KEEP_ALIVE_TIME, 0); this.readTimeoutHandler = new ReadTimeoutHandler(TIMER, DEFAULT_WAIT_TIME); }
Example #11
Source File: CommonHttpPipeline.java From zuul-netty with Apache License 2.0 | 4 votes |
public CommonHttpPipeline(Timer timer) { this.idleStateHandler = new IdleStateHandler(timer, IDLE_TIMEOUT_READER, IDLE_TIMEOUT_WRITER, IDLE_TIMEOUT_BOTH); this.outboundConnectionPool = new CommonsConnectionPool(timer, OUTBOUND_CHANNEL_FACTORY); }
Example #12
Source File: HttpOutboundPipeline.java From zuul-netty with Apache License 2.0 | 4 votes |
public HttpOutboundPipeline (Timer timer) { IDLE_STATE_HANDLER = new IdleStateHandler(timer, IDLE_TIMEOUT_READER, IDLE_TIMEOUT_WRITER, IDLE_TIMEOUT_BOTH); }
Example #13
Source File: MockEndpoint.java From zuul-netty with Apache License 2.0 | 4 votes |
public MockEndpoint() { IDLE_STATE_HANDLER = new IdleStateHandler(TIMER, IDLE_TIMEOUT_READER, IDLE_TIMEOUT_WRITER, IDLE_TIMEOUT_BOTH); }
Example #14
Source File: UdpWorker.java From parallec with Apache License 2.0 | 3 votes |
/** * Instantiates a new my pipeline factory. * * @param timer * the timer * @param udpWorker * the udp worker */ public UdpPipelineFactory(Timer timer, UdpWorker udpWorker) { this.udpWorker = udpWorker; this.idleStateHandler = new IdleStateHandler(timer, 0, 0, udpWorker.udpMeta.getUdpIdleTimeoutSec()); this.myIdleHandler = new MyIdleHandler(udpWorker); }
Example #15
Source File: TcpWorker.java From parallec with Apache License 2.0 | 2 votes |
/** * Instantiates a new my pipeline factory. * * @param timer the timer * @param tcpWorker the tcp worker * @param idleTimeoutSec the idle timeout sec */ public MyPipelineFactory(Timer timer, TcpWorker tcpWorker, int idleTimeoutSec) { this.tcpWorker = tcpWorker; this.idleStateHandler = new IdleStateHandler(timer, 0, 0, idleTimeoutSec); this.myIdleHandler = new MyIdleHandler(tcpWorker); }