示例#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));
		}
        private ServerBootstrap StartHttpServer(int port, Org.Apache.Hadoop.Security.Token.Token
                                                <DelegationTokenIdentifier> token, URI url)
        {
            ServerBootstrap bootstrap = new ServerBootstrap(new NioServerSocketChannelFactory
                                                                (Executors.NewCachedThreadPool(), Executors.NewCachedThreadPool()));

            bootstrap.SetPipelineFactory(new _ChannelPipelineFactory_362(token, url));
            bootstrap.Bind(new IPEndPoint("localhost", port));
            return(bootstrap);
        }
示例#4
0
        public virtual void InitServer(string fsimage)
        {
            FSImageLoader loader = FSImageLoader.Load(fsimage);

            bootstrap.ChildHandler(new _ChannelInitializer_92(this, loader));
            channel = bootstrap.Bind(address).Sync().Channel();
            allChannels.AddItem(channel);
            address = (IPEndPoint)channel.LocalAddress();
            Log.Info("WebImageViewer started. Listening on " + address.ToString() + ". Press Ctrl+C to stop the viewer."
                     );
        }
示例#5
0
 internal void Start(int idleTimeMilliSeconds, EndPoint tcpAddress, EndPoint udpAddress
                     )
 {
     tcpServer = new ServerBootstrap(new NioServerSocketChannelFactory(Executors.NewCachedThreadPool
                                                                           (), Executors.NewCachedThreadPool()));
     tcpServer.SetPipelineFactory(new _ChannelPipelineFactory_100(this, idleTimeMilliSeconds
                                                                  ));
     udpServer = new ConnectionlessBootstrap(new NioDatagramChannelFactory(Executors.NewCachedThreadPool
                                                                               ()));
     udpServer.SetPipeline(Channels.Pipeline(RpcUtil.StageRpcMessageParser, handler, RpcUtil
                                             .StageRpcUdpResponse));
     tcpChannel = tcpServer.Bind(tcpAddress);
     udpChannel = udpServer.Bind(udpAddress);
     allChannels.AddItem(tcpChannel);
     allChannels.AddItem(udpChannel);
     Log.Info("Portmap server started at tcp://" + tcpChannel.GetLocalAddress() + ", udp://"
              + udpChannel.GetLocalAddress());
 }
示例#6
0
 public virtual void Start()
 {
     if (httpServer != null)
     {
         ChannelFuture f = httpServer.Bind(DataNode.GetInfoAddr(conf));
         f.SyncUninterruptibly();
         httpAddress = (IPEndPoint)f.Channel().LocalAddress();
         Log.Info("Listening HTTP traffic on " + httpAddress);
     }
     if (httpsServer != null)
     {
         IPEndPoint secInfoSocAddr = NetUtils.CreateSocketAddr(conf.GetTrimmed(DFSConfigKeys
                                                                               .DfsDatanodeHttpsAddressKey, DFSConfigKeys.DfsDatanodeHttpsAddressDefault));
         ChannelFuture f = httpsServer.Bind(secInfoSocAddr);
         f.SyncUninterruptibly();
         httpsAddress = (IPEndPoint)f.Channel().LocalAddress();
         Log.Info("Listening HTTPS traffic on " + httpsAddress);
     }
 }