public async Task BindAsync() { var bossGroup = _eventLoopGroupFactory.GetBossGroup(); var workerGroup = _eventLoopGroupFactory.GetWorkerGroup(); var bootstrap = new ServerBootstrap(); bootstrap.ChannelFactory(() => new TcpServerSocketChannel()); bootstrap.Group(bossGroup, workerGroup); bootstrap.ChildHandler(_serverChannelInitializer); Channel = await bootstrap.BindAsync(IPAddress.Parse(_gameServerParameters.BindAddress), _gameServerParameters.Port); _logger.Information("Network Bound NIC IP: {0} Port: {1}", _gameServerParameters.BindAddress, _gameServerParameters.Port); }
/// <exception cref="System.IO.IOException"/> public DatanodeHttpServer(Configuration conf, DataNode datanode, ServerSocketChannel externalHttpChannel) { this.conf = conf; Configuration confForInfoServer = new Configuration(conf); confForInfoServer.SetInt(HttpServer2.HttpMaxThreads, 10); HttpServer2.Builder builder = new HttpServer2.Builder().SetName("datanode").SetConf (confForInfoServer).SetACL(new AccessControlList(conf.Get(DFSConfigKeys.DfsAdmin , " "))).HostName(GetHostnameForSpnegoPrincipal(confForInfoServer)).AddEndpoint( URI.Create("http://localhost:0")).SetFindPort(true); this.infoServer = builder.Build(); this.infoServer.AddInternalServlet(null, "/streamFile/*", typeof(StreamFile)); this.infoServer.AddInternalServlet(null, "/getFileChecksum/*", typeof(FileChecksumServlets.GetServlet )); this.infoServer.SetAttribute("datanode", datanode); this.infoServer.SetAttribute(JspHelper.CurrentConf, conf); this.infoServer.AddServlet(null, "/blockScannerReport", typeof(BlockScanner.Servlet )); this.infoServer.Start(); IPEndPoint jettyAddr = infoServer.GetConnectorAddress(0); this.confForCreate = new Configuration(conf); confForCreate.Set(FsPermission.UmaskLabel, "000"); this.bossGroup = new NioEventLoopGroup(); this.workerGroup = new NioEventLoopGroup(); this.externalHttpChannel = externalHttpChannel; HttpConfig.Policy policy = DFSUtil.GetHttpPolicy(conf); if (policy.IsHttpEnabled()) { this.httpServer = new ServerBootstrap().Group(bossGroup, workerGroup).ChildHandler (new _ChannelInitializer_117(this, jettyAddr, conf)); if (externalHttpChannel == null) { httpServer.Channel(typeof(NioServerSocketChannel)); } else { httpServer.ChannelFactory(new _ChannelFactory_130(externalHttpChannel)); } } else { // The channel has been bounded externally via JSVC, // thus bind() becomes a no-op. this.httpServer = null; } if (policy.IsHttpsEnabled()) { this.sslFactory = new SSLFactory(SSLFactory.Mode.Server, conf); try { sslFactory.Init(); } catch (GeneralSecurityException e) { throw new IOException(e); } this.httpsServer = new ServerBootstrap().Group(bossGroup, workerGroup).Channel(typeof( NioServerSocketChannel)).ChildHandler(new _ChannelInitializer_155(this, jettyAddr , conf)); } else { this.httpsServer = null; this.sslFactory = null; } }