use of org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory in project socket.io-netty by ibdknox.
the class FlashPolicyServer method start.
public static void start() {
// Configure the server.
bootstrap = new ServerBootstrap(new NioServerSocketChannelFactory(Executors.newCachedThreadPool(), Executors.newCachedThreadPool()));
// Set up the event pipeline factory.
bootstrap.setPipelineFactory(new FlashPolicyServerPipelineFactory());
bootstrap.setOption("child.tcpNoDelay", true);
bootstrap.setOption("child.keepAlive", true);
// Bind and start to accept incoming connections.
serverChannel = bootstrap.bind(new InetSocketAddress(843));
}
use of org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory in project neo4j by neo4j.
the class NetworkReceiver method start.
@Override
public void start() throws Throwable {
channels = new DefaultChannelGroup();
// Listen for incoming connections
nioChannelFactory = new NioServerSocketChannelFactory(Executors.newCachedThreadPool(daemon("Cluster boss", monitor)), Executors.newFixedThreadPool(2, daemon("Cluster worker", monitor)), 2);
serverBootstrap = new ServerBootstrap(nioChannelFactory);
serverBootstrap.setOption("child.tcpNoDelay", true);
serverBootstrap.setPipelineFactory(new NetworkNodePipelineFactory());
int[] ports = config.clusterServer().getPorts();
int minPort = ports[0];
int maxPort = ports.length == 2 ? ports[1] : minPort;
// Try all ports in the given range
port = listen(minPort, maxPort);
msgLog.debug("Started NetworkReceiver at " + config.clusterServer().getHost() + ":" + port);
}
use of org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory in project neo4j by neo4j.
the class Server method start.
@Override
public void start() throws Throwable {
String className = getClass().getSimpleName();
ExecutorService bossExecutor = newCachedThreadPool(daemon("Boss-" + className));
ExecutorService workerExecutor = newCachedThreadPool(daemon("Worker-" + className));
bootstrap = new ServerBootstrap(new NioServerSocketChannelFactory(bossExecutor, workerExecutor, config.getMaxConcurrentTransactions()));
bootstrap.setPipelineFactory(this);
PortRangeSocketBinder portRangeSocketBinder = new PortRangeSocketBinder(bootstrap);
try {
Connection connection = portRangeSocketBinder.bindToFirstAvailablePortInRange(config.getServerAddress());
Channel channel = connection.getChannel();
socketAddress = connection.getSocketAddress();
channelGroup = new DefaultChannelGroup();
channelGroup.add(channel);
msgLog.info(className + " communication server started and bound to " + socketAddress);
} catch (Exception ex) {
msgLog.error("Failed to bind server to " + socketAddress, ex);
bootstrap.releaseExternalResources();
targetCallExecutor.shutdownNow();
unfinishedTransactionExecutor.shutdownNow();
silentChannelExecutor.shutdownNow();
throw new IOException(ex);
}
}
use of org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory in project databus by linkedin.
the class JmxShutdownThread method initializeContainerNetworking.
protected void initializeContainerNetworking(ByteOrder byteOrder) throws IOException, DatabusException {
//instruct netty not to rename our threads in the I/O and boss thread pools
ThreadRenamingRunnable.setThreadNameDeterminer(ThreadNameDeterminer.CURRENT);
_httpBootstrap = new ServerBootstrap(new NioServerSocketChannelFactory(_bossExecutorService, _ioExecutorService));
_httpBootstrap.setPipelineFactory(new HttpServerPipelineFactory(this));
_httpBootstrap.setOption("bufferFactory", DirectChannelBufferFactory.getInstance(byteOrder));
_httpBootstrap.setOption("child.bufferFactory", DirectChannelBufferFactory.getInstance(byteOrder));
if (_containerStaticConfig.getTcp().isEnabled()) {
_tcpBootstrap = new ServerBootstrap(new NioServerSocketChannelFactory(_bossExecutorService, _ioExecutorService));
_tcpBootstrap.setPipelineFactory(new TcpServerPipelineFactory(this, byteOrder));
_tcpBootstrap.setOption("bufferFactory", DirectChannelBufferFactory.getInstance(byteOrder));
_tcpBootstrap.setOption("child.bufferFactory", DirectChannelBufferFactory.getInstance(byteOrder));
//LOG.debug("endianness:" + ((ChannelBufferFactory)_tcpBootstrap.getOption("bufferFactory")).getDefaultOrder());
}
}
use of org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory in project JAirPort by froks.
the class RtspServer method run.
@Override
public void run() {
System.out.println("Listening on Port " + port);
ServerBootstrap bootstrap = new ServerBootstrap(new NioServerSocketChannelFactory(Executors.newCachedThreadPool(), Executors.newCachedThreadPool()));
bootstrap.setPipelineFactory(new RtspServerPipelineFactory());
bootstrap.bind(new InetSocketAddress(port));
while (!Thread.interrupted()) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// ignore
}
}
System.out.println("RTSP-Server shutdown");
}
Aggregations