use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpObjectAggregator in project alien4cloud by alien4cloud.
the class StompConnection method init.
@SneakyThrows({ InterruptedException.class, URISyntaxException.class })
private void init() {
if (this.stompChannel != null) {
throw new IllegalStateException("The stomp connection has already been started");
}
String wsUrl = "ws://" + host + ":" + port + endPoint + "/websocket";
if (log.isDebugEnabled()) {
log.debug("Web socket url {}", wsUrl);
}
String loginUrl = null;
if (user != null && password != null && loginPath != null) {
loginUrl = "http://" + host + ":" + port + loginPath;
if (log.isDebugEnabled()) {
log.debug("Authentication url {}", loginUrl);
}
}
this.eventLoopGroup = new NioEventLoopGroup();
this.stompClientHandler = new StompClientHandler();
DefaultHttpHeaders handshakeHeaders = new DefaultHttpHeaders();
if (this.headers != null) {
for (Map.Entry<String, String> header : this.headers.entrySet()) {
handshakeHeaders.add(header.getKey(), header.getValue());
}
}
final WebSocketClientHandler webSocketHandler = new WebSocketClientHandler(WebSocketClientHandshakerFactory.newHandshaker(new URI(wsUrl), WebSocketVersion.V13, null, false, handshakeHeaders), host, user, password, loginUrl);
Bootstrap b = new Bootstrap();
b.group(eventLoopGroup).channel(NioSocketChannel.class);
b.handler(new ChannelInitializer<SocketChannel>() {
@Override
protected void initChannel(SocketChannel ch) throws Exception {
ChannelPipeline pipeline = ch.pipeline();
pipeline.addLast(HttpClientCodec.class.getName(), new HttpClientCodec());
pipeline.addLast(HttpObjectAggregator.class.getName(), new HttpObjectAggregator(8192));
pipeline.addLast(WebSocketClientCompressionHandler.class.getName(), new WebSocketClientCompressionHandler());
pipeline.addLast(WebSocketClientHandler.class.getName(), webSocketHandler);
pipeline.addLast(StompSubframeDecoder.class.getName(), new StompSubframeDecoder());
pipeline.addLast(StompSubframeEncoder.class.getName(), new StompSubframeEncoder());
pipeline.addLast(StompSubframeAggregator.class.getName(), new StompSubframeAggregator(1048576));
pipeline.addLast(StompClientHandler.class.getName(), stompClientHandler);
}
});
this.stompChannel = b.connect(host, port).sync().channel();
this.stompClientHandler.connectFuture(this.stompChannel.newPromise());
webSocketHandler.handshakeFuture().addListener(new ChannelFutureListener() {
@Override
public void operationComplete(final ChannelFuture future) throws Exception {
stompClientHandler.beginStomp(stompChannel);
}
});
}
use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpObjectAggregator 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.codec.http.HttpObjectAggregator in project neo4j by neo4j.
the class TransportSelectionHandler method switchToWebsocket.
private void switchToWebsocket(ChannelHandlerContext ctx) {
ChannelPipeline p = ctx.pipeline();
memoryTracker.allocateHeap(HTTP_SERVER_CODEC_SHALLOW_SIZE + HTTP_OBJECT_AGGREGATOR_SHALLOW_SIZE + WEB_SOCKET_SERVER_PROTOCOL_HANDLER_SHALLOW_SIZE + WEB_SOCKET_FRAME_AGGREGATOR_SHALLOW_SIZE + WebSocketFrameTranslator.SHALLOW_SIZE + ProtocolHandshaker.SHALLOW_SIZE);
p.addLast(new HttpServerCodec(), new HttpObjectAggregator(MAX_WEBSOCKET_HANDSHAKE_SIZE), new WebSocketServerProtocolHandler("/", null, false, MAX_WEBSOCKET_FRAME_SIZE), new WebSocketFrameAggregator(MAX_WEBSOCKET_FRAME_SIZE), new WebSocketFrameTranslator(), newHandshaker());
p.remove(this);
}
use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpObjectAggregator in project pinpoint by naver.
the class NettyIT method client.
public Bootstrap client(EventLoopGroup workerGroup) {
Bootstrap bootstrap = new Bootstrap();
bootstrap.group(workerGroup).channel(NioSocketChannel.class).handler(new ChannelInitializer<SocketChannel>() {
@Override
protected void initChannel(SocketChannel ch) throws Exception {
ch.pipeline().addLast(new HttpClientCodec());
ch.pipeline().addLast(new HttpObjectAggregator(65535));
}
});
return bootstrap;
}
use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpObjectAggregator in project netty by netty.
the class HttpProxyServer method configure.
@Override
protected void configure(SocketChannel ch) throws Exception {
ChannelPipeline p = ch.pipeline();
switch(testMode) {
case INTERMEDIARY:
p.addLast(new HttpServerCodec());
p.addLast(new HttpObjectAggregator(1));
p.addLast(new HttpIntermediaryHandler());
break;
case TERMINAL:
p.addLast(new HttpServerCodec());
p.addLast(new HttpObjectAggregator(1));
p.addLast(new HttpTerminalHandler());
break;
case UNRESPONSIVE:
p.addLast(UnresponsiveHandler.INSTANCE);
break;
}
}
Aggregations