Search in sources :

Example 6 with Monitors

use of org.neo4j.monitoring.Monitors in project neo4j by neo4j.

the class Database method init.

/**
 * Initialize the database, and bring it to a state where its version can be examined, and it can be
 * upgraded if necessary.
 */
@Override
public synchronized void init() {
    if (initialized) {
        return;
    }
    try {
        databaseDependencies = new Dependencies(globalDependencies);
        ioController = ioControllerService.createIOController(databaseConfig, clock);
        databasePageCache = new DatabasePageCache(globalPageCache, ioController);
        databaseMonitors = new Monitors(parentMonitors, internalLogProvider);
        life = new LifeSupport();
        life.add(new LockerLifecycleAdapter(fileLockerService.createDatabaseLocker(fs, databaseLayout)));
        life.add(databaseConfig);
        databaseHealth = databaseHealthFactory.newInstance();
        databaseAvailability = new DatabaseAvailability(databaseAvailabilityGuard, transactionStats, clock, getAwaitActiveTransactionDeadlineMillis());
        databaseDependencies.satisfyDependency(this);
        databaseDependencies.satisfyDependency(ioController);
        databaseDependencies.satisfyDependency(readOnlyDatabaseChecker);
        databaseDependencies.satisfyDependency(databaseLayout);
        databaseDependencies.satisfyDependency(startupController);
        databaseDependencies.satisfyDependency(databaseConfig);
        databaseDependencies.satisfyDependency(databaseMonitors);
        databaseDependencies.satisfyDependency(databaseLogService);
        databaseDependencies.satisfyDependency(databasePageCache);
        databaseDependencies.satisfyDependency(tokenHolders);
        databaseDependencies.satisfyDependency(databaseFacade);
        databaseDependencies.satisfyDependency(kernelTransactionFactory);
        databaseDependencies.satisfyDependency(databaseHealth);
        databaseDependencies.satisfyDependency(storeCopyCheckPointMutex);
        databaseDependencies.satisfyDependency(transactionStats);
        databaseDependencies.satisfyDependency(locks);
        databaseDependencies.satisfyDependency(databaseAvailabilityGuard);
        databaseDependencies.satisfyDependency(databaseAvailability);
        databaseDependencies.satisfyDependency(idGeneratorFactory);
        databaseDependencies.satisfyDependency(idController);
        databaseDependencies.satisfyDependency(lockService);
        databaseDependencies.satisfyDependency(versionContextSupplier);
        databaseDependencies.satisfyDependency(tracers.getDatabaseTracer());
        databaseDependencies.satisfyDependency(tracers.getPageCacheTracer());
        databaseDependencies.satisfyDependency(storageEngineFactory);
        recoveryCleanupWorkCollector = RecoveryCleanupWorkCollector.immediate();
        databaseDependencies.satisfyDependency(recoveryCleanupWorkCollector);
        life.add(new PageCacheLifecycle(databasePageCache));
        life.add(initializeExtensions(databaseDependencies));
        DatabaseLayoutWatcher watcherService = watcherServiceFactory.apply(databaseLayout);
        life.add(watcherService);
        databaseDependencies.satisfyDependency(watcherService);
        otherDatabasePool = otherMemoryPool.newDatabasePool(namedDatabaseId.name(), 0, null);
        life.add(onShutdown(() -> otherDatabasePool.close()));
        otherDatabaseMemoryTracker = otherDatabasePool.getPoolMemoryTracker();
        databaseDependencies.satisfyDependency(new DatabaseMemoryTrackers(otherDatabaseMemoryTracker));
        eventListeners.databaseCreate(namedDatabaseId);
        initialized = true;
    } catch (Throwable e) {
        handleStartupFailure(e);
    }
}
Also used : DatabaseLayoutWatcher(org.neo4j.io.fs.watcher.DatabaseLayoutWatcher) LockerLifecycleAdapter(org.neo4j.kernel.internal.locker.LockerLifecycleAdapter) Monitors(org.neo4j.monitoring.Monitors) LifeSupport(org.neo4j.kernel.lifecycle.LifeSupport) DatabaseAvailability(org.neo4j.kernel.availability.DatabaseAvailability) Dependencies(org.neo4j.collection.Dependencies) DatabasePageCache(org.neo4j.dbms.database.DatabasePageCache) PageCacheLifecycle(org.neo4j.kernel.impl.pagecache.PageCacheLifecycle)

Example 7 with Monitors

use of org.neo4j.monitoring.Monitors in project neo4j by neo4j.

the class TokenIndexPopulatorTest method shouldRelayMonitorCallsToRegisteredGBPTreeMonitorWithoutTag.

@Test
void shouldRelayMonitorCallsToRegisteredGBPTreeMonitorWithoutTag() throws IOException {
    // Given
    AtomicBoolean checkpointCompletedCall = new AtomicBoolean();
    Monitors monitors = new Monitors();
    monitors.addMonitorListener(getCheckpointCompletedListener(checkpointCompletedCall));
    populator = createPopulator(pageCache, monitors, "tag");
    // When
    populator.create();
    populator.close(true, NULL);
    // Then
    assertTrue(checkpointCompletedCall.get());
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Monitors(org.neo4j.monitoring.Monitors) Test(org.junit.jupiter.api.Test)

Example 8 with Monitors

use of org.neo4j.monitoring.Monitors in project neo4j by neo4j.

the class TokenIndexPopulatorTest method shouldRelayMonitorCallsToRegisteredGBPTreeMonitorWithTag.

@Test
void shouldRelayMonitorCallsToRegisteredGBPTreeMonitorWithTag() throws IOException {
    // Given
    AtomicBoolean checkpointCompletedCall = new AtomicBoolean();
    Monitors monitors = new Monitors();
    monitors.addMonitorListener(getCheckpointCompletedListener(checkpointCompletedCall), "tag");
    populator = createPopulator(pageCache, monitors, "tag");
    // When
    populator.create();
    populator.close(true, NULL);
    // Then
    assertTrue(checkpointCompletedCall.get());
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Monitors(org.neo4j.monitoring.Monitors) Test(org.junit.jupiter.api.Test)

Example 9 with Monitors

use of org.neo4j.monitoring.Monitors in project neo4j by neo4j.

the class ExecutionEngine method makeExecutionEngine.

protected static org.neo4j.cypher.internal.ExecutionEngine makeExecutionEngine(GraphDatabaseQueryService queryService, CaffeineCacheFactory cacheFactory, LogProvider logProvider, CompilerLibrary compilerLibrary) {
    DependencyResolver resolver = queryService.getDependencyResolver();
    Monitors monitors = resolver.resolveDependency(Monitors.class);
    MonitoringCacheTracer cacheTracer = new MonitoringCacheTracer(monitors.newMonitor(ExecutionEngineQueryCacheMonitor.class));
    Config config = resolver.resolveDependency(Config.class);
    CypherConfiguration cypherConfiguration = CypherConfiguration.fromConfig(config);
    CompilationTracer tracer = new TimingCompilationTracer(monitors.newMonitor(TimingCompilationTracer.EventListener.class));
    return new org.neo4j.cypher.internal.ExecutionEngine(queryService, monitors, tracer, cacheTracer, cypherConfiguration, compilerLibrary, cacheFactory, logProvider, Clock.systemUTC());
}
Also used : TimingCompilationTracer(org.neo4j.cypher.internal.tracing.TimingCompilationTracer) CompilationTracer(org.neo4j.cypher.internal.tracing.CompilationTracer) QueryExecutionEngine(org.neo4j.kernel.impl.query.QueryExecutionEngine) ExecutionEngineQueryCacheMonitor(org.neo4j.cypher.internal.ExecutionEngineQueryCacheMonitor) Config(org.neo4j.configuration.Config) Monitors(org.neo4j.monitoring.Monitors) TimingCompilationTracer(org.neo4j.cypher.internal.tracing.TimingCompilationTracer) CypherConfiguration(org.neo4j.cypher.internal.config.CypherConfiguration) DependencyResolver(org.neo4j.common.DependencyResolver)

Example 10 with Monitors

use of org.neo4j.monitoring.Monitors in project neo4j by neo4j.

the class Recovery method instantiateRecoveryExtensions.

private static DatabaseExtensions instantiateRecoveryExtensions(DatabaseLayout databaseLayout, FileSystemAbstraction fileSystem, Config config, LogService logService, PageCache pageCache, JobScheduler jobScheduler, DbmsInfo dbmsInfo, Monitors monitors, TokenHolders tokenHolders, RecoveryCleanupWorkCollector recoveryCleanupCollector, DatabaseReadOnlyChecker readOnlyChecker, Iterable<ExtensionFactory<?>> extensionFactories, PageCacheTracer pageCacheTracer) {
    List<ExtensionFactory<?>> recoveryExtensions = stream(extensionFactories).filter(extension -> extension.getClass().isAnnotationPresent(RecoveryExtension.class)).collect(toList());
    Dependencies deps = new Dependencies();
    NonListenableMonitors nonListenableMonitors = new NonListenableMonitors(monitors, logService.getInternalLogProvider());
    deps.satisfyDependencies(fileSystem, config, logService, pageCache, nonListenableMonitors, jobScheduler, tokenHolders, recoveryCleanupCollector, pageCacheTracer, databaseLayout, readOnlyChecker);
    DatabaseExtensionContext extensionContext = new DatabaseExtensionContext(databaseLayout, dbmsInfo, deps);
    return new DatabaseExtensions(extensionContext, recoveryExtensions, deps, ExtensionFailureStrategies.fail());
}
Also used : DatabaseExtensionContext(org.neo4j.kernel.extension.context.DatabaseExtensionContext) DefaultIdController(org.neo4j.internal.id.DefaultIdController) LogFilesBuilder(org.neo4j.kernel.impl.transaction.log.files.LogFilesBuilder) Config(org.neo4j.configuration.Config) NullLogProvider(org.neo4j.logging.NullLogProvider) VersionAwareLogEntryReader(org.neo4j.kernel.impl.transaction.log.entry.VersionAwareLogEntryReader) IndexStatisticsStore(org.neo4j.kernel.impl.api.index.stats.IndexStatisticsStore) DatabasePageCache(org.neo4j.dbms.database.DatabasePageCache) ReadOnlyTokenCreator(org.neo4j.token.ReadOnlyTokenCreator) PageCacheTracer(org.neo4j.io.pagecache.tracing.PageCacheTracer) RecoveryCleanupWorkCollector(org.neo4j.index.internal.gbptree.RecoveryCleanupWorkCollector) NullLog(org.neo4j.logging.NullLog) Path(java.nio.file.Path) INDEX_CLEANUP_WORK(org.neo4j.scheduler.Group.INDEX_CLEANUP_WORK) EMPTY_CHECKER(org.neo4j.kernel.recovery.RecoveryStartupChecker.EMPTY_CHECKER) TransactionLogFilesHelper(org.neo4j.kernel.impl.transaction.log.files.TransactionLogFilesHelper) StorageFilesState(org.neo4j.storageengine.api.StorageFilesState) Dependencies(org.neo4j.collection.Dependencies) IOController(org.neo4j.io.pagecache.IOController) FullScanStoreView(org.neo4j.kernel.impl.transaction.state.storeview.FullScanStoreView) Services(org.neo4j.service.Services) SimpleTriggerInfo(org.neo4j.kernel.impl.transaction.log.checkpoint.SimpleTriggerInfo) Database(org.neo4j.kernel.database.Database) DefaultIdGeneratorFactory(org.neo4j.internal.id.DefaultIdGeneratorFactory) Tracers(org.neo4j.kernel.monitoring.tracing.Tracers) VersionContextSupplier(org.neo4j.io.pagecache.context.VersionContextSupplier) IndexingService(org.neo4j.kernel.impl.api.index.IndexingService) RecoveryThreshold(org.neo4j.kernel.impl.transaction.log.checkpoint.RecoveryThreshold) DefaultForceOperation(org.neo4j.kernel.database.DefaultForceOperation) DelegatingTokenHolder(org.neo4j.token.DelegatingTokenHolder) TYPE_PROPERTY_KEY(org.neo4j.token.api.TokenHolder.TYPE_PROPERTY_KEY) DatabaseExtensions(org.neo4j.kernel.extension.DatabaseExtensions) DefaultIndexProviderMap(org.neo4j.kernel.impl.transaction.state.DefaultIndexProviderMap) MemoryTracker(org.neo4j.memory.MemoryTracker) Lifecycle(org.neo4j.kernel.lifecycle.Lifecycle) PanicEventGenerator(org.neo4j.monitoring.PanicEventGenerator) TransactionMetadataCache(org.neo4j.kernel.impl.transaction.log.TransactionMetadataCache) IOException(java.io.IOException) DatabaseTracers(org.neo4j.kernel.database.DatabaseTracers) ExtensionFactory(org.neo4j.kernel.extension.ExtensionFactory) TokenHolders(org.neo4j.token.TokenHolders) TYPE_LABEL(org.neo4j.token.api.TokenHolder.TYPE_LABEL) StoreCopyCheckPointMutex(org.neo4j.kernel.impl.transaction.log.checkpoint.StoreCopyCheckPointMutex) LifecycleAdapter(org.neo4j.kernel.lifecycle.LifecycleAdapter) Log(org.neo4j.logging.Log) BatchingTransactionAppender(org.neo4j.kernel.impl.transaction.log.BatchingTransactionAppender) LifeSupport(org.neo4j.kernel.lifecycle.LifeSupport) DatabaseLayout(org.neo4j.io.layout.DatabaseLayout) LogRotation(org.neo4j.kernel.impl.transaction.log.rotation.LogRotation) RecoveryState(org.neo4j.storageengine.api.RecoveryState) Monitors(org.neo4j.monitoring.Monitors) LogVersionRepository(org.neo4j.storageengine.api.LogVersionRepository) CheckPointerImpl(org.neo4j.kernel.impl.transaction.log.checkpoint.CheckPointerImpl) DatabaseSchemaState(org.neo4j.kernel.impl.api.DatabaseSchemaState) JobSchedulerFactory(org.neo4j.kernel.impl.scheduler.JobSchedulerFactory) PageCache(org.neo4j.io.pagecache.PageCache) LegacyTransactionLogsLocator(org.neo4j.kernel.impl.storemigration.LegacyTransactionLogsLocator) StorageEngine(org.neo4j.storageengine.api.StorageEngine) DatabaseReadOnlyChecker.writable(org.neo4j.configuration.helpers.DatabaseReadOnlyChecker.writable) LogProgressReporter(org.neo4j.kernel.impl.util.monitoring.LogProgressReporter) String.format(java.lang.String.format) List(java.util.List) NO_LOCK_SERVICE(org.neo4j.lock.LockService.NO_LOCK_SERVICE) SimpleLogService(org.neo4j.logging.internal.SimpleLogService) Optional(java.util.Optional) DatabaseReadOnlyChecker(org.neo4j.configuration.helpers.DatabaseReadOnlyChecker) TYPE_RELATIONSHIP_TYPE(org.neo4j.token.api.TokenHolder.TYPE_RELATIONSHIP_TYPE) PhysicalLogicalTransactionStore(org.neo4j.kernel.impl.transaction.log.PhysicalLogicalTransactionStore) LogFiles(org.neo4j.kernel.impl.transaction.log.files.LogFiles) LogicalTransactionStore(org.neo4j.kernel.impl.transaction.log.LogicalTransactionStore) Config.defaults(org.neo4j.configuration.Config.defaults) ProgressReporter(org.neo4j.common.ProgressReporter) GraphDatabaseSettings(org.neo4j.configuration.GraphDatabaseSettings) LogProvider(org.neo4j.logging.LogProvider) ConfiguringPageCacheFactory(org.neo4j.kernel.impl.pagecache.ConfiguringPageCacheFactory) GroupingRecoveryCleanupWorkCollector(org.neo4j.index.internal.gbptree.GroupingRecoveryCleanupWorkCollector) Clocks.systemClock(org.neo4j.time.Clocks.systemClock) Iterables(org.neo4j.internal.helpers.collection.Iterables) Objects.requireNonNull(java.util.Objects.requireNonNull) StoreId(org.neo4j.storageengine.api.StoreId) GraphDatabaseInternalSettings(org.neo4j.configuration.GraphDatabaseInternalSettings) DbmsInfo(org.neo4j.kernel.impl.factory.DbmsInfo) LogPruning(org.neo4j.kernel.impl.transaction.log.pruning.LogPruning) MemoryPools(org.neo4j.memory.MemoryPools) IndexStoreViewFactory(org.neo4j.kernel.impl.transaction.state.storeview.IndexStoreViewFactory) JobScheduler(org.neo4j.scheduler.JobScheduler) Iterables.stream(org.neo4j.internal.helpers.collection.Iterables.stream) DatabaseHealth(org.neo4j.monitoring.DatabaseHealth) NO_LOCKS(org.neo4j.kernel.impl.locking.Locks.NO_LOCKS) ConstraintSemantics.getConstraintSemantics(org.neo4j.kernel.impl.constraints.ConstraintSemantics.getConstraintSemantics) LogService(org.neo4j.logging.internal.LogService) StorageEngineFactory(org.neo4j.storageengine.api.StorageEngineFactory) INDEX_CLEANUP(org.neo4j.scheduler.Group.INDEX_CLEANUP) MetadataProvider(org.neo4j.storageengine.api.MetadataProvider) DefaultFileSystemAbstraction(org.neo4j.io.fs.DefaultFileSystemAbstraction) Collectors.toList(java.util.stream.Collectors.toList) StorageEngineFactory.selectStorageEngine(org.neo4j.storageengine.api.StorageEngineFactory.selectStorageEngine) Clock(java.time.Clock) ExtensionFailureStrategies(org.neo4j.kernel.extension.ExtensionFailureStrategies) TransactionIdStore(org.neo4j.storageengine.api.TransactionIdStore) Clocks(org.neo4j.time.Clocks) FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) EmptyVersionContextSupplier(org.neo4j.io.pagecache.context.EmptyVersionContextSupplier) ExtensionFactory(org.neo4j.kernel.extension.ExtensionFactory) DatabaseExtensionContext(org.neo4j.kernel.extension.context.DatabaseExtensionContext) DatabaseExtensions(org.neo4j.kernel.extension.DatabaseExtensions) Dependencies(org.neo4j.collection.Dependencies)

Aggregations

Monitors (org.neo4j.monitoring.Monitors)45 Test (org.junit.jupiter.api.Test)13 Path (java.nio.file.Path)7 Config (org.neo4j.configuration.Config)7 RecoveryCleanupWorkCollector (org.neo4j.index.internal.gbptree.RecoveryCleanupWorkCollector)7 Dependencies (org.neo4j.collection.Dependencies)6 IndexingService (org.neo4j.kernel.impl.api.index.IndexingService)6 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)5 DatabaseManagementService (org.neo4j.dbms.api.DatabaseManagementService)5 DatabaseLayout (org.neo4j.io.layout.DatabaseLayout)5 LifeSupport (org.neo4j.kernel.lifecycle.LifeSupport)5 TestDatabaseManagementServiceBuilder (org.neo4j.test.TestDatabaseManagementServiceBuilder)5 BoltKernelDatabaseManagementServiceProvider (org.neo4j.bolt.dbapi.impl.BoltKernelDatabaseManagementServiceProvider)4 DatabaseReadOnlyChecker (org.neo4j.configuration.helpers.DatabaseReadOnlyChecker)4 DefaultIdGeneratorFactory (org.neo4j.internal.id.DefaultIdGeneratorFactory)4 Log (org.neo4j.logging.Log)4 MemoryTracker (org.neo4j.memory.MemoryTracker)4 IOException (java.io.IOException)3 BeforeEach (org.junit.jupiter.api.BeforeEach)3 GraphDatabaseService (org.neo4j.graphdb.GraphDatabaseService)3