示例#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);
        }
示例#2
0
		// TODO change AbstractService to throw InterruptedException
		/// <exception cref="System.Exception"/>
		protected override void ServiceStart()
		{
			Configuration conf = GetConfig();
			userRsrc = new ConcurrentHashMap<string, string>();
			secretManager = new JobTokenSecretManager();
			RecoverState(conf);
			ServerBootstrap bootstrap = new ServerBootstrap(selector);
			try
			{
				pipelineFact = new ShuffleHandler.HttpPipelineFactory(this, conf);
			}
			catch (Exception ex)
			{
				throw new RuntimeException(ex);
			}
			bootstrap.SetOption("child.keepAlive", true);
			bootstrap.SetPipelineFactory(pipelineFact);
			port = conf.GetInt(ShufflePortConfigKey, DefaultShufflePort);
			Org.Jboss.Netty.Channel.Channel ch = bootstrap.Bind(new IPEndPoint(port));
			accepted.AddItem(ch);
			port = ((IPEndPoint)ch.GetLocalAddress()).Port;
			conf.Set(ShufflePortConfigKey, Sharpen.Extensions.ToString(port));
			pipelineFact.Shuffle.SetPort(port);
			Log.Info(GetName() + " listening on port " + port);
			base.ServiceStart();
			sslFileBufferSize = conf.GetInt(SuffleSslFileBufferSizeKey, DefaultSuffleSslFileBufferSize
				);
			connectionKeepAliveEnabled = conf.GetBoolean(ShuffleConnectionKeepAliveEnabled, DefaultShuffleConnectionKeepAliveEnabled
				);
			connectionKeepAliveTimeOut = Math.Max(1, conf.GetInt(ShuffleConnectionKeepAliveTimeOut
				, DefaultShuffleConnectionKeepAliveTimeOut));
			mapOutputMetaInfoCacheSize = Math.Max(1, conf.GetInt(ShuffleMapoutputMetaInfoCacheSize
				, DefaultShuffleMapoutputMetaInfoCacheSize));
		}