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());
}
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());
}
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());
}
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());
}
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();
}
}
Aggregations