Search in sources :

Example 1 with TransactionMonitorScheduler

use of org.neo4j.kernel.impl.api.transaction.monitor.TransactionMonitorScheduler in project neo4j by neo4j.

the class Database method buildTransactionMonitor.

private void buildTransactionMonitor(KernelTransactions kernelTransactions, Config config) {
    KernelTransactionMonitor kernelTransactionTimeoutMonitor = new KernelTransactionMonitor(kernelTransactions, clock, databaseLogService);
    databaseDependencies.satisfyDependency(kernelTransactionTimeoutMonitor);
    TransactionMonitorScheduler transactionMonitorScheduler = new TransactionMonitorScheduler(kernelTransactionTimeoutMonitor, scheduler, config.get(GraphDatabaseSettings.transaction_monitor_check_interval).toMillis(), namedDatabaseId.name());
    life.add(transactionMonitorScheduler);
}
Also used : KernelTransactionMonitor(org.neo4j.kernel.impl.api.transaction.monitor.KernelTransactionMonitor) TransactionMonitorScheduler(org.neo4j.kernel.impl.api.transaction.monitor.TransactionMonitorScheduler)

Example 2 with TransactionMonitorScheduler

use of org.neo4j.kernel.impl.api.transaction.monitor.TransactionMonitorScheduler in project neo4j by neo4j.

the class FabricServicesBootstrap method bootstrapServices.

public void bootstrapServices() {
    LogProvider internalLogProvider = logService.getInternalLogProvider();
    @SuppressWarnings("unchecked") var databaseManager = (DatabaseManager<DatabaseContext>) resolve(DatabaseManager.class);
    var fabricDatabaseManager = register(createFabricDatabaseManager(fabricConfig), FabricDatabaseManager.class);
    var jobScheduler = resolve(JobScheduler.class);
    var monitors = resolve(Monitors.class);
    var databaseAccess = createFabricDatabaseAccess();
    var remoteExecutor = bootstrapRemoteStack();
    var localExecutor = register(new FabricLocalExecutor(fabricConfig, fabricDatabaseManager, databaseAccess), FabricLocalExecutor.class);
    var systemNanoClock = resolve(SystemNanoClock.class);
    var transactionMonitor = register(new FabricTransactionMonitor(systemNanoClock, logService, fabricConfig), FabricTransactionMonitor.class);
    var transactionCheckInterval = config.get(GraphDatabaseSettings.transaction_monitor_check_interval).toMillis();
    register(new TransactionMonitorScheduler(transactionMonitor, jobScheduler, transactionCheckInterval, null), TransactionMonitorScheduler.class);
    var errorReporter = new ErrorReporter(logService);
    register(new TransactionManager(remoteExecutor, localExecutor, errorReporter, fabricConfig, transactionMonitor, securityLog, systemNanoClock, config, availabilityGuard), TransactionManager.class);
    var cypherConfig = CypherConfiguration.fromConfig(config);
    Supplier<GlobalProcedures> proceduresSupplier = () -> resolve(GlobalProcedures.class);
    var catalogManager = register(createCatalogManger(), CatalogManager.class);
    var signatureResolver = new SignatureResolver(proceduresSupplier);
    var statementLifecycles = new FabricStatementLifecycles(databaseManager, monitors, config, systemNanoClock);
    var monitoredExecutor = jobScheduler.monitoredJobExecutor(CYPHER_CACHE);
    var cacheFactory = new ExecutorBasedCaffeineCacheFactory(job -> monitoredExecutor.execute(systemJob("Query plan cache maintenance"), job));
    var planner = register(new FabricPlanner(fabricConfig, cypherConfig, monitors, cacheFactory, signatureResolver), FabricPlanner.class);
    var useEvaluation = register(new UseEvaluation(catalogManager, proceduresSupplier, signatureResolver), UseEvaluation.class);
    register(new FabricReactorHooksService(errorReporter), FabricReactorHooksService.class);
    Executor fabricWorkerExecutor = jobScheduler.executor(FABRIC_WORKER);
    var fabricExecutor = new FabricExecutor(fabricConfig, planner, useEvaluation, catalogManager, internalLogProvider, statementLifecycles, fabricWorkerExecutor);
    register(fabricExecutor, FabricExecutor.class);
    register(new TransactionBookmarkManagerFactory(fabricDatabaseManager), TransactionBookmarkManagerFactory.class);
}
Also used : FabricStatementLifecycles(org.neo4j.fabric.executor.FabricStatementLifecycles) FabricExecutor(org.neo4j.fabric.executor.FabricExecutor) DatabaseManager(org.neo4j.dbms.database.DatabaseManager) FabricDatabaseManager(org.neo4j.fabric.FabricDatabaseManager) SignatureResolver(org.neo4j.fabric.pipeline.SignatureResolver) UseEvaluation(org.neo4j.fabric.eval.UseEvaluation) FabricTransactionMonitor(org.neo4j.fabric.transaction.FabricTransactionMonitor) TransactionMonitorScheduler(org.neo4j.kernel.impl.api.transaction.monitor.TransactionMonitorScheduler) GlobalProcedures(org.neo4j.kernel.api.procedure.GlobalProcedures) LogProvider(org.neo4j.logging.LogProvider) ErrorReporter(org.neo4j.fabric.transaction.ErrorReporter) FabricLocalExecutor(org.neo4j.fabric.executor.FabricLocalExecutor) ThrowingFabricRemoteExecutor(org.neo4j.fabric.executor.ThrowingFabricRemoteExecutor) FabricRemoteExecutor(org.neo4j.fabric.executor.FabricRemoteExecutor) Executor(java.util.concurrent.Executor) FabricExecutor(org.neo4j.fabric.executor.FabricExecutor) FabricLocalExecutor(org.neo4j.fabric.executor.FabricLocalExecutor) ExecutorBasedCaffeineCacheFactory(org.neo4j.cypher.internal.cache.ExecutorBasedCaffeineCacheFactory) TransactionBookmarkManagerFactory(org.neo4j.fabric.bookmark.TransactionBookmarkManagerFactory) TransactionManager(org.neo4j.fabric.transaction.TransactionManager) FabricPlanner(org.neo4j.fabric.planning.FabricPlanner)

Example 3 with TransactionMonitorScheduler

use of org.neo4j.kernel.impl.api.transaction.monitor.TransactionMonitorScheduler in project neo4j by neo4j.

the class KernelTransactionMonitorSchedulerTest method scheduleRecurringMonitorJobIfConfigured.

@Test
void scheduleRecurringMonitorJobIfConfigured() {
    TransactionMonitorScheduler transactionMonitorScheduler = createMonitorScheduler(1);
    transactionMonitorScheduler.start();
    verify(scheduler).scheduleRecurring(eq(Group.TRANSACTION_TIMEOUT_MONITOR), any(JobMonitoringParams.class), eq(transactionTimeoutMonitor), eq(1L), eq(TimeUnit.MILLISECONDS));
}
Also used : JobMonitoringParams(org.neo4j.scheduler.JobMonitoringParams) TransactionMonitorScheduler(org.neo4j.kernel.impl.api.transaction.monitor.TransactionMonitorScheduler) Test(org.junit.jupiter.api.Test)

Example 4 with TransactionMonitorScheduler

use of org.neo4j.kernel.impl.api.transaction.monitor.TransactionMonitorScheduler in project neo4j by neo4j.

the class KernelTransactionMonitorSchedulerTest method doNotScheduleMonitorJobIfDisabled.

@Test
void doNotScheduleMonitorJobIfDisabled() {
    TransactionMonitorScheduler transactionMonitorScheduler = createMonitorScheduler(0);
    transactionMonitorScheduler.start();
    verifyNoInteractions(scheduler);
}
Also used : TransactionMonitorScheduler(org.neo4j.kernel.impl.api.transaction.monitor.TransactionMonitorScheduler) Test(org.junit.jupiter.api.Test)

Example 5 with TransactionMonitorScheduler

use of org.neo4j.kernel.impl.api.transaction.monitor.TransactionMonitorScheduler in project neo4j by neo4j.

the class KernelTransactionTimeoutMonitorSchedulerTest method startJobTransactionMonitor.

@Test
void startJobTransactionMonitor() {
    JobHandle jobHandle = Mockito.mock(JobHandle.class);
    when(jobScheduler.scheduleRecurring(eq(Group.TRANSACTION_TIMEOUT_MONITOR), any(JobMonitoringParams.class), eq(transactionMonitor), anyLong(), any(TimeUnit.class))).thenReturn(jobHandle);
    TransactionMonitorScheduler monitorScheduler = new TransactionMonitorScheduler(transactionMonitor, jobScheduler, 7, "test database");
    monitorScheduler.start();
    verify(jobScheduler).scheduleRecurring(eq(Group.TRANSACTION_TIMEOUT_MONITOR), any(JobMonitoringParams.class), eq(transactionMonitor), eq(7L), eq(TimeUnit.MILLISECONDS));
    monitorScheduler.stop();
    verify(jobHandle).cancel();
}
Also used : JobHandle(org.neo4j.scheduler.JobHandle) TimeUnit(java.util.concurrent.TimeUnit) JobMonitoringParams(org.neo4j.scheduler.JobMonitoringParams) TransactionMonitorScheduler(org.neo4j.kernel.impl.api.transaction.monitor.TransactionMonitorScheduler) Test(org.junit.jupiter.api.Test)

Aggregations

TransactionMonitorScheduler (org.neo4j.kernel.impl.api.transaction.monitor.TransactionMonitorScheduler)5 Test (org.junit.jupiter.api.Test)3 JobMonitoringParams (org.neo4j.scheduler.JobMonitoringParams)2 Executor (java.util.concurrent.Executor)1 TimeUnit (java.util.concurrent.TimeUnit)1 ExecutorBasedCaffeineCacheFactory (org.neo4j.cypher.internal.cache.ExecutorBasedCaffeineCacheFactory)1 DatabaseManager (org.neo4j.dbms.database.DatabaseManager)1 FabricDatabaseManager (org.neo4j.fabric.FabricDatabaseManager)1 TransactionBookmarkManagerFactory (org.neo4j.fabric.bookmark.TransactionBookmarkManagerFactory)1 UseEvaluation (org.neo4j.fabric.eval.UseEvaluation)1 FabricExecutor (org.neo4j.fabric.executor.FabricExecutor)1 FabricLocalExecutor (org.neo4j.fabric.executor.FabricLocalExecutor)1 FabricRemoteExecutor (org.neo4j.fabric.executor.FabricRemoteExecutor)1 FabricStatementLifecycles (org.neo4j.fabric.executor.FabricStatementLifecycles)1 ThrowingFabricRemoteExecutor (org.neo4j.fabric.executor.ThrowingFabricRemoteExecutor)1 SignatureResolver (org.neo4j.fabric.pipeline.SignatureResolver)1 FabricPlanner (org.neo4j.fabric.planning.FabricPlanner)1 ErrorReporter (org.neo4j.fabric.transaction.ErrorReporter)1 FabricTransactionMonitor (org.neo4j.fabric.transaction.FabricTransactionMonitor)1 TransactionManager (org.neo4j.fabric.transaction.TransactionManager)1