• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java NioWorkerPool类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.jboss.netty.channel.socket.nio.NioWorkerPool的典型用法代码示例。如果您正苦于以下问题:Java NioWorkerPool类的具体用法?Java NioWorkerPool怎么用?Java NioWorkerPool使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



NioWorkerPool类属于org.jboss.netty.channel.socket.nio包,在下文中一共展示了NioWorkerPool类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: NiftyClient

import org.jboss.netty.channel.socket.nio.NioWorkerPool; //导入依赖的package包/类
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);
	}
}
 
开发者ID:Treydone,项目名称:mandrel,代码行数:25,代码来源:NiftyClient.java


示例2: createChannelFactory

import org.jboss.netty.channel.socket.nio.NioWorkerPool; //导入依赖的package包/类
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);
}
 
开发者ID:masonmei,项目名称:apm-agent,代码行数:9,代码来源:PinpointSocketFactory.java


示例3: createBootStrap

import org.jboss.netty.channel.socket.nio.NioWorkerPool; //导入依赖的package包/类
private ServerBootstrap createBootStrap(int bossCount, int workerCount) {
    // profiler, collector
    ExecutorService boss = Executors.newCachedThreadPool(new PinpointThreadFactory("Pinpoint-Server-Boss"));
    NioServerBossPool nioServerBossPool = new NioServerBossPool(boss, bossCount, ThreadNameDeterminer.CURRENT);

    ExecutorService worker = Executors.newCachedThreadPool(new PinpointThreadFactory("Pinpoint-Server-Worker"));
    NioWorkerPool nioWorkerPool = new NioWorkerPool(worker, workerCount, ThreadNameDeterminer.CURRENT);

    NioServerSocketChannelFactory nioClientSocketChannelFactory = new NioServerSocketChannelFactory(nioServerBossPool, nioWorkerPool);
    return new ServerBootstrap(nioClientSocketChannelFactory);
}
 
开发者ID:masonmei,项目名称:apm-agent,代码行数:12,代码来源:PinpointServerSocket.java


示例4: start

import org.jboss.netty.channel.socket.nio.NioWorkerPool; //导入依赖的package包/类
public void start() {
	if (local) {
		channelFactory = new DefaultLocalServerChannelFactory();
	} else {
		bossExecutor = nettyServerConfig.getBossExecutor();
		int bossThreadCount = nettyServerConfig.getBossThreadCount();
		ioWorkerExecutor = nettyServerConfig.getWorkerExecutor();
		int ioWorkerThreadCount = nettyServerConfig.getWorkerThreadCount();
		channelFactory = new NioServerSocketChannelFactory(new NioServerBossPool(bossExecutor, bossThreadCount, ThreadNameDeterminer.CURRENT),
				new NioWorkerPool(ioWorkerExecutor, ioWorkerThreadCount, ThreadNameDeterminer.CURRENT));
	}

	start(channelFactory);
}
 
开发者ID:Treydone,项目名称:mandrel,代码行数:15,代码来源:NettyServerTransport.java


示例5: createBootStrap

import org.jboss.netty.channel.socket.nio.NioWorkerPool; //导入依赖的package包/类
private ServerBootstrap createBootStrap(int bossCount, int workerCount) {
    // profiler, collector
    ExecutorService boss = Executors.newCachedThreadPool(new PinpointThreadFactory("Pinpoint-Server-Boss", true));
    NioServerBossPool nioServerBossPool = new NioServerBossPool(boss, bossCount, ThreadNameDeterminer.CURRENT);

    ExecutorService worker = Executors.newCachedThreadPool(new PinpointThreadFactory("Pinpoint-Server-Worker", true));
    NioWorkerPool nioWorkerPool = new NioWorkerPool(worker, workerCount, ThreadNameDeterminer.CURRENT);

    NioServerSocketChannelFactory nioClientSocketChannelFactory = new NioServerSocketChannelFactory(nioServerBossPool, nioWorkerPool);
    return new ServerBootstrap(nioClientSocketChannelFactory);
}
 
开发者ID:naver,项目名称:pinpoint,代码行数:12,代码来源:PinpointServerAcceptor.java


示例6: initialize

import org.jboss.netty.channel.socket.nio.NioWorkerPool; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:allengeorge,项目名称:libraft,代码行数:50,代码来源:RaftAgent.java


示例7: build

import org.jboss.netty.channel.socket.nio.NioWorkerPool; //导入依赖的package包/类
/**
 * Creates a new worker pool.
 */
public WorkerPool build() {
    int count = workerCount > 0 ? workerCount : NettyHelper.DEFAULT_IO_THREADS;
    workerPool = new NioWorkerPool(Executors.newCachedThreadPool(), count, new CamelNettyThreadNameDeterminer(pattern, name));
    return workerPool;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:9,代码来源:NettyWorkerPoolBuilder.java


示例8: ThriftServer

import org.jboss.netty.channel.socket.nio.NioWorkerPool; //导入依赖的package包/类
@Inject
public ThriftServer(final NiftyProcessor processor, ThriftServerConfig config, @ThriftServerTimer Timer timer,
		Map<String, ThriftFrameCodecFactory> availableFrameCodecFactories, Map<String, TDuplexProtocolFactory> availableProtocolFactories,
		@ThriftServerWorkerExecutor Map<String, ExecutorService> availableWorkerExecutors, NiftySecurityFactoryHolder securityFactoryHolder, boolean local) {
	checkNotNull(availableFrameCodecFactories, "availableFrameCodecFactories cannot be null");
	checkNotNull(availableProtocolFactories, "availableProtocolFactories cannot be null");

	NiftyProcessorFactory processorFactory = new NiftyProcessorFactory() {
		@Override
		public NiftyProcessor getProcessor(TTransport transport) {
			return processor;
		}
	};

	String transportName = config.getTransportName();
	String protocolName = config.getProtocolName();

	checkState(availableFrameCodecFactories.containsKey(transportName), "No available server transport named " + transportName);
	checkState(availableProtocolFactories.containsKey(protocolName), "No available server protocol named " + protocolName);

	workerExecutor = config.getOrBuildWorkerExecutor(availableWorkerExecutors);
	if (local) {
		log.warn("Using local server");
		configuredPort = 0;
		ioThreads = 0;
		ioExecutor = null;
		acceptorThreads = 0;
		acceptorExecutor = null;
		serverChannelFactory = new DefaultLocalServerChannelFactory();
	} else {
		configuredPort = config.getPort();

		acceptorExecutor = newCachedThreadPool(new ThreadFactoryBuilder().setNameFormat("thrift-acceptor-%s").build());
		acceptorThreads = config.getAcceptorThreadCount();
		ioExecutor = newCachedThreadPool(new ThreadFactoryBuilder().setNameFormat("thrift-io-%s").build());
		ioThreads = config.getIoThreadCount();

		serverChannelFactory = new NioServerSocketChannelFactory(new NioServerBossPool(acceptorExecutor, acceptorThreads, ThreadNameDeterminer.CURRENT),
				new NioWorkerPool(ioExecutor, ioThreads, ThreadNameDeterminer.CURRENT));
	}

	ThriftServerDef thriftServerDef = ThriftServerDef.newBuilder().name("thrift").listen(configuredPort)
			.limitFrameSizeTo((int) config.getMaxFrameSize().toBytes()).clientIdleTimeout(config.getIdleConnectionTimeout())
			.withProcessorFactory(processorFactory).limitConnectionsTo(config.getConnectionLimit())
			.limitQueuedResponsesPerConnection(config.getMaxQueuedResponsesPerConnection())
			.thriftFrameCodecFactory(availableFrameCodecFactories.get(transportName)).protocol(availableProtocolFactories.get(protocolName))
			.withSecurityFactory(securityFactoryHolder.niftySecurityFactory).using(workerExecutor).taskTimeout(config.getTaskExpirationTimeout()).build();

	NettyServerConfigBuilder nettyServerConfigBuilder = NettyServerConfig.newBuilder();

	nettyServerConfigBuilder.getServerSocketChannelConfig().setBacklog(config.getAcceptBacklog());
	nettyServerConfigBuilder.setBossThreadCount(config.getAcceptorThreadCount());
	nettyServerConfigBuilder.setWorkerThreadCount(config.getIoThreadCount());
	nettyServerConfigBuilder.setTimer(timer);

	NettyServerConfig nettyServerConfig = nettyServerConfigBuilder.build();

	transport = new NettyServerTransport(thriftServerDef, nettyServerConfig, allChannels, local);
}
 
开发者ID:Treydone,项目名称:mandrel,代码行数:60,代码来源:ThriftServer.java


示例9: NioClientSocketChannelFactory

import org.jboss.netty.channel.socket.nio.NioWorkerPool; //导入依赖的package包/类
/**
 * Creates a new instance.
 *
 * @param bossExecutor
 *        the {@link Executor} which will execute the boss thread
 * @param workerExecutor
 *        the {@link Executor} which will execute the worker threads
 * @param bossCount
 *        the maximum number of boss threads
 * @param workerCount
 *        the maximum number of I/O worker threads
 */
public NioClientSocketChannelFactory(
        Executor bossExecutor, Executor workerExecutor,
        int bossCount, int workerCount) {
    this(bossExecutor, bossCount, new NioWorkerPool(workerExecutor, workerCount));
}
 
开发者ID:nyankosama,项目名称:simple-netty-source,代码行数:18,代码来源:NioClientSocketChannelFactory.java


示例10: NioServerSocketChannelFactory

import org.jboss.netty.channel.socket.nio.NioWorkerPool; //导入依赖的package包/类
/**
 * Create a new instance.
 *
 * @param bossExecutor
 *        the {@link Executor} which will execute the boss threads
 * @param bossCount
 *        the number of boss threads
 * @param workerExecutor
 *        the {@link Executor} which will execute the I/O worker threads
 * @param workerCount
 *        the maximum number of I/O worker threads
 */
public NioServerSocketChannelFactory(
        Executor bossExecutor, int bossCount, Executor workerExecutor,
        int workerCount) {
    this(bossExecutor, bossCount, new NioWorkerPool(workerExecutor, workerCount));
}
 
开发者ID:nyankosama,项目名称:simple-netty-source,代码行数:18,代码来源:NioServerSocketChannelFactory.java



注:本文中的org.jboss.netty.channel.socket.nio.NioWorkerPool类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Issue类代码示例发布时间:2022-05-22
下一篇:
Java ECKeyParameters类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap