/** * Creates a new instance. * <p> * Please note that the {@link InternetProtocolFamily} of the channel will be platform (and possibly * configuration) dependent and therefore unspecified. * Use {@link #NioDatagramChannelFactory(Executor, int, InternetProtocolFamily)} if unsure. * * @param workerExecutor * the {@link Executor} which will execute the I/O worker threads * @param workerCount * the maximum number of I/O worker threads */ public NioDatagramChannelFactory(final Executor workerExecutor, final int workerCount) { this(new NioDatagramWorkerPool(workerExecutor, workerCount)); }
@Override public void releaseExternalResources() { workerPool.releaseExternalResources(); }
@Override public void shutdown() { workerPool.shutdown(); }
/** * Creates a new instance. * * @param workerExecutor * the {@link Executor} which will execute the I/O worker threads * @param workerCount * the maximum number of I/O worker threads * @param family * the {@link InternetProtocolFamily} to use. This should be used for UDP multicast. * <strong>Be aware that this option is only considered when running on java7+</strong> */ public NioDatagramChannelFactory(final Executor workerExecutor, final int workerCount, InternetProtocolFamily family) { this(new NioDatagramWorkerPool(workerExecutor, workerCount), family); }
/** * Create a new {@link NioDatagramChannelFactory} with a {@link Executors#newCachedThreadPool()}. * * See {@link #NioDatagramChannelFactory(Executor)} */ public NioDatagramChannelFactory(InternetProtocolFamily family) { workerPool = new NioDatagramWorkerPool(Executors.newCachedThreadPool(), SelectorUtil.DEFAULT_IO_THREADS); this.family = family; sink = new NioDatagramPipelineSink(workerPool); releasePool = true; }
protected void setupUDPCommunication() throws Exception { if (datagramChannelFactory == null) { int count = configuration.getWorkerCount() > 0 ? configuration.getWorkerCount() : NettyHelper.DEFAULT_IO_THREADS; workerPool = new NioDatagramWorkerPool(Executors.newCachedThreadPool(), count); datagramChannelFactory = new NioDatagramChannelFactory(workerPool); } }
/** * Returns a {@link ServerBootstrap} instance for the named transport. */ @Override public synchronized ServerBootstrap newServerBootstrap() throws Exception { if (serverChannelFactory == null) { Executor workerExecutor = executorServiceFactory.newExecutorService("worker.server"); NioDatagramWorkerPool workerPool = new NioDatagramWorkerPool(workerExecutor, 1); serverChannelFactory = new UdpServerChannelFactory(workerPool, timer); // unshared channelFactories.add(serverChannelFactory); } return new ServerBootstrap(serverChannelFactory); }
/** * Returns a {@link ClientBootstrap} instance for the named transport. */ @Override public synchronized ClientBootstrap newClientBootstrap() throws Exception { if (clientChannelFactory == null) { Executor workerExecutor = executorServiceFactory.newExecutorService("worker.client"); NioDatagramWorkerPool workerPool = new NioDatagramWorkerPool(workerExecutor, 1); clientChannelFactory = new NioDatagramChannelFactory(workerPool); // unshared channelFactories.add(clientChannelFactory); } return new UdpClientBootstrap(clientChannelFactory, timer); }
protected void startServerBootstrap() throws Exception { workerPool = new NioDatagramWorkerPool(Executors.newCachedThreadPool(), count);