@Override public Bootstrap createServerBootstrap() { serverBootstrap = new ConnectionlessBootstrap( new NioDatagramChannelFactory(Executors .newCachedThreadPool(new NamedThreadFactory( "UDP-Server-Worker")))); return serverBootstrap; }
public void shutdown() { workerPool.shutdown(); if (releasePool) { releasePool(); } }
if (channelFactory == null) this.channelFactory = new NioDatagramChannelFactory(worker);
public void releaseExternalResources() { workerPool.shutdown(); releasePool(); }
/** * Initialize; cached threadpool is safe as it is releasing resources automatically if idle */ public synchronized void init() { channelFactory = new NioClientSocketChannelFactory( Executors.newCachedThreadPool(), Executors.newCachedThreadPool()); datagramChannelFactory = new NioDatagramChannelFactory( Executors.newCachedThreadPool()); timer = new HashedWheelTimer(); }
UdpServerChannelSink(NioDatagramWorkerPool workerPool, Timer timer) { serverChannelFactory = new NioDatagramChannelFactory(workerPool); this.timer = timer; }
/** * Initialize; cached threadpool is safe as it is releasing resources automatically if idle */ public synchronized void init() { channelFactory = new NioClientSocketChannelFactory( Executors.newCachedThreadPool(), Executors.newCachedThreadPool()); datagramChannelFactory = new NioDatagramChannelFactory( Executors.newCachedThreadPool()); timer = new HashedWheelTimer(); }
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 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); }
@Override public Bootstrap getBootstrap() { final ConnectionlessBootstrap bootstrap = new ConnectionlessBootstrap(new NioDatagramChannelFactory(workerExecutor)); final int recvBufferSize = Ints.saturatedCast(getRecvBufferSize()); LOG.debug("Setting receive buffer size to {} bytes", recvBufferSize); bootstrap.setOption("receiveBufferSizePredictorFactory", new FixedReceiveBufferSizePredictorFactory(recvBufferSize)); bootstrap.setOption("receiveBufferSize", recvBufferSize); return bootstrap; }
@Override public Bootstrap getBootstrap() { final ConnectionlessBootstrap bootstrap = new ConnectionlessBootstrap(new NioDatagramChannelFactory(workerExecutor)); final int recvBufferSize = Ints.saturatedCast(getRecvBufferSize()); LOG.debug("Setting receive buffer size to {} bytes", recvBufferSize); bootstrap.setOption("receiveBufferSizePredictorFactory", new FixedReceiveBufferSizePredictorFactory(recvBufferSize)); bootstrap.setOption("receiveBufferSize", recvBufferSize); return bootstrap; }
final ChannelPipelineHandlerImpl perDatagramFactory = new ChannelPipelineHandlerImpl(); DatagramChannelFactory udpFactory = new NioDatagramChannelFactory(Executors.newCachedThreadPool());
public void run() { // Configure the client. DatagramChannelFactory f = new NioDatagramChannelFactory( Executors.newCachedThreadPool(), workerCount); server = new ConnectionlessBootstrap(f); server.setPipeline(Channels.pipeline(RpcUtil.STAGE_RPC_MESSAGE_PARSER, rpcProgram, RpcUtil.STAGE_RPC_UDP_RESPONSE)); server.setOption("broadcast", "false"); server.setOption("sendBufferSize", SEND_BUFFER_SIZE); server.setOption("receiveBufferSize", RECEIVE_BUFFER_SIZE); // Listen to the UDP port ch = server.bind(new InetSocketAddress(port)); InetSocketAddress socketAddr = (InetSocketAddress) ch.getLocalAddress(); boundPort = socketAddr.getPort(); LOG.info("Started listening to UDP requests at port " + boundPort + " for " + rpcProgram + " with workerCount " + workerCount); }
public HistoricReplayListenerClientDDF(final int socketAddress, final Executor executor) { this.socketAddress = socketAddress; runner = executor; final DatagramChannelFactory channelFactory = new NioDatagramChannelFactory( runner); boot = new ConnectionlessBootstrap(channelFactory); final ChannelPipelineFactory pipelineFactory = new PipelineFactoryDDF( this); boot.setPipelineFactory(pipelineFactory); boot.setOption("broadcast", "false"); boot.setOption("receiveBufferSizePredictorFactory", // new FixedReceiveBufferSizePredictorFactory(2 * 1024)); }
udpServer = new ConnectionlessBootstrap(new NioDatagramChannelFactory( Executors.newCachedThreadPool()));
UDPListenerClientDDF(final List<Integer> socketAddress, final boolean filterBySub, final Executor executor) { this.socketAddress = socketAddress; this.filterBySub = filterBySub; runner = executor; final DatagramChannelFactory channelFactory = new NioDatagramChannelFactory( runner); boot = new ConnectionlessBootstrap(channelFactory); final ChannelPipelineFactory pipelineFactory = new PipelineFactoryDDF( this); boot.setPipelineFactory(pipelineFactory); boot.setOption("broadcast", "false"); boot.setOption("receiveBufferSizePredictorFactory", // new FixedReceiveBufferSizePredictorFactory(2 * 1024)); }
final ConnectionlessBootstrap bootstrap = new ConnectionlessBootstrap(new NioDatagramChannelFactory(m_rtpExecutorService));
/** * Starts this application * * @param pipelineFactory the {@link CoapChannelPipelineFactory} that creates the instances of * {@link AbstractCoapChannelHandler}s that deal with inbound and outbound messages * @param localSocket the socket address to be used for inbound and outbound messages */ protected void startApplication(CoapChannelPipelineFactory pipelineFactory, InetSocketAddress localSocket) { //ChannelFactory channelFactory = new NioDatagramChannelFactory(executor, executor.getCorePoolSize() / 2 ); ChannelFactory channelFactory = new NioDatagramChannelFactory(executor, 1 ); //System.out.println("Threads: " + (executor.getCorePoolSize() - 1)); //Create and configure bootstrap ConnectionlessBootstrap bootstrap = new ConnectionlessBootstrap(channelFactory); bootstrap.setPipelineFactory(pipelineFactory); bootstrap.setOption("receiveBufferSizePredictor", new FixedReceiveBufferSizePredictor(RECEIVE_BUFFER_SIZE)); //Create datagram channel this.channel = (DatagramChannel) bootstrap.bind(localSocket); // set the channel handler contexts for (ChannelHandler handler : pipelineFactory.getChannelHandlers()) { if (handler instanceof AbstractCoapChannelHandler) { ChannelHandlerContext context = this.channel.getPipeline().getContext(handler.getClass()); ((AbstractCoapChannelHandler) handler).setContext(context); } } }
configureThreadPool(getReceiveExecutorName(), receiveExecutor); this.channelFactory = isSendToServerInsteadOfMulticast() ? new NioDatagramChannelFactory(workerExecutor) : new OioDatagramChannelFactory(workerExecutor); this.bootstrap = new ConnectionlessBootstrap(channelFactory); this.bootstrap.setOption("receiveBufferSizePredictorFactory", new FixedReceiveBufferSizePredictorFactory(4096));
final ChannelFactory channelFactory = new NioDatagramChannelFactory( Executors.newCachedThreadPool());