Search in sources :

Example 1 with TransportThrottleGroup

use of org.neo4j.bolt.transport.TransportThrottleGroup in project neo4j by neo4j.

the class BoltServer method init.

@Override
public void init() {
    Log log = logService.getInternalLog(BoltServer.class);
    boltMemoryPool = new BoltMemoryPool(memoryPools, NETTY_BUF_ALLOCATOR.metric());
    life.add(new BoltMemoryPoolLifeCycleAdapter(boltMemoryPool));
    InternalLoggerFactory.setDefaultFactory(new Netty4LoggerFactory(logService.getInternalLogProvider()));
    TransportThrottleGroup throttleGroup = new TransportThrottleGroup(config, clock);
    BoltSchedulerProvider boltSchedulerProvider = life.setLast(new ExecutorBoltSchedulerProvider(config, new CachedThreadPoolExecutorFactory(), jobScheduler, logService));
    BoltConnectionFactory boltConnectionFactory = createConnectionFactory(config, boltSchedulerProvider, logService, clock);
    BoltStateMachineFactory externalBoltStateMachineFactory = createBoltStateMachineFactory(createAuthentication(externalAuthManager), clock);
    BoltStateMachineFactory internalBoltStateMachineFactory = createBoltStateMachineFactory(createAuthentication(internalAuthManager), clock);
    BoltStateMachineFactory loopbackBoltStateMachineFactory = createBoltStateMachineFactory(createAuthentication(loopbackAuthManager), clock);
    BoltProtocolFactory externalBoltProtocolFactory = createBoltProtocolFactory(boltConnectionFactory, externalBoltStateMachineFactory, throttleGroup, clock, config.get(BoltConnectorInternalSettings.connection_keep_alive));
    BoltProtocolFactory internalBoltProtocolFactory = createBoltProtocolFactory(boltConnectionFactory, internalBoltStateMachineFactory, throttleGroup, clock, config.get(BoltConnectorInternalSettings.connection_keep_alive));
    BoltProtocolFactory loopbackBoltProtocolFactory = createBoltProtocolFactory(boltConnectionFactory, loopbackBoltStateMachineFactory, throttleGroup, clock, config.get(BoltConnectorInternalSettings.connection_keep_alive));
    if (config.get(CommonConnectorConfig.ocsp_stapling_enabled)) {
        enableOcspStapling();
    }
    ByteBufAllocator bufferAllocator = getBufferAllocator();
    if (config.get(BoltConnector.enabled)) {
        jobScheduler.setThreadFactory(Group.BOLT_NETWORK_IO, NettyThreadFactory::new);
        NettyServer nettyServer;
        var isNotReadReplica = config.get(GraphDatabaseSettings.mode) != GraphDatabaseSettings.Mode.READ_REPLICA;
        var loopbackProtocolInitializer = createLoopbackProtocolInitializer(loopbackBoltProtocolFactory, throttleGroup, bufferAllocator);
        if (config.get(GraphDatabaseSettings.routing_enabled) && isNotReadReplica) {
            nettyServer = new NettyServer(jobScheduler.threadFactory(Group.BOLT_NETWORK_IO), createExternalProtocolInitializer(externalBoltProtocolFactory, throttleGroup, log, bufferAllocator), createInternalProtocolInitializer(internalBoltProtocolFactory, throttleGroup, bufferAllocator), loopbackProtocolInitializer, connectorPortRegister, logService, config);
        } else {
            nettyServer = new NettyServer(jobScheduler.threadFactory(Group.BOLT_NETWORK_IO), createExternalProtocolInitializer(externalBoltProtocolFactory, throttleGroup, log, bufferAllocator), loopbackProtocolInitializer, connectorPortRegister, logService, config);
        }
        life.add(nettyServer);
        log.info("Bolt server loaded");
    }
    life.init();
}
Also used : BoltMemoryPool(org.neo4j.bolt.transport.BoltMemoryPool) ByteBufAllocator(io.netty.buffer.ByteBufAllocator) PooledByteBufAllocator(io.netty.buffer.PooledByteBufAllocator) DefaultBoltConnectionFactory(org.neo4j.bolt.runtime.DefaultBoltConnectionFactory) BoltConnectionFactory(org.neo4j.bolt.runtime.BoltConnectionFactory) Log(org.neo4j.logging.Log) BoltStateMachineFactory(org.neo4j.bolt.runtime.statemachine.BoltStateMachineFactory) ExecutorBoltSchedulerProvider(org.neo4j.bolt.runtime.scheduling.ExecutorBoltSchedulerProvider) NettyThreadFactory(org.neo4j.bolt.runtime.scheduling.NettyThreadFactory) BoltProtocolFactory(org.neo4j.bolt.transport.BoltProtocolFactory) DefaultBoltProtocolFactory(org.neo4j.bolt.transport.DefaultBoltProtocolFactory) NettyServer(org.neo4j.bolt.transport.NettyServer) CachedThreadPoolExecutorFactory(org.neo4j.bolt.runtime.scheduling.CachedThreadPoolExecutorFactory) ExecutorBoltSchedulerProvider(org.neo4j.bolt.runtime.scheduling.ExecutorBoltSchedulerProvider) BoltSchedulerProvider(org.neo4j.bolt.runtime.scheduling.BoltSchedulerProvider) Netty4LoggerFactory(org.neo4j.bolt.transport.Netty4LoggerFactory) TransportThrottleGroup(org.neo4j.bolt.transport.TransportThrottleGroup)

Aggregations

ByteBufAllocator (io.netty.buffer.ByteBufAllocator)1 PooledByteBufAllocator (io.netty.buffer.PooledByteBufAllocator)1 BoltConnectionFactory (org.neo4j.bolt.runtime.BoltConnectionFactory)1 DefaultBoltConnectionFactory (org.neo4j.bolt.runtime.DefaultBoltConnectionFactory)1 BoltSchedulerProvider (org.neo4j.bolt.runtime.scheduling.BoltSchedulerProvider)1 CachedThreadPoolExecutorFactory (org.neo4j.bolt.runtime.scheduling.CachedThreadPoolExecutorFactory)1 ExecutorBoltSchedulerProvider (org.neo4j.bolt.runtime.scheduling.ExecutorBoltSchedulerProvider)1 NettyThreadFactory (org.neo4j.bolt.runtime.scheduling.NettyThreadFactory)1 BoltStateMachineFactory (org.neo4j.bolt.runtime.statemachine.BoltStateMachineFactory)1 BoltMemoryPool (org.neo4j.bolt.transport.BoltMemoryPool)1 BoltProtocolFactory (org.neo4j.bolt.transport.BoltProtocolFactory)1 DefaultBoltProtocolFactory (org.neo4j.bolt.transport.DefaultBoltProtocolFactory)1 Netty4LoggerFactory (org.neo4j.bolt.transport.Netty4LoggerFactory)1 NettyServer (org.neo4j.bolt.transport.NettyServer)1 TransportThrottleGroup (org.neo4j.bolt.transport.TransportThrottleGroup)1 Log (org.neo4j.logging.Log)1