Search in sources :

Example 51 with IdleStateHandler

use of org.apache.flink.shaded.netty4.io.netty.handler.timeout.IdleStateHandler in project netty by netty.

the class UptimeClient method main.

public static void main(String[] args) throws Exception {
    EventLoopGroup group = new NioEventLoopGroup();
    bs.group(group).channel(NioSocketChannel.class).remoteAddress(HOST, PORT).handler(new ChannelInitializer<SocketChannel>() {

        @Override
        protected void initChannel(SocketChannel ch) throws Exception {
            ch.pipeline().addLast(new IdleStateHandler(READ_TIMEOUT, 0, 0), handler);
        }
    });
    bs.connect();
}
Also used : NioSocketChannel(io.netty.channel.socket.nio.NioSocketChannel) SocketChannel(io.netty.channel.socket.SocketChannel) EventLoopGroup(io.netty.channel.EventLoopGroup) NioEventLoopGroup(io.netty.channel.nio.NioEventLoopGroup) IdleStateHandler(io.netty.handler.timeout.IdleStateHandler) NioEventLoopGroup(io.netty.channel.nio.NioEventLoopGroup)

Example 52 with IdleStateHandler

use of org.apache.flink.shaded.netty4.io.netty.handler.timeout.IdleStateHandler in project netty by netty.

the class MqttHeartBeatClient method main.

public static void main(String[] args) throws Exception {
    EventLoopGroup workerGroup = new NioEventLoopGroup();
    try {
        Bootstrap b = new Bootstrap();
        b.group(workerGroup);
        b.channel(NioSocketChannel.class);
        b.handler(new ChannelInitializer<SocketChannel>() {

            protected void initChannel(SocketChannel ch) throws Exception {
                ch.pipeline().addLast("encoder", MqttEncoder.INSTANCE);
                ch.pipeline().addLast("decoder", new MqttDecoder());
                ch.pipeline().addLast("heartBeatHandler", new IdleStateHandler(0, 20, 0, TimeUnit.SECONDS));
                ch.pipeline().addLast("handler", new MqttHeartBeatClientHandler(CLIENT_ID, USER_NAME, PASSWORD));
            }
        });
        ChannelFuture f = b.connect(HOST, PORT).sync();
        System.out.println("Client connected");
        f.channel().closeFuture().sync();
    } finally {
        workerGroup.shutdownGracefully();
    }
}
Also used : ChannelFuture(io.netty.channel.ChannelFuture) NioSocketChannel(io.netty.channel.socket.nio.NioSocketChannel) SocketChannel(io.netty.channel.socket.SocketChannel) EventLoopGroup(io.netty.channel.EventLoopGroup) NioEventLoopGroup(io.netty.channel.nio.NioEventLoopGroup) MqttDecoder(io.netty.handler.codec.mqtt.MqttDecoder) IdleStateHandler(io.netty.handler.timeout.IdleStateHandler) Bootstrap(io.netty.bootstrap.Bootstrap) NioEventLoopGroup(io.netty.channel.nio.NioEventLoopGroup)

Example 53 with IdleStateHandler

use of org.apache.flink.shaded.netty4.io.netty.handler.timeout.IdleStateHandler in project LogHub by fbacchella.

the class Beats method addHandlers.

@Override
public void addHandlers(ChannelPipeline pipe) {
    super.addHandlers(pipe);
    // From org.logstash.beats.Server
    // We have set a specific executor for the idle check, because the `beatsHandler` can be
    // blocked on the queue, this the idleStateHandler manage the `KeepAlive` signal.
    pipe.addBefore(idleExecutorGroup, "Splitter", "KeepAlive", new IdleStateHandler(clientInactivityTimeoutSeconds, 5, 0));
    pipe.addAfter("Splitter", "Acker", new AckEncoder());
    pipe.addAfter("Acker", "Handler", new BeatsHandler(messageListener));
}
Also used : BeatsHandler(org.logstash.beats.BeatsHandler) IdleStateHandler(io.netty.handler.timeout.IdleStateHandler) AckEncoder(org.logstash.beats.AckEncoder)

Example 54 with IdleStateHandler

use of org.apache.flink.shaded.netty4.io.netty.handler.timeout.IdleStateHandler in project zuul by Netflix.

the class BaseZuulChannelInitializer method addTimeoutHandlers.

protected void addTimeoutHandlers(ChannelPipeline pipeline) {
    pipeline.addLast(new IdleStateHandler(0, 0, idleTimeout, TimeUnit.MILLISECONDS));
    pipeline.addLast(new CloseOnIdleStateHandler(registry, metricId));
}
Also used : CloseOnIdleStateHandler(com.netflix.netty.common.CloseOnIdleStateHandler) IdleStateHandler(io.netty.handler.timeout.IdleStateHandler) CloseOnIdleStateHandler(com.netflix.netty.common.CloseOnIdleStateHandler)

Example 55 with IdleStateHandler

use of org.apache.flink.shaded.netty4.io.netty.handler.timeout.IdleStateHandler in project zuul by Netflix.

the class DefaultClientChannelManager method releaseHandlers.

protected void releaseHandlers(PooledConnection conn) {
    final ChannelPipeline pipeline = conn.getChannel().pipeline();
    removeHandlerFromPipeline(OriginResponseReceiver.CHANNEL_HANDLER_NAME, pipeline);
    // The Outbound handler is always after the inbound handler, so look for it.
    ChannelHandlerContext passportStateHttpClientHandlerCtx = pipeline.context(PassportStateHttpClientHandler.OutboundHandler.class);
    pipeline.addAfter(passportStateHttpClientHandlerCtx.name(), IDLE_STATE_HANDLER_NAME, new IdleStateHandler(0, 0, connPoolConfig.getIdleTimeout(), TimeUnit.MILLISECONDS));
}
Also used : IdleStateHandler(io.netty.handler.timeout.IdleStateHandler) ChannelHandlerContext(io.netty.channel.ChannelHandlerContext) ChannelPipeline(io.netty.channel.ChannelPipeline) PassportStateHttpClientHandler(com.netflix.zuul.netty.insights.PassportStateHttpClientHandler)

Aggregations

IdleStateHandler (io.netty.handler.timeout.IdleStateHandler)61 ChannelPipeline (io.netty.channel.ChannelPipeline)29 SocketChannel (io.netty.channel.socket.SocketChannel)16 LoggingHandler (io.netty.handler.logging.LoggingHandler)15 NioSocketChannel (io.netty.channel.socket.nio.NioSocketChannel)12 SslHandler (io.netty.handler.ssl.SslHandler)11 ChunkedWriteHandler (io.netty.handler.stream.ChunkedWriteHandler)11 NioEventLoopGroup (io.netty.channel.nio.NioEventLoopGroup)10 EventLoopGroup (io.netty.channel.EventLoopGroup)8 NioServerSocketChannel (io.netty.channel.socket.nio.NioServerSocketChannel)8 HttpObjectAggregator (io.netty.handler.codec.http.HttpObjectAggregator)8 Bootstrap (io.netty.bootstrap.Bootstrap)7 ChannelFuture (io.netty.channel.ChannelFuture)7 ServerBootstrap (io.netty.bootstrap.ServerBootstrap)6 HttpServerCodec (io.netty.handler.codec.http.HttpServerCodec)6 InetSocketAddress (java.net.InetSocketAddress)6 StringDecoder (io.netty.handler.codec.string.StringDecoder)5 IdleStateEvent (io.netty.handler.timeout.IdleStateEvent)5 DefaultEventExecutorGroup (io.netty.util.concurrent.DefaultEventExecutorGroup)5 ThreadFactory (java.util.concurrent.ThreadFactory)5