Esempio n. 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()
        {
            if (Server == null)
            {
                Server = new PrometheusHttpServer(_hostnamePort.Host, _hostnamePort.Port);
                _portRegister.register("prometheus", Server.Address);
                _logger.info("Started publishing Prometheus metrics at http://" + Server.Address + "/metrics");
            }
        }
Esempio n. 2
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()
        {
            bool useEpoll = _useEpoll && Epoll.Available;
            ServerConfigurationProvider configurationProvider = useEpoll ? EpollConfigurationProvider.INSTANCE : NioConfigurationProvider.INSTANCE;

            _bossGroup = configurationProvider.CreateEventLoopGroup(1, _tf);

            // These threads handle live channels. Each thread has a set of channels it is responsible for, and it will
            // continuously run a #select() loop to react to new events on these channels.
            _selectorGroup = configurationProvider.CreateEventLoopGroup(_numSelectorThreads, _tf);

            // Bootstrap the various ports and protocols we want to handle

            foreach (KeyValuePair <BoltConnector, ProtocolInitializer> bootstrapEntry in _bootstrappersMap.SetOfKeyValuePairs())
            {
                try
                {
                    ProtocolInitializer protocolInitializer = bootstrapEntry.Value;
                    BoltConnector       boltConnector       = bootstrapEntry.Key;
                    ServerBootstrap     serverBootstrap     = CreateServerBootstrap(configurationProvider, protocolInitializer);
                    ChannelFuture       channelFuture       = serverBootstrap.bind(protocolInitializer.Address().socketAddress()).sync();
                    InetSocketAddress   localAddress        = ( InetSocketAddress )channelFuture.channel().localAddress();
                    _connectionRegister.register(boltConnector.Key(), localAddress);
                    string host = protocolInitializer.Address().Hostname;
                    int    port = localAddress.Port;
                    if (host.Contains(":"))
                    {
                        // IPv6
                        _log.info("Bolt enabled on [%s]:%s.", host, port);
                    }
                    else
                    {
                        // IPv4
                        _log.info("Bolt enabled on %s:%s.", host, port);
                    }
                }
                catch (Exception e)
                {
                    // We catch throwable here because netty uses clever tricks to have method signatures that look like they do not
                    // throw checked exceptions, but they actually do. The compiler won't let us catch them explicitly because in theory
                    // they shouldn't be possible, so we have to catch Throwable and do our own checks to grab them
                    throw new PortBindException(bootstrapEntry.Value.address(), e);
                }
            }
        }