use of org.jboss.netty.channel.ChannelPipeline in project dubbo by alibaba.
the class NettyServer method doOpen.
@Override
protected void doOpen() throws Throwable {
NettyHelper.setNettyLoggerFactory();
ExecutorService boss = Executors.newCachedThreadPool(new NamedThreadFactory("NettyServerBoss", true));
ExecutorService worker = Executors.newCachedThreadPool(new NamedThreadFactory("NettyServerWorker", true));
ChannelFactory channelFactory = new NioServerSocketChannelFactory(boss, worker, getUrl().getPositiveParameter(Constants.IO_THREADS_KEY, Constants.DEFAULT_IO_THREADS));
bootstrap = new ServerBootstrap(channelFactory);
final NettyHandler nettyHandler = new NettyHandler(getUrl(), this);
channels = nettyHandler.getChannels();
// https://issues.jboss.org/browse/NETTY-365
// https://issues.jboss.org/browse/NETTY-379
// final Timer timer = new HashedWheelTimer(new NamedThreadFactory("NettyIdleTimer", true));
bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
public ChannelPipeline getPipeline() {
NettyCodecAdapter adapter = new NettyCodecAdapter(getCodec(), getUrl(), NettyServer.this);
ChannelPipeline pipeline = Channels.pipeline();
/*int idleTimeout = getIdleTimeout();
if (idleTimeout > 10000) {
pipeline.addLast("timer", new IdleStateHandler(timer, idleTimeout / 1000, 0, 0));
}*/
pipeline.addLast("decoder", adapter.getDecoder());
pipeline.addLast("encoder", adapter.getEncoder());
pipeline.addLast("handler", nettyHandler);
return pipeline;
}
});
// bind
channel = bootstrap.bind(getBindAddress());
}
use of org.jboss.netty.channel.ChannelPipeline in project databus by linkedin.
the class DummyHttpRequestHandler method setupClient.
private void setupClient() {
_clientBootstrap = new ClientBootstrap(new DefaultLocalClientChannelFactory());
_clientBootstrap.setPipelineFactory(new ChannelPipelineFactory() {
@Override
public ChannelPipeline getPipeline() throws Exception {
ChannelPipeline clientPipeline = pipeline();
clientPipeline.addLast("client logger 1", new LoggingHandler("client logger 1", InternalLogLevel.DEBUG, true));
clientPipeline.addLast("codec", new HttpClientCodec());
clientPipeline.addLast("aggregator", new FooterAwareHttpChunkAggregator(1000000));
_responseHandler = new SimpleHttpResponseHandler();
clientPipeline.addLast("handler", _responseHandler);
clientPipeline.addLast("client logger 5", new LoggingHandler("client logger 5", InternalLogLevel.DEBUG, true));
return clientPipeline;
}
});
}
use of org.jboss.netty.channel.ChannelPipeline in project databus by linkedin.
the class SimpleTestHttpClient method createPipeline.
private ChannelPipeline createPipeline() throws Exception {
ChannelPipeline clientPipeline = pipeline();
clientPipeline.addLast("client logger 1", new LoggingHandler("client logger 1", InternalLogLevel.DEBUG, true));
clientPipeline.addLast("codec", new HttpClientCodec());
clientPipeline.addLast("aggregator", new FooterAwareHttpChunkAggregator(1000000));
_responseHandler = new SimpleHttpResponseHandler();
clientPipeline.addLast("handler", _responseHandler);
clientPipeline.addLast("client logger 5", new LoggingHandler("client logger 5", InternalLogLevel.DEBUG, true));
return clientPipeline;
}
use of org.jboss.netty.channel.ChannelPipeline in project bagheera by mozilla-metrics.
the class HttpServerPipelineFactory method getPipeline.
/* (non-Javadoc)
* @see org.jboss.netty.channel.ChannelPipelineFactory#getPipeline()
*/
public ChannelPipeline getPipeline() throws Exception {
ChannelPipeline pipeline = Channels.pipeline();
pipeline.addLast("decoder", new BagheeraHttpRequestDecoder());
pipeline.addLast("aggregator", new HttpChunkAggregator(maxContentLength));
pipeline.addLast("contentLengthFilter", new ContentLengthFilter(maxContentLength));
pipeline.addLast("rootResponse", new RootResponse());
pipeline.addLast("accessFilter", new AccessFilter(validator, props));
pipeline.addLast("encodingCorrector", new ContentEncodingCorrector());
pipeline.addLast("inflater", new HttpContentDecompressor());
pipeline.addLast("encoder", new HttpResponseEncoder());
pipeline.addLast("handler", new SubmissionHandler(validator, producer, this.channelGroup, this.metricsManager));
return pipeline;
}
use of org.jboss.netty.channel.ChannelPipeline in project pinpoint by naver.
the class DefaultPinpointClientFactory method reconnect.
public ChannelFuture reconnect(final SocketAddress remoteAddress) {
if (remoteAddress == null) {
throw new NullPointerException("remoteAddress");
}
ChannelPipeline pipeline;
final ClientBootstrap bootstrap = this.bootstrap;
try {
pipeline = bootstrap.getPipelineFactory().getPipeline();
} catch (Exception e) {
throw new ChannelPipelineException("Failed to initialize a pipeline.", e);
}
PinpointClientHandler pinpointClientHandler = (DefaultPinpointClientHandler) pipeline.getLast();
pinpointClientHandler.initReconnect();
// Set the options.
Channel ch = bootstrap.getFactory().newChannel(pipeline);
boolean success = false;
try {
ch.getConfig().setOptions(bootstrap.getOptions());
success = true;
} finally {
if (!success) {
ch.close();
}
}
// Connect.
return ch.connect(remoteAddress);
}
Aggregations