use of org.jboss.netty.handler.codec.http.HttpContentCompressor in project weave by continuuity.
the class TrackerService method startUp.
@Override
protected void startUp() throws Exception {
Executor bossThreads = Executors.newFixedThreadPool(NUM_BOSS_THREADS, new ThreadFactoryBuilder().setDaemon(true).setNameFormat("boss-thread").build());
Executor workerThreads = Executors.newCachedThreadPool(new ThreadFactoryBuilder().setDaemon(true).setNameFormat("worker-thread#%d").build());
ChannelFactory factory = new NioServerSocketChannelFactory(bossThreads, workerThreads);
bootstrap = new ServerBootstrap(factory);
bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
public ChannelPipeline getPipeline() {
ChannelPipeline pipeline = Channels.pipeline();
pipeline.addLast("decoder", new HttpRequestDecoder());
pipeline.addLast("aggregator", new HttpChunkAggregator(MAX_INPUT_SIZE));
pipeline.addLast("encoder", new HttpResponseEncoder());
pipeline.addLast("compressor", new HttpContentCompressor());
pipeline.addLast("handler", new ReportHandler(resourceReport));
return pipeline;
}
});
Channel channel = bootstrap.bind(new InetSocketAddress(host, 0));
bindAddress = (InetSocketAddress) channel.getLocalAddress();
url = URI.create(String.format("http://%s:%d", host, bindAddress.getPort())).resolve(TrackerService.PATH).toURL();
channelGroup.add(channel);
}
use of org.jboss.netty.handler.codec.http.HttpContentCompressor in project camel by apache.
the class HttpServerSharedPipelineFactory method getPipeline.
@Override
public ChannelPipeline getPipeline() throws Exception {
// Create a default pipeline implementation.
ChannelPipeline pipeline = Channels.pipeline();
SslHandler sslHandler = configureServerSSLOnDemand();
if (sslHandler != null) {
LOG.debug("Server SSL handler configured and added as an interceptor against the ChannelPipeline: {}", sslHandler);
pipeline.addLast("ssl", sslHandler);
}
pipeline.addLast("decoder", new HttpRequestDecoder(4096, configuration.getMaxHeaderSize(), 8192));
if (configuration.isChunked()) {
pipeline.addLast("aggregator", new HttpChunkAggregator(configuration.getChunkedMaxContentLength()));
}
pipeline.addLast("encoder", new HttpResponseEncoder());
if (configuration.isCompression()) {
pipeline.addLast("deflater", new HttpContentCompressor());
}
pipeline.addLast("handler", channelFactory.getChannelHandler());
return pipeline;
}
use of org.jboss.netty.handler.codec.http.HttpContentCompressor in project databus by linkedin.
the class HttpServerPipelineFactory method getPipeline.
@Override
public ChannelPipeline getPipeline() throws Exception {
// TODO DDS-305: Rework the netty stats collector to use event-based stats aggregation
/* NettyStats nettyStats = _serverContainer.getNettyStats();
CallCompletion getPipelineCompletion = nettyStats.isEnabled() ?
nettyStats.getPipelineFactory_GetPipelineCallTracker().startCall() :
null;*/
// Create a default pipeline implementation.
ChannelPipeline pipeline = pipeline();
// pipeline.addLast("in traffic",
// new LoggingHandler("in traffic", InternalLogLevel.INFO, true));
pipeline.addLast("auto group register ", new ConnectionChannelRegistrationHandler(_serverContainer.getHttpChannelGroup()));
if (Logger.getRootLogger().isTraceEnabled()) {
pipeline.addLast("netty server traffic", new LoggingHandler("netty server traffic", InternalLogLevel.DEBUG, true));
}
pipeline.addLast("outbound statistics collector", new OutboundContainerStatisticsCollectingHandler(_serverContainer.getContainerStatsCollector()));
pipeline.addLast("decoder", new HttpRequestDecoder());
pipeline.addLast("encoder", new HttpResponseEncoder());
pipeline.addLast("http logger", new HttpRequestLoggingHandler());
ExtendedReadTimeoutHandler readTimeoutHandler = new ExtendedReadTimeoutHandler("server container " + _serverContainer.getContainerStaticConfig().getId(), _serverContainer.getNetworkTimeoutTimer(), _serverContainer.getContainerStaticConfig().getReadTimeoutMs(), true);
HttpRequestHandler reqHandler = new HttpRequestHandler(_serverContainer, readTimeoutHandler);
pipeline.addLast("handler", reqHandler);
if (_serverContainer.getContainerStaticConfig().getEnableHttpCompression()) {
pipeline.addLast("deflater", new HttpContentCompressor());
}
pipeline.addLast("executionHandler", _serverContainer.getNettyExecHandler());
DatabusRequestExecutionHandler dbusRequestHandler = new DatabusRequestExecutionHandler(_serverContainer);
pipeline.addLast("databusRequestRunner", dbusRequestHandler);
// add a handler to deal with write timeouts
pipeline.addLast("server container write timeout handler", new ExtendedWriteTimeoutHandler("server container " + _serverContainer.getContainerStaticConfig().getId(), _serverContainer.getNetworkTimeoutTimer(), _serverContainer.getContainerStaticConfig().getWriteTimeoutMs(), true));
return pipeline;
}
use of org.jboss.netty.handler.codec.http.HttpContentCompressor in project voldemort by voldemort.
the class RestPipelineFactory method getPipeline.
@Override
public ChannelPipeline getPipeline() throws Exception {
// Create a default pipeline implementation.
ChannelPipeline pipeline = pipeline();
pipeline.addLast("connectionStats", connectionStatsHandler);
pipeline.addLast("decoder", new HttpRequestDecoder());
pipeline.addLast("aggregator", new HttpChunkAggregator(maxHttpContentLength));
pipeline.addLast("encoder", new HttpResponseEncoder());
pipeline.addLast("deflater", new HttpContentCompressor());
pipeline.addLast("handler", new RestServerRequestHandler(storeRepository));
pipeline.addLast("storageExecutionHandler", storageExecutionHandler);
return pipeline;
}
use of org.jboss.netty.handler.codec.http.HttpContentCompressor in project camel by apache.
the class HttpServerPipelineFactory method getPipeline.
@Override
public ChannelPipeline getPipeline() throws Exception {
// Create a default pipeline implementation.
ChannelPipeline pipeline = Channels.pipeline();
SslHandler sslHandler = configureServerSSLOnDemand();
if (sslHandler != null) {
// must close on SSL exception
sslHandler.setCloseOnSSLException(true);
LOG.debug("Server SSL handler configured and added as an interceptor against the ChannelPipeline: {}", sslHandler);
pipeline.addLast("ssl", sslHandler);
}
pipeline.addLast("decoder", new HttpRequestDecoder(4096, configuration.getMaxHeaderSize(), 8192));
List<ChannelHandler> decoders = consumer.getConfiguration().getDecoders();
for (int x = 0; x < decoders.size(); x++) {
ChannelHandler decoder = decoders.get(x);
if (decoder instanceof ChannelHandlerFactory) {
// use the factory to create a new instance of the channel as it may not be shareable
decoder = ((ChannelHandlerFactory) decoder).newChannelHandler();
}
pipeline.addLast("decoder-" + x, decoder);
}
pipeline.addLast("aggregator", new HttpChunkAggregator(configuration.getChunkedMaxContentLength()));
pipeline.addLast("encoder", new HttpResponseEncoder());
List<ChannelHandler> encoders = consumer.getConfiguration().getEncoders();
for (int x = 0; x < encoders.size(); x++) {
ChannelHandler encoder = encoders.get(x);
if (encoder instanceof ChannelHandlerFactory) {
// use the factory to create a new instance of the channel as it may not be shareable
encoder = ((ChannelHandlerFactory) encoder).newChannelHandler();
}
pipeline.addLast("encoder-" + x, encoder);
}
if (supportCompressed()) {
pipeline.addLast("deflater", new HttpContentCompressor());
}
if (consumer.getConfiguration().isOrderedThreadPoolExecutor()) {
// this must be added just before the HttpServerMultiplexChannelHandler
// use ordered thread pool, to ensure we process the events in order, and can send back
// replies in the expected order. eg this is required by TCP.
// and use a Camel thread factory so we have consistent thread namings
ExecutionHandler executionHandler = new ExecutionHandler(consumer.getEndpoint().getComponent().getExecutorService());
pipeline.addLast("executionHandler", executionHandler);
LOG.debug("Using OrderedMemoryAwareThreadPoolExecutor with core pool size: {}", consumer.getConfiguration().getMaximumPoolSize());
}
int port = consumer.getConfiguration().getPort();
ChannelHandler handler = consumer.getEndpoint().getComponent().getMultiplexChannelHandler(port).getChannelHandler();
pipeline.addLast("handler", handler);
return pipeline;
}
Aggregations