public NiftyClient(NettyClientConfig nettyClientConfig, boolean local) {
this.nettyClientConfig = nettyClientConfig;
if (local) {
log.warn("Using local client");
this.channelFactory = new DefaultLocalClientChannelFactory();
this.timer = null;
this.bossExecutor = null;
this.workerExecutor = null;
this.defaultSocksProxyAddress = null;
} else {
this.timer = nettyClientConfig.getTimer();
this.bossExecutor = nettyClientConfig.getBossExecutor();
this.workerExecutor = nettyClientConfig.getWorkerExecutor();
this.defaultSocksProxyAddress = nettyClientConfig.getDefaultSocksProxyAddress();
int bossThreadCount = nettyClientConfig.getBossThreadCount();
int workerThreadCount = nettyClientConfig.getWorkerThreadCount();
NioWorkerPool workerPool = new NioWorkerPool(workerExecutor, workerThreadCount, ThreadNameDeterminer.CURRENT);
NioClientBossPool bossPool = new NioClientBossPool(bossExecutor, bossThreadCount, timer, ThreadNameDeterminer.CURRENT);
this.channelFactory = new NioClientSocketChannelFactory(bossPool, workerPool);
}
}
java类org.jboss.netty.channel.socket.nio.NioClientBossPool的实例源码
NiftyClient.java 文件源码
项目:mandrel
阅读 30
收藏 0
点赞 0
评论 0
NettyClientBossPoolBuilder.java 文件源码
项目:Camel
阅读 29
收藏 0
点赞 0
评论 0
/**
* Creates a new boss pool.
*/
public BossPool build() {
Timer internalTimer = timer;
if (!stopTimer) {
internalTimer = new UnstoppableTimer(timer);
}
return new NioClientBossPool(Executors.newCachedThreadPool(), bossCount, internalTimer, new CamelNettyThreadNameDeterminer(pattern, name));
}
PinpointSocketFactory.java 文件源码
项目:apm-agent
阅读 37
收藏 0
点赞 0
评论 0
private NioClientSocketChannelFactory createChannelFactory(int bossCount, int workerCount, Timer timer) {
ExecutorService boss = Executors.newCachedThreadPool(new PinpointThreadFactory("Pinpoint-Client-Boss", true));
NioClientBossPool bossPool = new NioClientBossPool(boss, bossCount, timer, ThreadNameDeterminer.CURRENT);
ExecutorService worker = Executors.newCachedThreadPool(new PinpointThreadFactory("Pinpoint-Client-Worker", true));
NioWorkerPool workerPool = new NioWorkerPool(worker, workerCount, ThreadNameDeterminer.CURRENT);
return new NioClientSocketChannelFactory(bossPool, workerPool);
}
DefaultPinpointClientFactory.java 文件源码
项目:pinpoint
阅读 36
收藏 0
点赞 0
评论 0
private NioClientSocketChannelFactory createChannelFactory(int bossCount, int workerCount, Timer timer) {
ExecutorService boss = Executors.newCachedThreadPool(new PinpointThreadFactory("Pinpoint-Client-Boss", true));
NioClientBossPool bossPool = new NioClientBossPool(boss, bossCount, timer, ThreadNameDeterminer.CURRENT);
ExecutorService worker = Executors.newCachedThreadPool(new PinpointThreadFactory("Pinpoint-Client-Worker", true));
NioWorkerPool workerPool = new NioWorkerPool(worker, workerCount, ThreadNameDeterminer.CURRENT);
return new NioClientSocketChannelFactory(bossPool, workerPool);
}
RaftAgent.java 文件源码
项目:libraft
阅读 28
收藏 0
点赞 0
评论 0
/**
* Initialize the local Raft server.
* <p/>
* Sets up the service implementation classes, creates database
* tables and starts any thread pools necessary. Following this
* call all service classes are <strong>fully initialized</strong>.
* Even though various threads are started they <strong>will not</strong>
* use or interact with the service implementation classes. Callers
* still have exclusive access to the system.
* <p/>
* This method should <strong>only</strong> be called once before {@link RaftAgent#start()}.
*
* @throws StorageException if the persistence components cannot be initialized
* @throws IllegalStateException if this method is called multiple times
*/
public synchronized void initialize() throws StorageException {
checkState(!running);
checkState(!initialized);
checkState(setupConversion);
// start up the snapshots subsystem
snapshotStore.initialize();
// check that the snapshot metadata and the filesystem agree
// FIXME (AG): this _may_ be expensive, especially if the user never bothers to clean out snapshots!
// FIXME (AG): warning, warning - this is upfront work - probably a very, very bad idea
snapshotStore.reconcileSnapshots();
// initialize the log and store
jdbcLog.initialize();
jdbcStore.initialize();
// initialize the various thread pools
nonIoExecutorService = MoreExecutors.listeningDecorator(Executors.newCachedThreadPool());
ioExecutorService = Executors.newCachedThreadPool();
serverBossPool = new NioServerBossPool(ioExecutorService, 1);
clientBossPool = new NioClientBossPool(ioExecutorService, 1);
workerPool = new NioWorkerPool(ioExecutorService, 3);
// TODO (AG): avoid creating threads in the initialize() method
// initialize the networking subsystem
sharedWorkerPool = new ShareableWorkerPool<NioWorker>(workerPool);
ServerSocketChannelFactory serverChannelFactory = new NioServerSocketChannelFactory(serverBossPool, sharedWorkerPool);
ClientSocketChannelFactory clientChannelFactory = new NioClientSocketChannelFactory(clientBossPool, sharedWorkerPool);
raftNetworkClient.initialize(nonIoExecutorService, serverChannelFactory, clientChannelFactory, raftAlgorithm);
raftAlgorithm.initialize();
initialized = true;
}