Search in sources :

Example 26 with NioServerSocketChannelFactory

use of org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory in project pinpoint by naver.

the class PinpointServerAcceptor method createBootStrap.

private ServerBootstrap createBootStrap(int bossCount, int workerCount) {
    // profiler, collector
    ExecutorService boss = Executors.newCachedThreadPool(new PinpointThreadFactory("Pinpoint-Server-Boss"));
    NioServerBossPool nioServerBossPool = new NioServerBossPool(boss, bossCount, ThreadNameDeterminer.CURRENT);
    ExecutorService worker = Executors.newCachedThreadPool(new PinpointThreadFactory("Pinpoint-Server-Worker"));
    NioWorkerPool nioWorkerPool = new NioWorkerPool(worker, workerCount, ThreadNameDeterminer.CURRENT);
    NioServerSocketChannelFactory nioClientSocketChannelFactory = new NioServerSocketChannelFactory(nioServerBossPool, nioWorkerPool);
    return new ServerBootstrap(nioClientSocketChannelFactory);
}
Also used : NioServerBossPool(org.jboss.netty.channel.socket.nio.NioServerBossPool) NioWorkerPool(org.jboss.netty.channel.socket.nio.NioWorkerPool) NioServerSocketChannelFactory(org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory) ExecutorService(java.util.concurrent.ExecutorService) ServerBootstrap(org.jboss.netty.bootstrap.ServerBootstrap) PinpointThreadFactory(com.navercorp.pinpoint.common.util.PinpointThreadFactory)

Example 27 with NioServerSocketChannelFactory

use of org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory 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;
}
Also used : NioServerSocketChannelFactory(org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory) InetSocketAddress(java.net.InetSocketAddress) ProtocolAdapterException(com.alliander.osgp.adapter.protocol.iec61850.exceptions.ProtocolAdapterException) NioServerSocketChannelFactory(org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory) ChannelFactory(org.jboss.netty.channel.ChannelFactory) ChannelPipelineFactory(org.jboss.netty.channel.ChannelPipelineFactory) ServerBootstrap(org.jboss.netty.bootstrap.ServerBootstrap) ChannelPipeline(org.jboss.netty.channel.ChannelPipeline) Bean(org.springframework.context.annotation.Bean)

Aggregations

NioServerSocketChannelFactory (org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory)27 ServerBootstrap (org.jboss.netty.bootstrap.ServerBootstrap)26 InetSocketAddress (java.net.InetSocketAddress)18 ChannelPipeline (org.jboss.netty.channel.ChannelPipeline)11 ChannelPipelineFactory (org.jboss.netty.channel.ChannelPipelineFactory)10 Channel (org.jboss.netty.channel.Channel)5 ChannelFactory (org.jboss.netty.channel.ChannelFactory)5 Executor (java.util.concurrent.Executor)4 ExecutorService (java.util.concurrent.ExecutorService)4 DefaultChannelGroup (org.jboss.netty.channel.group.DefaultChannelGroup)4 HttpRequestDecoder (org.jboss.netty.handler.codec.http.HttpRequestDecoder)3 HttpResponseEncoder (org.jboss.netty.handler.codec.http.HttpResponseEncoder)3 ThreadFactoryBuilder (com.google.common.util.concurrent.ThreadFactoryBuilder)2 IOException (java.io.IOException)2 SocketAddress (java.net.SocketAddress)2 Map (java.util.Map)2 SSLEngine (javax.net.ssl.SSLEngine)2 NioServerBossPool (org.jboss.netty.channel.socket.nio.NioServerBossPool)2 NioWorkerPool (org.jboss.netty.channel.socket.nio.NioWorkerPool)2 OioServerSocketChannelFactory (org.jboss.netty.channel.socket.oio.OioServerSocketChannelFactory)2