Refine search
@Override public void start() throws KairosDBException { // Configure the server. serverBootstrap = new ServerBootstrap( new NioServerSocketChannelFactory( Executors.newCachedThreadPool(new ThreadFactoryBuilder().setNameFormat("telnet-boss-%d").build()), Executors.newCachedThreadPool(new ThreadFactoryBuilder().setNameFormat("telnet-worker-%d").build()))); // Configure the pipeline factory. serverBootstrap.setPipelineFactory(this); serverBootstrap.setOption("child.tcpNoDelay", true); serverBootstrap.setOption("child.keepAlive", true); serverBootstrap.setOption("reuseAddress", true); // Bind and start to accept incoming connections. serverBootstrap.bind(new InetSocketAddress(address, port)); }
@Override public void stop() { logger.info("Avro source {} stopping: {}", getName(), this); if (server != null) { server.close(); try { server.join(); server = null; } catch (InterruptedException e) { logger.info("Avro source " + getName() + ": Interrupted while waiting " + "for Avro server to stop. Exiting. Exception follows.", e); Thread.currentThread().interrupt(); } } if (socketChannelFactory != null) { socketChannelFactory.releaseExternalResources(); socketChannelFactory = null; } sourceCounter.stop(); if (connectionCountUpdater != null) { connectionCountUpdater.shutdownNow(); connectionCountUpdater = null; } super.stop(); logger.info("Avro source {} stopped. Metrics: {}", getName(), sourceCounter); }
protected static Server initializeServer(Responder responder) { ChannelFactory channelFactory = new NioServerSocketChannelFactory( Executors.newCachedThreadPool(), Executors.newCachedThreadPool() ); return new NettyServer(responder, new InetSocketAddress(0), channelFactory, new SSLChannelPipelineFactory(), null); }
bootstrap = new ServerBootstrap( new NioServerSocketChannelFactory( Executors.newCachedThreadPool(), Executors.newCachedThreadPool(), ioWorkerCount)); bootstrap.setPipelineFactory(factory); bootstrap.setOptions(channelOptions); socketAddress = new InetSocketAddress(configuredPort); } else { socketAddress = new InetSocketAddress(hostname, configuredPort); channel = bootstrap.bind(socketAddress); allChannels.add(channel); runtimePort = ((InetSocketAddress) channel.getLocalAddress()).getPort();
private NioServerSocketChannelFactory initSocketChannelFactory() { NioServerSocketChannelFactory socketChannelFactory; if (maxThreads <= 0) { socketChannelFactory = new NioServerSocketChannelFactory( Executors.newCachedThreadPool(new ThreadFactoryBuilder().setNameFormat( "Avro " + NettyTransceiver.class.getSimpleName() + " Boss-%d").build()), Executors.newCachedThreadPool(new ThreadFactoryBuilder().setNameFormat( "Avro " + NettyTransceiver.class.getSimpleName() + " I/O Worker-%d").build())); } else { socketChannelFactory = new NioServerSocketChannelFactory( Executors.newCachedThreadPool(new ThreadFactoryBuilder().setNameFormat( "Avro " + NettyTransceiver.class.getSimpleName() + " Boss-%d").build()), Executors.newFixedThreadPool(maxThreads, new ThreadFactoryBuilder().setNameFormat( "Avro " + NettyTransceiver.class.getSimpleName() + " I/O Worker-%d").build())); } return socketChannelFactory; }
public Bootstrap createServerBootstrap() { // TODO The thread pools should be injected from spring. serverBootstrap = new ServerBootstrap( new NioServerSocketChannelFactory(Executors .newCachedThreadPool(new NamedThreadFactory( "TCP-Server-Boss")), Executors .newCachedThreadPool(new NamedThreadFactory( "TCP-Server-Worker")))); return serverBootstrap; }
/** * Bind the network connection and start the network processing threads. */ public void start() { // TODO provide tweakable options here for passing in custom executors. channelFactory = new NioServerSocketChannelFactory( Executors.newCachedThreadPool(), Executors.newCachedThreadPool()); allChannels = new DefaultChannelGroup("jmemcachedChannelGroup"); ServerBootstrap bootstrap = new ServerBootstrap(channelFactory); ChannelPipelineFactory pipelineFactory; if (binary) pipelineFactory = createMemcachedBinaryPipelineFactory(cache, memcachedVersion, verbose, idleTime, allChannels); else pipelineFactory = createMemcachedPipelineFactory(cache, memcachedVersion, verbose, idleTime, frameSize, allChannels); bootstrap.setPipelineFactory(pipelineFactory); bootstrap.setOption("sendBufferSize", 65536 ); bootstrap.setOption("receiveBufferSize", 65536); Channel serverChannel = bootstrap.bind(addr); allChannels.add(serverChannel); log.info("Listening on " + String.valueOf(addr.getHostName()) + ":" + addr.getPort()); running = true; }
public Bootstrap createServerBootstrap() { // TODO The thread pools should be injected from spring. serverBootstrap = new ServerBootstrap( new NioServerSocketChannelFactory(Executors .newFixedThreadPool(1,new NamedThreadFactory( "Flash-Server-Boss")), Executors .newFixedThreadPool(1,new NamedThreadFactory( "Flash-Server-Worker")))); return serverBootstrap; }
public SmppSimulatorServer(ExecutorService executors) { // used for tracking any child channels (sessions) this.sessionChannels = new DefaultChannelGroup(); // we'll put the "boss" worker for a server in its own pool this.bossThreadPool = Executors.newCachedThreadPool(); // a factory for creating channels (connections) this.channelFactory = new NioServerSocketChannelFactory(this.bossThreadPool, executors); // tie the server bootstrap to this server socket channel factory this.serverBootstrap = new ServerBootstrap(this.channelFactory); // the handler to use when new child connections are accepted this.serverHandler = new SmppSimulatorServerHandler(this.sessionChannels); // set up the event pipeline factory for new connections this.serverBootstrap.setParentHandler(serverHandler); }
public NettyServer(Responder responder, InetSocketAddress addr) { this(responder, addr, new NioServerSocketChannelFactory (Executors .newCachedThreadPool(), Executors.newCachedThreadPool())); }
bootstrap = new ServerBootstrap(); bootstrap.setPipelineFactory(new ChannelPipelineFactory() { @Override public ChannelPipeline getPipeline() throws Exception { ScheduledExecutorService staleCheckExecutor = Executors.newSingleThreadScheduledExecutor(new NamingThreadFactory("WEBBIT-STALE-CONNECTION-CHECK-THREAD")); staleCheckExecutor.scheduleWithFixedDelay(new Runnable() { @Override ExecutorService bossExecutor = Executors.newSingleThreadExecutor(new NamingThreadFactory("WEBBIT-BOSS-THREAD")); executorServices.add(bossExecutor); ExecutorService workerExecutor = Executors.newSingleThreadExecutor(new NamingThreadFactory("WEBBIT-WORKER-THREAD")); executorServices.add(workerExecutor); bootstrap.setFactory(new NioServerSocketChannelFactory(bossExecutor, workerExecutor, 1)); channel = bootstrap.bind(socketAddress); return NettyWebServer.this;
@Inject public TSOChannelHandler(TSOServerConfig config, RequestProcessor requestProcessor, MetricsRegistry metrics) { this.config = config; this.metrics = metrics; this.requestProcessor = requestProcessor; // Setup netty listener this.factory = new NioServerSocketChannelFactory( Executors.newCachedThreadPool(new ThreadFactoryBuilder().setNameFormat("boss-%d").build()), Executors.newCachedThreadPool(new ThreadFactoryBuilder().setNameFormat("worker-%d").build()), (Runtime.getRuntime().availableProcessors() * 2 + 1) * 2); this.bootstrap = new ServerBootstrap(factory); bootstrap.setPipelineFactory(new TSOPipelineFactory(this)); }
/** * Create a server for this cluster. * @param cluster */ public GossipServer(GossipCluster cluster) { this.cluster = cluster; serverBootstrap = new ServerBootstrap(new NioServerSocketChannelFactory(Executors.newFixedThreadPool(1), Executors.newFixedThreadPool(8))); serverBootstrap.setPipelineFactory(new GossipPipelineFactory(cluster,false)); clientBootstrap = new ClientBootstrap(new NioClientSocketChannelFactory(Executors.newFixedThreadPool(1), Executors.newFixedThreadPool(8))); clientBootstrap.setPipelineFactory(new GossipPipelineFactory(cluster,true)); }
@PostConstruct public void init() { ExecutorService bossExecutor = Executors.newCachedThreadPool(Executors.defaultThreadFactory()); ExecutorService workerExecutor = Executors.newCachedThreadPool(Executors.defaultThreadFactory()); int workers = Runtime.getRuntime().availableProcessors(); NioServerSocketChannelFactory channelFactory = new NioServerSocketChannelFactory(bossExecutor,workerExecutor,workers); httpServer = new HttpServer(channelFactory, this, actorSystem , configuration.getProperty(this.getClass(),"listenPort",Integer.class,8080)); httpServer.init(); }
public static void setupHTTPListeners() { ServerBootstrap bootstrap = new ServerBootstrap(new NioServerSocketChannelFactory(Executors.newFixedThreadPool(1), Executors.newFixedThreadPool(2))); ----- ----- }
NettyServerCnxnFactory() { bootstrap = new ServerBootstrap( new NioServerSocketChannelFactory( Executors.newCachedThreadPool(), Executors.newCachedThreadPool())); // parent channel bootstrap.setOption("reuseAddress", true); // child channels bootstrap.setOption("child.tcpNoDelay", true); /* set socket linger to off, so that socket close does not block */ bootstrap.setOption("child.soLinger", -1); bootstrap.getPipeline().addLast("servercnxnfactory", channelHandler); }
TCPListenerClientDDF(final List<Integer> socketAddress, final boolean filterBySub, final Executor executor) { this.socketAddress = socketAddress; this.filterBySub = filterBySub; runner = executor; final ChannelFactory channelFactory = new NioServerSocketChannelFactory(executor, executor); boot = new ServerBootstrap(channelFactory); final ChannelPipelineFactory pipelineFactory = new PipelineFactoryDDF(this); boot.setPipelineFactory(pipelineFactory); }
public static final synchronized ServerBootstrap defaultBootstrap(ExecutorService bossExecutor, ExecutorService workExecutor) { if (bootstrap == null) bootstrap = new ServerBootstrap(new NioServerSocketChannelFactory(bossExecutor, workExecutor)); return bootstrap; }
@Override protected Bootstrap getBootstrap() { final ServerBootstrap bootstrap = new ServerBootstrap(new NioServerSocketChannelFactory(bossExecutor, workerExecutor)); bootstrap.setOption("receiveBufferSizePredictorFactory", new FixedReceiveBufferSizePredictorFactory(8192)); bootstrap.setOption("receiveBufferSize", getRecvBufferSize()); bootstrap.setOption("child.receiveBufferSize", getRecvBufferSize()); bootstrap.setOption("child.keepAlive", tcpKeepalive); return bootstrap; }
@PostConstruct public void start() { bossExecutor = nettyServerConfig.getBossExecutor(); workerExecutor = nettyServerConfig.getWorkerExecutor(); serverChannelFactory = new NioServerSocketChannelFactory(bossExecutor, workerExecutor); for (NettyServerTransport transport : transports.values()) { transport.start(serverChannelFactory); } }