Example #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()
        {
            Log log     = _logService.getInternalLog(typeof(BoltServer));
            Log userLog = _logService.getUserLog(typeof(BoltServer));

            InternalLoggerFactory.DefaultFactory = new Netty4LoggerFactory(_logService.InternalLogProvider);

            Authentication authentication = CreateAuthentication();

            TransportThrottleGroup throttleGroup = new TransportThrottleGroup(_config, _clock);

            BoltSchedulerProvider   boltSchedulerProvider   = _life.add(new ExecutorBoltSchedulerProvider(_config, new CachedThreadPoolExecutorFactory(log), _jobScheduler, _logService));
            BoltConnectionFactory   boltConnectionFactory   = CreateConnectionFactory(_config, boltSchedulerProvider, throttleGroup, _logService, _clock);
            BoltStateMachineFactory boltStateMachineFactory = CreateBoltFactory(authentication, _clock);

            BoltProtocolFactory boltProtocolFactory = CreateBoltProtocolFactory(boltConnectionFactory, boltStateMachineFactory);

            if (_config.enabledBoltConnectors().Count > 0 && !_config.get(GraphDatabaseSettings.disconnected))
            {
                NettyServer server = new NettyServer(_jobScheduler.threadFactory(Group.BOLT_NETWORK_IO), CreateConnectors(boltProtocolFactory, throttleGroup, log), _connectorPortRegister, userLog);
                _life.add(server);
                log.Info("Bolt server loaded");
            }

            _life.start();               // init and start the nested lifecycle
        }
Example #2
0
 public ChunkedOutput(Channel channel, int maxBufferSize, int maxChunkSize, TransportThrottleGroup throttleGroup)
 {
     this._channel       = Objects.requireNonNull(channel);
     this._maxBufferSize = maxBufferSize;
     this._maxChunkSize  = maxChunkSize;
     this._buffer        = AllocateBuffer();
     this._throttleGroup = Objects.requireNonNull(throttleGroup);
 }
Example #3
0
 public ChunkedOutput(Channel ch, int bufferSize, TransportThrottleGroup throttleGroup) : this(ch, bufferSize, _maxChunkSize, throttleGroup)
 {
 }
Example #4
0
 public ChunkedOutput(Channel ch, TransportThrottleGroup throttleGroup) : this(ch, DEFAULT_BUFFER_SIZE, throttleGroup)
 {
 }
Example #5
0
        private NettyServer.ProtocolInitializer CreateProtocolInitializer(BoltConnector connector, BoltProtocolFactory boltProtocolFactory, TransportThrottleGroup throttleGroup, Log log)
        {
            SslContext sslCtx;
            bool       requireEncryption;

            BoltConnector.EncryptionLevel encryptionLevel = _config.get(connector.EncryptionLevel);
            SslPolicyLoader sslPolicyLoader = _dependencyResolver.resolveDependency(typeof(SslPolicyLoader));

            switch (encryptionLevel)
            {
            case BoltConnector.EncryptionLevel.REQUIRED:
                // Encrypted connections are mandatory, a self-signed certificate may be generated.
                requireEncryption = true;
                sslCtx            = CreateSslContext(sslPolicyLoader, _config);
                break;

            case BoltConnector.EncryptionLevel.OPTIONAL:
                // Encrypted connections are optional, a self-signed certificate may be generated.
                requireEncryption = false;
                sslCtx            = CreateSslContext(sslPolicyLoader, _config);
                break;

            case BoltConnector.EncryptionLevel.DISABLED:
                // Encryption is turned off, no self-signed certificate will be generated.
                requireEncryption = false;
                sslCtx            = null;
                break;

            default:
                // In the unlikely event that we happen to fall through to the default option here,
                // there is a mismatch between the BoltConnector.EncryptionLevel enum and the options
                // handled in this switch statement. In this case, we'll log a warning and default to
                // disabling encryption, since this mirrors the functionality introduced in 3.0.
                log.Warn("Unhandled encryption level %s - assuming DISABLED.", encryptionLevel.name());
                requireEncryption = false;
                sslCtx            = null;
                break;
            }

            ListenSocketAddress listenAddress = _config.get(connector.ListenAddress);

            return(new SocketTransport(connector.Key(), listenAddress, sslCtx, requireEncryption, _logService.InternalLogProvider, throttleGroup, boltProtocolFactory, _connectionTracker));
        }
Example #6
0
 private IDictionary <BoltConnector, NettyServer.ProtocolInitializer> CreateConnectors(BoltProtocolFactory boltProtocolFactory, TransportThrottleGroup throttleGroup, Log log)
 {
     return(_config.enabledBoltConnectors().ToDictionary(identity(), connector => CreateProtocolInitializer(connector, boltProtocolFactory, throttleGroup, log)));
 }
Example #7
0
 private BoltConnectionFactory CreateConnectionFactory(Config config, BoltSchedulerProvider schedulerProvider, TransportThrottleGroup throttleGroup, LogService logService, Clock clock)
 {
     return(new DefaultBoltConnectionFactory(schedulerProvider, throttleGroup, config, logService, clock, _monitors));
 }