udpBootstrap.setOption("broadcast", "true"); this.pipelineFactory = pipelineFactory;
@Override public void start() { // setup Netty server ConnectionlessBootstrap serverBootstrap = new ConnectionlessBootstrap( new OioDatagramChannelFactory(Executors.newCachedThreadPool())); final NetcatHandler handler = new NetcatHandler(); serverBootstrap.setOption("receiveBufferSizePredictorFactory", new AdaptiveReceiveBufferSizePredictorFactory(DEFAULT_MIN_SIZE, DEFAULT_INITIAL_SIZE, maxsize)); serverBootstrap.setPipelineFactory(new ChannelPipelineFactory() { @Override public ChannelPipeline getPipeline() { return Channels.pipeline(handler); } }); if (host == null) { nettyChannel = serverBootstrap.bind(new InetSocketAddress(port)); } else { nettyChannel = serverBootstrap.bind(new InetSocketAddress(host, port)); } super.start(); }
@Override public void start() { // setup Netty server ConnectionlessBootstrap serverBootstrap = new ConnectionlessBootstrap( new OioDatagramChannelFactory(Executors.newCachedThreadPool())); final syslogHandler handler = new syslogHandler(); handler.setFormater(formaterProp); handler.setKeepFields(keepFields); handler.setClientIPHeader(clientIPHeader); handler.setClientHostnameHeader(clientHostnameHeader); serverBootstrap.setOption("receiveBufferSizePredictorFactory", new AdaptiveReceiveBufferSizePredictorFactory(DEFAULT_MIN_SIZE, DEFAULT_INITIAL_SIZE, maxsize)); serverBootstrap.setPipelineFactory(new ChannelPipelineFactory() { @Override public ChannelPipeline getPipeline() { return Channels.pipeline(handler); } }); if (host == null) { nettyChannel = serverBootstrap.bind(new InetSocketAddress(port)); } else { nettyChannel = serverBootstrap.bind(new InetSocketAddress(host, port)); } sourceCounter.start(); super.start(); }
public void setReceiveBufferSize(int size) { assertDuringInitialization(); bootstrap.setOption("receiveBufferSize", size); }
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); }
@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; }
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)); }
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)); }
public NioUdpGntpClient(GntpApplicationInfo applicationInfo, SocketAddress growlAddress, Executor executor, GntpPassword password, boolean encrypted) { super(applicationInfo, growlAddress, password, encrypted); Preconditions.checkNotNull(executor, "Executor must not be null"); bootstrap = new ConnectionlessBootstrap(new OioDatagramChannelFactory(executor)); bootstrap.setPipelineFactory(new GntpChannelPipelineFactory(new GntpChannelHandler(this, null))); bootstrap.setOption("broadcast", "false"); datagramChannel = (DatagramChannel) bootstrap.bind(new InetSocketAddress(0)); }
public void run(Timeout timeout) throws Exception { if (bootstrap instanceof ClientBootstrap) { ClientBootstrap b = (ClientBootstrap) bootstrap; b.setOption("remoteAddress", getRemoteAddress()); b.connect(); } else if (bootstrap instanceof ConnectionlessBootstrap) { ConnectionlessBootstrap b = (ConnectionlessBootstrap) bootstrap; b.setOption("remoteAddress", getRemoteAddress()); b.connect(); } } }, delay.get(), unit);
@Override public void start() { // setup Netty server ConnectionlessBootstrap serverBootstrap = new ConnectionlessBootstrap( new OioDatagramChannelFactory(Executors.newCachedThreadPool())); final NetcatHandler handler = new NetcatHandler(); serverBootstrap.setOption("receiveBufferSizePredictorFactory", new AdaptiveReceiveBufferSizePredictorFactory(DEFAULT_MIN_SIZE, DEFAULT_INITIAL_SIZE, maxsize)); serverBootstrap.setPipelineFactory(new ChannelPipelineFactory() { @Override public ChannelPipeline getPipeline() { return Channels.pipeline(handler); } }); if (host == null) { nettyChannel = serverBootstrap.bind(new InetSocketAddress(port)); } else { nettyChannel = serverBootstrap.bind(new InetSocketAddress(host, port)); } super.start(); }
connectionlessBootstrap.setOption("child.keepAlive", configuration.isKeepAlive()); connectionlessBootstrap.setOption("child.tcpNoDelay", configuration.isTcpNoDelay()); connectionlessBootstrap.setOption("reuseAddress", configuration.isReuseAddress()); connectionlessBootstrap.setOption("child.reuseAddress", configuration.isReuseAddress()); connectionlessBootstrap.setOption("child.connectTimeoutMillis", configuration.getConnectTimeout()); connectionlessBootstrap.setOption("child.broadcast", configuration.isBroadcast()); connectionlessBootstrap.setOption("sendBufferSize", configuration.getSendBufferSize()); connectionlessBootstrap.setOption("receiveBufferSize", configuration.getReceiveBufferSize()); connectionlessBootstrap.setOption("receiveBufferSizePredictorFactory", new FixedReceiveBufferSizePredictorFactory(configuration.getReceiveBufferSizePredictor())); connectionlessBootstrap.setOption("backlog", configuration.getBacklog()); connectionlessBootstrap.setOption(entry.getKey(), entry.getValue());
connectionlessClientBootstrap.setOption("child.keepAlive", configuration.isKeepAlive()); connectionlessClientBootstrap.setOption("child.tcpNoDelay", configuration.isTcpNoDelay()); connectionlessClientBootstrap.setOption("child.reuseAddress", configuration.isReuseAddress()); connectionlessClientBootstrap.setOption("child.connectTimeoutMillis", configuration.getConnectTimeout()); connectionlessClientBootstrap.setOption("child.broadcast", configuration.isBroadcast()); connectionlessClientBootstrap.setOption("sendBufferSize", configuration.getSendBufferSize()); connectionlessClientBootstrap.setOption("receiveBufferSize", configuration.getReceiveBufferSize()); connectionlessClientBootstrap.setOption(entry.getKey(), entry.getValue());
@Override public void start() { // setup Netty server ConnectionlessBootstrap serverBootstrap = new ConnectionlessBootstrap( new OioDatagramChannelFactory(Executors.newCachedThreadPool())); final syslogHandler handler = new syslogHandler(); handler.setFormater(formaterProp); handler.setKeepFields(keepFields); handler.setClientIPHeader(clientIPHeader); handler.setClientHostnameHeader(clientHostnameHeader); serverBootstrap.setOption("receiveBufferSizePredictorFactory", new AdaptiveReceiveBufferSizePredictorFactory(DEFAULT_MIN_SIZE, DEFAULT_INITIAL_SIZE, maxsize)); serverBootstrap.setPipelineFactory(new ChannelPipelineFactory() { @Override public ChannelPipeline getPipeline() { return Channels.pipeline(handler); } }); if (host == null) { nettyChannel = serverBootstrap.bind(new InetSocketAddress(port)); } else { nettyChannel = serverBootstrap.bind(new InetSocketAddress(host, port)); } sourceCounter.start(); super.start(); }
/** * 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); } } }