@Override public void init() { fileWatchers = jobScheduler.threadFactory( Group.FILE_WATCHER ); }
@Override public ThreadFactory threadFactory( Group group ) { return delegate.threadFactory( group ); }
@Override public void start() { threadPool = executorFactory.create( corePoolSize, maxPoolSize, keepAlive, queueSize, true, new NameAppendingThreadFactory( connector, scheduler.threadFactory( Group.BOLT_WORKER ) ) ); }
@Before public void setup() { when( jobScheduler.threadFactory( any() ) ).thenReturn( Executors.defaultThreadFactory() ); }
@Before public void setup() throws Throwable { when( jobScheduler.threadFactory( any() ) ).thenReturn( Executors.defaultThreadFactory() ); boltScheduler.start(); }
@Test public void initShouldCreateThreadPool() throws Throwable { ExecutorFactory mockExecutorFactory = mock( ExecutorFactory.class ); when( mockExecutorFactory.create( anyInt(), anyInt(), any(), anyInt(), anyBoolean(), any() ) ).thenReturn( Executors.newCachedThreadPool() ); ExecutorBoltScheduler scheduler = new ExecutorBoltScheduler( CONNECTOR_KEY, mockExecutorFactory, jobScheduler, logService, 0, 10, Duration.ofMinutes( 1 ), 0, ForkJoinPool.commonPool() ); scheduler.start(); verify( jobScheduler ).threadFactory( Group.BOLT_WORKER ); verify( mockExecutorFactory, times( 1 ) ).create( anyInt(), anyInt(), any( Duration.class ), anyInt(), anyBoolean(), any( ThreadFactory.class ) ); }
@Override public void start() throws Throwable { Log log = logService.getInternalLog( BoltServer.class ); Log userLog = logService.getUserLog( BoltServer.class ); InternalLoggerFactory.setDefaultFactory( new Netty4LoggerFactory( logService.getInternalLogProvider() ) ); 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().isEmpty() && !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 }
@Override public void init() { fileWatchers = jobScheduler.threadFactory( Group.FILE_WATCHER ); }
private ExecutorService buildExecutorService( JobScheduler scheduler ) { BlockingQueue<Runnable> workQueue = new LinkedBlockingQueue<>( IO_PARALLELISM * 4 ); RejectedExecutionHandler rejectionPolicy = new ThreadPoolExecutor.CallerRunsPolicy(); ThreadFactory threadFactory = scheduler.threadFactory( JobScheduler.Groups.pageCacheIOHelper ); return new ThreadPoolExecutor( 0, IO_PARALLELISM, 10, TimeUnit.SECONDS, workQueue, threadFactory, rejectionPolicy ); }
@Override public void start() { threadPool = executorFactory.create( corePoolSize, maxPoolSize, keepAlive, queueSize, true, new NameAppendingThreadFactory( connector, scheduler.threadFactory( Group.BOLT_WORKER ) ) ); }
private LifecycleMessageHandler<ReceivedInstantClusterIdAwareMessage<?>> createMessageHandlerChain( CoreServerModule coreServerModule ) { RaftMessageApplier messageApplier = new RaftMessageApplier( localDatabase, logProvider, consensusModule.raftMachine(), coreServerModule.downloadService(), coreServerModule.commandApplicationProcess(), catchupAddressProvider ); ComposableMessageHandler monitoringHandler = RaftMessageMonitoringHandler.composable( platformModule.clock, platformModule.monitors ); int queueSize = platformModule.config.get( CausalClusteringSettings.raft_in_queue_size ); int maxBatch = platformModule.config.get( CausalClusteringSettings.raft_in_queue_max_batch ); Function<Runnable, ContinuousJob> jobFactory = runnable -> new ContinuousJob( platformModule.jobScheduler.threadFactory( new JobScheduler.Group( "raft-batch-handler" ) ), runnable, logProvider ); ComposableMessageHandler batchingMessageHandler = BatchingMessageHandler.composable( queueSize, maxBatch, jobFactory, logProvider ); ComposableMessageHandler leaderAvailabilityHandler = LeaderAvailabilityHandler.composable( consensusModule.getLeaderAvailabilityTimers(), consensusModule.raftMachine()::term ); ComposableMessageHandler clusterBindingHandler = ClusterBindingHandler.composable( logProvider ); return clusterBindingHandler .compose( leaderAvailabilityHandler ) .compose( batchingMessageHandler ) .compose( monitoringHandler ) .apply( messageApplier ); } }
@Override public void start() throws Throwable { Log log = logService.getInternalLog( BoltServer.class ); Log userLog = logService.getUserLog( BoltServer.class ); InternalLoggerFactory.setDefaultFactory( new Netty4LoggerFactory( logService.getInternalLogProvider() ) ); 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().isEmpty() && !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 }