示例#1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void start() throws Throwable
        public override void Start()
        {
            string          className      = this.GetType().Name;
            ExecutorService bossExecutor   = newCachedThreadPool(daemon("Boss-" + className));
            ExecutorService workerExecutor = newCachedThreadPool(daemon("Worker-" + className));

            _bootstrap = new ServerBootstrap(new NioServerSocketChannelFactory(bossExecutor, workerExecutor, _config.MaxConcurrentTransactions));
            _bootstrap.PipelineFactory = this;

            PortRangeSocketBinder portRangeSocketBinder = new PortRangeSocketBinder(_bootstrap);

            try
            {
                Connection connection = portRangeSocketBinder.BindToFirstAvailablePortInRange(_config.ServerAddress);
                Channel    channel    = connection.Channel;
                _socketAddress = connection.SocketAddress;

                _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);
            }
        }
示例#2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void stop() throws Throwable
        public override void Stop()
        {
            _msgLog.debug("Shutting down NetworkReceiver at " + _config.clusterServer().Host + ":" + _port);

            _channels.close().awaitUninterruptibly();
            _serverBootstrap.releaseExternalResources();
            _msgLog.debug("Shutting down NetworkReceiver complete");
        }