Beispiel #1
0
        public virtual void Start()
        {
            _eventLoopGroup = new NioEventLoopGroup();
            ServerBootstrap bootstrap = (new ServerBootstrap()).group(_eventLoopGroup).channel(typeof(NioServerSocketChannel)).option(ChannelOption.SO_REUSEADDR, true).localAddress(0).childHandler(new ChannelInitializerAnonymousInnerClass(this));

            _channel = bootstrap.bind().syncUninterruptibly().channel();
        }
Beispiel #2
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected:
//ORIGINAL LINE: void start(final ApplicationProtocolRepository applicationProtocolRepository, final ModifierProtocolRepository modifierProtocolRepository)
            internal virtual void Start(ApplicationProtocolRepository applicationProtocolRepository, ModifierProtocolRepository modifierProtocolRepository)
            {
                EventLoopGroup = new NioEventLoopGroup();
                ServerBootstrap bootstrap = (new ServerBootstrap()).group(EventLoopGroup).channel(typeof(NioServerSocketChannel)).option(ChannelOption.SO_REUSEADDR, true).localAddress(0).childHandler(new ChannelInitializerAnonymousInnerClass(this, applicationProtocolRepository, modifierProtocolRepository));

                Channel = bootstrap.bind().syncUninterruptibly().channel();
            }
Beispiel #3
0
        protected internal override void Start0()
        {
            if (_channel != null)
            {
                return;
            }

            _workerGroup = new NioEventLoopGroup(0, _threadFactory);

            ServerBootstrap bootstrap = (new ServerBootstrap()).group(_workerGroup).channel(typeof(NioServerSocketChannel)).option(ChannelOption.SO_REUSEADDR, true).localAddress(_listenAddress.socketAddress()).childHandler(_childInitializer.asChannelInitializer());

            if (_parentHandler != null)
            {
                bootstrap.handler(_parentHandler);
            }

            try
            {
                _channel = bootstrap.bind().syncUninterruptibly().channel();
                _debugLog.info(_serverName + ": bound to " + _listenAddress);
            }
            catch (Exception e)
            {
                //noinspection ConstantConditions netty sneaky throw
                if (e is BindException)
                {
                    string message = _serverName + ": address is already bound: " + _listenAddress;
                    _userLog.error(message);
                    _debugLog.error(message, e);
                }
                throw e;
            }
        }
Beispiel #4
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected:
//ORIGINAL LINE: void start(final ApplicationProtocolRepository applicationProtocolRepository, final ModifierProtocolRepository modifierProtocolRepository, org.neo4j.logging.LogProvider logProvider)
            internal virtual void Start(ApplicationProtocolRepository applicationProtocolRepository, ModifierProtocolRepository modifierProtocolRepository, LogProvider logProvider)
            {
                RaftProtocolServerInstallerV2.Factory raftFactoryV2 = new RaftProtocolServerInstallerV2.Factory(nettyHandler, PipelineBuilderFactory, logProvider);
                RaftProtocolServerInstallerV1.Factory raftFactoryV1 = new RaftProtocolServerInstallerV1.Factory(nettyHandler, PipelineBuilderFactory, logProvider);
                ProtocolInstallerRepository <Org.Neo4j.causalclustering.protocol.ProtocolInstaller_Orientation_Server> protocolInstallerRepository = new ProtocolInstallerRepository <Org.Neo4j.causalclustering.protocol.ProtocolInstaller_Orientation_Server>(Arrays.asList(raftFactoryV1, raftFactoryV2), Org.Neo4j.causalclustering.protocol.ModifierProtocolInstaller_Fields.AllServerInstallers);

                EventLoopGroup = new NioEventLoopGroup();
                ServerBootstrap bootstrap = (new ServerBootstrap()).group(EventLoopGroup).channel(typeof(NioServerSocketChannel)).option(ChannelOption.SO_REUSEADDR, true).localAddress(PortAuthority.allocatePort()).childHandler((new HandshakeServerInitializer(applicationProtocolRepository, modifierProtocolRepository, protocolInstallerRepository, PipelineBuilderFactory, logProvider)).asChannelInitializer());

                Channel = bootstrap.bind().syncUninterruptibly().channel();
            }
Beispiel #5
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);
                }
            }
        }
Beispiel #6
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private int listen(int minPort, int maxPort) throws org.jboss.netty.channel.ChannelException
        private int Listen(int minPort, int maxPort)
        {
            ChannelException ex = null;

            for (int checkPort = minPort; checkPort <= maxPort; checkPort++)
            {
                try
                {
                    string            address = _config.clusterServer().Host;
                    InetSocketAddress localAddress;
                    if (string.ReferenceEquals(address, null) || address.Equals(INADDR_ANY))
                    {
                        localAddress = new InetSocketAddress(checkPort);
                    }
                    else
                    {
                        localAddress    = new InetSocketAddress(address, checkPort);
                        BindingDetected = true;
                    }

                    Channel listenChannel = _serverBootstrap.bind(localAddress);

                    ListeningAt(GetURI(localAddress));

                    _channels.add(listenChannel);
                    return(checkPort);
                }
                catch (ChannelException e)
                {
                    ex = e;
                }
            }

            _nioChannelFactory.releaseExternalResources();
            throw ex;
        }