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); }
// 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)); }
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()); }
public virtual void Run() { // Configure the client. DatagramChannelFactory f = new NioDatagramChannelFactory(Executors.NewCachedThreadPool (), workerCount); server = new ConnectionlessBootstrap(f); server.SetPipeline(Channels.Pipeline(RpcUtil.StageRpcMessageParser, rpcProgram, RpcUtil .StageRpcUdpResponse)); server.SetOption("broadcast", "false"); server.SetOption("sendBufferSize", SendBufferSize); server.SetOption("receiveBufferSize", ReceiveBufferSize); // Listen to the UDP port ch = server.Bind(new IPEndPoint(port)); IPEndPoint socketAddr = (IPEndPoint)ch.GetLocalAddress(); boundPort = socketAddr.Port; Log.Info("Started listening to UDP requests at port " + boundPort + " for " + rpcProgram + " with workerCount " + workerCount); }
internal EndPoint GetUdpServerLoAddress() { return(udpChannel.GetLocalAddress()); }
internal EndPoint GetTcpServerLocalAddress() { return(tcpChannel.GetLocalAddress()); }