use of org.jboss.netty.bootstrap.ServerBootstrap in project Protocol-Adapter-IEC61850 by OSGP.
the class Iec61850Config method serverBootstrap.
/**
* Returns a ServerBootstrap setting up a server pipeline listening for
* incoming IEC61850 register device requests.
*
* @return an IEC61850 server bootstrap.
*/
@Bean(destroyMethod = "releaseExternalResources")
public ServerBootstrap serverBootstrap() {
final ChannelFactory factory = new NioServerSocketChannelFactory(Executors.newCachedThreadPool(), Executors.newCachedThreadPool());
final ServerBootstrap bootstrap = new ServerBootstrap(factory);
bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
@Override
public ChannelPipeline getPipeline() throws ProtocolAdapterException {
final ChannelPipeline pipeline = Iec61850Config.this.createChannelPipeline(Iec61850Config.this.iec61850ChannelHandlerServer());
LOGGER.info("Created new IEC61850 handler pipeline for server");
return pipeline;
}
});
bootstrap.setOption("child.tcpNoDelay", true);
bootstrap.setOption("child.keepAlive", false);
bootstrap.bind(new InetSocketAddress(this.iec61850PortListener()));
return bootstrap;
}
use of org.jboss.netty.bootstrap.ServerBootstrap in project NabAlive by jcheype.
the class HttpServer method start.
public void start() {
//Timer timer = new HashedWheelTimer();
System.out.println("Runtime.getRuntime().availableProcessors(): " + Runtime.getRuntime().availableProcessors());
// ExecutorService bossExec = new OrderedMemoryAwareThreadPoolExecutor(2, 400000000, 2000000000, 60, TimeUnit.SECONDS);
// ExecutorService ioExec = new OrderedMemoryAwareThreadPoolExecutor(Runtime.getRuntime().availableProcessors() + 1, 400000000, 2000000000, 60, TimeUnit.SECONDS);
//
// bootstrap = new ServerBootstrap(
// new NioServerSocketChannelFactory(bossExec, ioExec, Runtime.getRuntime().availableProcessors() + 1));
// Configure the server.
bootstrap = new ServerBootstrap(new NioServerSocketChannelFactory(Executors.newCachedThreadPool(), Executors.newCachedThreadPool()));
bootstrap.setOption("child.tcpNoDelay", true);
bootstrap.setOption("child.keepAlive", true);
bootstrap.setOption("receiveBufferSize", 128 * 1024);
bootstrap.setOption("sendBufferSize", 128 * 1024);
bootstrap.setOption("reuseAddress", true);
bootstrap.setOption("backlog", 16384);
final HttpApiServerHandler httpApiServerHandler = new HttpApiServerHandler(restHandler);
// Set up the event pipeline factory.
bootstrap.setPipelineFactory(new HttpApiServerPipelineFactory(httpApiServerHandler));
// Bind and start to accept incoming connections.
Channel c = bootstrap.bind(new InetSocketAddress(port));
cg.add(c);
}
use of org.jboss.netty.bootstrap.ServerBootstrap in project NabAlive by jcheype.
the class NabaliveServer method start.
@PostConstruct
public void start() {
logger.info("Starting server.");
// Configure the server.
bootstrap = new ServerBootstrap(new NioServerSocketChannelFactory(Executors.newCachedThreadPool(), Executors.newCachedThreadPool()));
// Set up the pipeline factory.
bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
public ChannelPipeline getPipeline() throws Exception {
ChannelPipeline pipeline = pipeline();
pipeline.addLast("timeout", new IdleStateHandler(timer, 0, 0, 20));
pipeline.addLast("nabaliveServerHandler", nabaliveServerHandler);
return pipeline;
}
});
bootstrap.setOption("reuseAddress", true);
// Bind and start to accept incoming connections.
bind = bootstrap.bind(new InetSocketAddress(XMPP_PORT));
}
use of org.jboss.netty.bootstrap.ServerBootstrap in project databus by linkedin.
the class DummyHttpRequestHandler method setupServer.
private void setupServer(DummyHttpRequestHandler requestHandler) {
_serverBootstrap = new ServerBootstrap(new DefaultLocalServerChannelFactory());
ChannelPipeline serverPipeline = pipeline();
serverPipeline.addLast("server logger 1", new LoggingHandler("server logger 1", InternalLogLevel.DEBUG, true));
serverPipeline.addLast("decoder", new HttpRequestDecoder());
serverPipeline.addLast("encoder", new HttpResponseEncoder());
serverPipeline.addLast("server loggger 5", new LoggingHandler("server logger 5", InternalLogLevel.DEBUG, true));
serverPipeline.addLast("handler", requestHandler);
_serverBootstrap.setPipeline(serverPipeline);
_serverAddress = new LocalAddress(1);
_serverChannel = _serverBootstrap.bind(_serverAddress);
}
use of org.jboss.netty.bootstrap.ServerBootstrap in project crate by crate.
the class PostgresNetty method doStart.
@Override
protected void doStart() {
if (!enabled) {
return;
}
bootstrap = new ServerBootstrap(new NioServerSocketChannelFactory(Executors.newCachedThreadPool(daemonThreadFactory(settings, "postgres-netty-boss")), Executors.newCachedThreadPool(daemonThreadFactory(settings, "postgres-netty-worker"))));
bootstrap.setOption("child.tcpNoDelay", settings.getAsBoolean("tcp_no_delay", true));
bootstrap.setOption("child.keepAlive", settings.getAsBoolean("tcp_keep_alive", true));
bootstrap.setPipelineFactory(() -> {
ChannelPipeline pipeline = Channels.pipeline();
ConnectionContext connectionContext = new ConnectionContext(sqlOperations);
pipeline.addLast("frame-decoder", connectionContext.decoder);
pipeline.addLast("handler", connectionContext.handler);
return pipeline;
});
boolean success = false;
try {
boundAddress = resolveBindAddress();
namedLogger.info("{}", boundAddress);
success = true;
} finally {
if (!success) {
// stop boss/worker threads to avoid leaks
doStop();
}
}
}
Aggregations