use of org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory in project storm by apache.
the class Context method prepare.
/**
* initialization per Storm configuration
*/
@SuppressWarnings("rawtypes")
public void prepare(Map storm_conf) {
this.storm_conf = storm_conf;
connections = new HashMap<>();
//each context will have a single client channel factory
int maxWorkers = Utils.getInt(storm_conf.get(Config.STORM_MESSAGING_NETTY_CLIENT_WORKER_THREADS));
ThreadFactory bossFactory = new NettyRenameThreadFactory("client" + "-boss");
ThreadFactory workerFactory = new NettyRenameThreadFactory("client" + "-worker");
if (maxWorkers > 0) {
clientChannelFactory = new NioClientSocketChannelFactory(Executors.newCachedThreadPool(bossFactory), Executors.newCachedThreadPool(workerFactory), maxWorkers);
} else {
clientChannelFactory = new NioClientSocketChannelFactory(Executors.newCachedThreadPool(bossFactory), Executors.newCachedThreadPool(workerFactory));
}
clientScheduleService = new HashedWheelTimer(new NettyRenameThreadFactory("client-schedule-service"));
}
use of org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory 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.channel.socket.nio.NioClientSocketChannelFactory 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.channel.socket.nio.NioClientSocketChannelFactory in project weave by continuuity.
the class SimpleKafkaClient method startUp.
@Override
protected void startUp() throws Exception {
brokerCache.startAndWait();
ThreadFactory threadFactory = Threads.createDaemonThreadFactory("kafka-client-netty-%d");
NioClientBossPool bossPool = new NioClientBossPool(Executors.newSingleThreadExecutor(threadFactory), 1, new HashedWheelTimer(threadFactory), null);
NioWorkerPool workerPool = new NioWorkerPool(Executors.newFixedThreadPool(4, threadFactory), 4);
bootstrap = new ClientBootstrap(new NioClientSocketChannelFactory(bossPool, workerPool));
bootstrap.setPipelineFactory(new KafkaChannelPipelineFactory());
connectionPool = new ConnectionPool(bootstrap);
}
use of org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory 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();
}
}
Aggregations