Search in sources :

Example 16 with ChunkedWriteHandler

use of org.apache.flink.shaded.netty4.io.netty.handler.stream.ChunkedWriteHandler in project duangframework by tcrct.

the class RpcChannelInitializer method initChannel.

@Override
protected void initChannel(SocketChannel ch) throws Exception {
    ChannelPipeline p = ch.pipeline();
    // 将 RPC 请求进行解码(为了处理请求)
    p.addLast(new NettyDecoder());
    // // 将 RPC 响应进行编码(为了返回响应)
    p.addLast(new NettyEncoder());
    // 目的是支持异步大文件传输
    p.addLast(new ChunkedWriteHandler());
    p.addLast(new IdleStateHandler(60, 0, 0));
    // 真正处理RPC业务逻辑的地方
    p.addLast(new NettyServiceHandler());
}
Also used : ChunkedWriteHandler(io.netty.handler.stream.ChunkedWriteHandler) NettyEncoder(com.duangframework.rpc.common.NettyEncoder) IdleStateHandler(io.netty.handler.timeout.IdleStateHandler) NettyDecoder(com.duangframework.rpc.common.NettyDecoder) NettyServiceHandler(com.duangframework.rpc.handler.NettyServiceHandler) ChannelPipeline(io.netty.channel.ChannelPipeline)

Example 17 with ChunkedWriteHandler

use of org.apache.flink.shaded.netty4.io.netty.handler.stream.ChunkedWriteHandler in project duangframework by tcrct.

the class ClientChannelInitializer method initChannel.

@Override
protected void initChannel(SocketChannel ch) throws Exception {
    ChannelPipeline p = ch.pipeline();
    // 将 RPC 请求进行解码(为了处理请求)
    p.addLast(new NettyDecoder());
    // // 将 RPC 响应进行编码(为了返回响应)
    p.addLast(new NettyEncoder());
    // 目的是支持异步大文件传输
    p.addLast(new ChunkedWriteHandler());
    p.addLast(new IdleStateHandler(60, 0, 0));
    // 真正处理RPC业务逻辑的地方
    p.addLast(new NettyClientHandler());
}
Also used : ChunkedWriteHandler(io.netty.handler.stream.ChunkedWriteHandler) NettyEncoder(com.duangframework.rpc.common.NettyEncoder) IdleStateHandler(io.netty.handler.timeout.IdleStateHandler) NettyDecoder(com.duangframework.rpc.common.NettyDecoder) NettyClientHandler(com.duangframework.rpc.handler.NettyClientHandler) ChannelPipeline(io.netty.channel.ChannelPipeline)

Example 18 with ChunkedWriteHandler

use of org.apache.flink.shaded.netty4.io.netty.handler.stream.ChunkedWriteHandler in project component-runtime by Talend.

the class ProxyInitializer method initChannel.

@Override
protected void initChannel(final SocketChannel channel) {
    final ChannelPipeline pipeline = channel.pipeline();
    pipeline.addLast("logging", new LoggingHandler(LogLevel.valueOf(api.getLogLevel()))).addLast("http-decoder", new HttpRequestDecoder()).addLast("http-encoder", new HttpResponseEncoder()).addLast("http-keepalive", new HttpServerKeepAliveHandler()).addLast("aggregator", new HttpObjectAggregator(Integer.MAX_VALUE)).addLast("chunked-writer", new ChunkedWriteHandler()).addLast("talend-junit-api-server", newHandler());
}
Also used : HttpResponseEncoder(io.netty.handler.codec.http.HttpResponseEncoder) HttpObjectAggregator(io.netty.handler.codec.http.HttpObjectAggregator) LoggingHandler(io.netty.handler.logging.LoggingHandler) ChunkedWriteHandler(io.netty.handler.stream.ChunkedWriteHandler) HttpRequestDecoder(io.netty.handler.codec.http.HttpRequestDecoder) HttpServerKeepAliveHandler(io.netty.handler.codec.http.HttpServerKeepAliveHandler) ChannelPipeline(io.netty.channel.ChannelPipeline)

Example 19 with ChunkedWriteHandler

use of org.apache.flink.shaded.netty4.io.netty.handler.stream.ChunkedWriteHandler in project netty by netty.

the class Http2StaticFileServerInitializer method initChannel.

@Override
public void initChannel(SocketChannel ch) {
    ChannelPipeline pipeline = ch.pipeline();
    pipeline.addLast(sslCtx.newHandler(ch.alloc()));
    pipeline.addLast(Http2FrameCodecBuilder.forServer().build());
    pipeline.addLast(new ChunkedWriteHandler());
    pipeline.addLast(new Http2StaticFileServerHandler());
}
Also used : ChunkedWriteHandler(io.netty.handler.stream.ChunkedWriteHandler) ChannelPipeline(io.netty.channel.ChannelPipeline)

Example 20 with ChunkedWriteHandler

use of org.apache.flink.shaded.netty4.io.netty.handler.stream.ChunkedWriteHandler in project netty by netty.

the class FileServer method main.

public static void main(String[] args) throws Exception {
    // Configure SSL.
    final SslContext sslCtx;
    if (SSL) {
        SelfSignedCertificate ssc = new SelfSignedCertificate();
        sslCtx = SslContextBuilder.forServer(ssc.certificate(), ssc.privateKey()).build();
    } else {
        sslCtx = null;
    }
    // Configure the server.
    EventLoopGroup bossGroup = new NioEventLoopGroup(1);
    EventLoopGroup workerGroup = new NioEventLoopGroup();
    try {
        ServerBootstrap b = new ServerBootstrap();
        b.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class).option(ChannelOption.SO_BACKLOG, 100).handler(new LoggingHandler(LogLevel.INFO)).childHandler(new ChannelInitializer<SocketChannel>() {

            @Override
            public void initChannel(SocketChannel ch) throws Exception {
                ChannelPipeline p = ch.pipeline();
                if (sslCtx != null) {
                    p.addLast(sslCtx.newHandler(ch.alloc()));
                }
                p.addLast(new StringEncoder(CharsetUtil.UTF_8), new LineBasedFrameDecoder(8192), new StringDecoder(CharsetUtil.UTF_8), new ChunkedWriteHandler(), new FileServerHandler());
            }
        });
        // Start the server.
        ChannelFuture f = b.bind(PORT).sync();
        // Wait until the server socket is closed.
        f.channel().closeFuture().sync();
    } finally {
        // Shut down all event loops to terminate all threads.
        bossGroup.shutdownGracefully();
        workerGroup.shutdownGracefully();
    }
}
Also used : ChannelFuture(io.netty.channel.ChannelFuture) NioServerSocketChannel(io.netty.channel.socket.nio.NioServerSocketChannel) SocketChannel(io.netty.channel.socket.SocketChannel) LoggingHandler(io.netty.handler.logging.LoggingHandler) SelfSignedCertificate(io.netty.handler.ssl.util.SelfSignedCertificate) NioServerSocketChannel(io.netty.channel.socket.nio.NioServerSocketChannel) LineBasedFrameDecoder(io.netty.handler.codec.LineBasedFrameDecoder) StringDecoder(io.netty.handler.codec.string.StringDecoder) ServerBootstrap(io.netty.bootstrap.ServerBootstrap) ChannelPipeline(io.netty.channel.ChannelPipeline) StringEncoder(io.netty.handler.codec.string.StringEncoder) EventLoopGroup(io.netty.channel.EventLoopGroup) NioEventLoopGroup(io.netty.channel.nio.NioEventLoopGroup) ChunkedWriteHandler(io.netty.handler.stream.ChunkedWriteHandler) NioEventLoopGroup(io.netty.channel.nio.NioEventLoopGroup) SslContext(io.netty.handler.ssl.SslContext)

Aggregations

ChunkedWriteHandler (io.netty.handler.stream.ChunkedWriteHandler)46 ChannelPipeline (io.netty.channel.ChannelPipeline)24 HttpObjectAggregator (io.netty.handler.codec.http.HttpObjectAggregator)16 HttpServerCodec (io.netty.handler.codec.http.HttpServerCodec)11 SslHandler (io.netty.handler.ssl.SslHandler)10 HttpRequestDecoder (io.netty.handler.codec.http.HttpRequestDecoder)9 ByteBuf (io.netty.buffer.ByteBuf)8 SocketChannel (io.netty.channel.socket.SocketChannel)8 HttpResponseEncoder (io.netty.handler.codec.http.HttpResponseEncoder)8 LoggingHandler (io.netty.handler.logging.LoggingHandler)8 EmbeddedChannel (io.netty.channel.embedded.EmbeddedChannel)7 IdleStateHandler (io.netty.handler.timeout.IdleStateHandler)7 ServerBootstrap (io.netty.bootstrap.ServerBootstrap)6 NioEventLoopGroup (io.netty.channel.nio.NioEventLoopGroup)6 NioServerSocketChannel (io.netty.channel.socket.nio.NioServerSocketChannel)5 IOException (java.io.IOException)5 ChannelFuture (io.netty.channel.ChannelFuture)4 ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)4 HttpClientCodec (io.netty.handler.codec.http.HttpClientCodec)4 HttpContentDecompressor (io.netty.handler.codec.http.HttpContentDecompressor)4