use of org.jboss.netty.bootstrap.ClientBootstrap in project pinpoint by naver.
the class DefaultPinpointClientFactory method createBootStrap.
private ClientBootstrap createBootStrap(int bossCount, int workerCount, Timer timer) {
// profiler, collector,
logger.debug("createBootStrap boss:{}, worker:{}", bossCount, workerCount);
NioClientSocketChannelFactory nioClientSocketChannelFactory = createChannelFactory(bossCount, workerCount, timer);
return new ClientBootstrap(nioClientSocketChannelFactory);
}
use of org.jboss.netty.bootstrap.ClientBootstrap in project neo4j by neo4j.
the class NetworkSender method start.
@Override
public void start() throws Throwable {
channels = new DefaultChannelGroup();
// Start client bootstrap
clientBootstrap = new ClientBootstrap(new NioClientSocketChannelFactory(Executors.newSingleThreadExecutor(daemon("Cluster client boss", monitor)), Executors.newFixedThreadPool(2, daemon("Cluster client worker", monitor)), 2));
clientBootstrap.setOption("tcpNoDelay", true);
clientBootstrap.setPipelineFactory(new NetworkNodePipelineFactory());
msgLog.debug("Started NetworkSender for " + toString(config));
}
use of org.jboss.netty.bootstrap.ClientBootstrap in project camel by apache.
the class ClientModeTCPNettyServerBootstrapFactory method startServerBootstrap.
protected void startServerBootstrap() {
// prefer using explicit configured thread pools
BossPool bp = configuration.getBossPool();
WorkerPool wp = configuration.getWorkerPool();
if (bp == null) {
// create new pool which we should shutdown when stopping as its not shared
bossPool = new NettyClientBossPoolBuilder().withTimer(new HashedWheelTimer()).withBossCount(configuration.getBossCount()).withName("NettyClientTCPBoss").build();
bp = bossPool;
}
if (wp == null) {
// create new pool which we should shutdown when stopping as its not shared
workerPool = new NettyWorkerPoolBuilder().withWorkerCount(configuration.getWorkerCount()).withName("NettyServerTCPWorker").build();
wp = workerPool;
}
channelFactory = new NioClientSocketChannelFactory(bp, wp);
serverBootstrap = new ClientBootstrap(channelFactory);
serverBootstrap.setOption("keepAlive", configuration.isKeepAlive());
serverBootstrap.setOption("tcpNoDelay", configuration.isTcpNoDelay());
serverBootstrap.setOption("reuseAddress", configuration.isReuseAddress());
serverBootstrap.setOption("connectTimeoutMillis", configuration.getConnectTimeout());
if (configuration.getBacklog() > 0) {
serverBootstrap.setOption("backlog", configuration.getBacklog());
}
// set any additional netty options
if (configuration.getOptions() != null) {
for (Map.Entry<String, Object> entry : configuration.getOptions().entrySet()) {
serverBootstrap.setOption(entry.getKey(), entry.getValue());
}
}
LOG.debug("Created ServerBootstrap {} with options: {}", serverBootstrap, serverBootstrap.getOptions());
// set the pipeline factory, which creates the pipeline for each newly created channels
serverBootstrap.setPipelineFactory(pipelineFactory);
LOG.info("ServerBootstrap connecting to {}:{}", configuration.getHost(), configuration.getPort());
ChannelFuture connectFuture = serverBootstrap.connect(new InetSocketAddress(configuration.getHost(), configuration.getPort()));
try {
channel = openChannel(connectFuture);
} catch (Exception e) {
e.printStackTrace();
}
}
use of org.jboss.netty.bootstrap.ClientBootstrap in project databus by linkedin.
the class TestHttpResponseProcessor method createChannelFuture.
static ChannelFuture createChannelFuture(final GenericHttpResponseHandler responseHandler, int port) {
ClientBootstrap client = new ClientBootstrap(new NioClientSocketChannelFactory(BOSS_POOL, IO_POOL));
client.setPipelineFactory(new ChannelPipelineFactory() {
@Override
public ChannelPipeline getPipeline() throws Exception {
return Channels.pipeline(new LoggingHandler(InternalLogLevel.DEBUG), new HttpClientCodec(), new LoggingHandler(InternalLogLevel.DEBUG), responseHandler);
}
});
final ChannelFuture connectFuture = client.connect(new InetSocketAddress("localhost", port));
return connectFuture;
}
use of org.jboss.netty.bootstrap.ClientBootstrap in project yyl_example by Relucent.
the class NettyClient method main.
public static void main(String[] args) {
ClientBootstrap bootstrap = new ClientBootstrap(new //
NioClientSocketChannelFactory(//
Executors.newCachedThreadPool(), //
Executors.newCachedThreadPool()));
// Set up the default event pipeline.
bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
@Override
public ChannelPipeline getPipeline() throws Exception {
return Channels.pipeline(new StringDecoder(), new StringEncoder(), new ClientHandler());
}
});
// Start the connection attempt.
ChannelFuture future = bootstrap.connect(new InetSocketAddress("localhost", 8000));
// Wait until the connection is closed or the connection attempt fails.
future.getChannel().getCloseFuture().awaitUninterruptibly();
// Shut down thread pools to exit.
bootstrap.releaseExternalResources();
}
Aggregations