Esempio n. 1
0
        public virtual void Run()
        {
            // Configure the Server.
            ChannelFactory factory;

            if (workerCount == 0)
            {
                // Use default workers: 2 * the number of available processors
                factory = new NioServerSocketChannelFactory(Executors.NewCachedThreadPool(), Executors
                                                            .NewCachedThreadPool());
            }
            else
            {
                factory = new NioServerSocketChannelFactory(Executors.NewCachedThreadPool(), Executors
                                                            .NewCachedThreadPool(), workerCount);
            }
            server = new ServerBootstrap(factory);
            server.SetPipelineFactory(new _ChannelPipelineFactory_73(this));
            server.SetOption("child.tcpNoDelay", true);
            server.SetOption("child.keepAlive", true);
            // Listen to TCP port
            ch = server.Bind(new IPEndPoint(port));
            IPEndPoint socketAddr = (IPEndPoint)ch.GetLocalAddress();

            boundPort = socketAddr.Port;
            Log.Info("Started listening to TCP requests at port " + boundPort + " for " + rpcProgram
                     + " with workerCount " + workerCount);
        }
Esempio n. 2
0
        public override void Start()
        {
            _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.PipelineFactory = new NetworkNodePipelineFactory(this);

            int[] ports = _config.clusterServer().Ports;

            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().Host + ":" + _port);
        }