Search in sources :

Example 21 with Monitors

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

the class BuiltInProceduresIT method replanMonitor.

private ReplanMonitor replanMonitor() {
    Monitors monitors = dependencyResolver.resolveDependency(Monitors.class);
    ReplanMonitor monitorListener = new ReplanMonitor();
    monitors.addMonitorListener(monitorListener);
    return monitorListener;
}
Also used : Monitors(org.neo4j.monitoring.Monitors)

Example 22 with Monitors

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

the class AbstractIndexProviderFactory method newInstance.

@Override
public IndexProvider newInstance(ExtensionContext context, Dependencies dependencies) {
    PageCache pageCache = dependencies.pageCache();
    Path databaseDir = context.directory();
    FileSystemAbstraction fs = dependencies.fileSystem();
    Log log = dependencies.getLogService().getInternalLogProvider().getLog(loggingClass());
    Monitors monitors = dependencies.monitors();
    String monitorTag = descriptor().toString();
    monitors.addMonitorListener(new LoggingMonitor(log), monitorTag);
    Config config = dependencies.getConfig();
    var readOnlyChecker = dependencies.readOnlyChecker();
    if (OperationalMode.SINGLE != context.dbmsInfo().operationalMode) {
        // if running as part of cluster indexes should be writable to allow catchup process to accept transactions
        readOnlyChecker = DatabaseReadOnlyChecker.writable();
    }
    RecoveryCleanupWorkCollector recoveryCleanupWorkCollector = dependencies.recoveryCleanupWorkCollector();
    PageCacheTracer pageCacheTracer = dependencies.pageCacheTracer();
    DatabaseLayout databaseLayout = dependencies.databaseLayout();
    return internalCreate(pageCache, databaseDir, fs, monitors, monitorTag, config, readOnlyChecker, recoveryCleanupWorkCollector, databaseLayout, pageCacheTracer);
}
Also used : Path(java.nio.file.Path) FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) Log(org.neo4j.logging.Log) LoggingMonitor(org.neo4j.kernel.api.index.LoggingMonitor) Config(org.neo4j.configuration.Config) Monitors(org.neo4j.monitoring.Monitors) PageCacheTracer(org.neo4j.io.pagecache.tracing.PageCacheTracer) DatabaseLayout(org.neo4j.io.layout.DatabaseLayout) RecoveryCleanupWorkCollector(org.neo4j.index.internal.gbptree.RecoveryCleanupWorkCollector) PageCache(org.neo4j.io.pagecache.PageCache)

Example 23 with Monitors

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

the class StartOldDbOnCurrentVersionAndCreateFusionIndexIT method setupDb.

private DatabaseManagementService setupDb(Path storeDir, IndexRecoveryTracker indexRecoveryTracker) {
    Monitors monitors = new Monitors();
    monitors.addMonitorListener(indexRecoveryTracker);
    return new TestDatabaseManagementServiceBuilder(storeDir).setMonitors(monitors).setConfig(GraphDatabaseSettings.allow_upgrade, true).build();
}
Also used : TestDatabaseManagementServiceBuilder(org.neo4j.test.TestDatabaseManagementServiceBuilder) Monitors(org.neo4j.monitoring.Monitors)

Example 24 with Monitors

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

the class RecoverIndexDropIT method shouldDropIndexOnRecovery.

@Test
void shouldDropIndexOnRecovery() throws IOException {
    // given a transaction stream ending in an INDEX DROP command.
    CommittedTransactionRepresentation dropTransaction = prepareDropTransaction();
    DatabaseManagementService managementService = configure(new TestDatabaseManagementServiceBuilder(databaseLayout)).build();
    GraphDatabaseService db = managementService.database(DEFAULT_DATABASE_NAME);
    long initialIndexCount = currentIndexCount(db);
    createIndex(db);
    StorageEngineFactory storageEngineFactory = ((GraphDatabaseAPI) db).getDependencyResolver().resolveDependency(StorageEngineFactory.class);
    managementService.shutdown();
    appendDropTransactionToTransactionLog(databaseLayout.getTransactionLogsDirectory(), dropTransaction, storageEngineFactory);
    // when recovering this (the drop transaction with the index file intact)
    Monitors monitors = new Monitors();
    AssertRecoveryIsPerformed recoveryMonitor = new AssertRecoveryIsPerformed();
    monitors.addMonitorListener(recoveryMonitor);
    managementService = configure(new TestDatabaseManagementServiceBuilder(databaseLayout).setMonitors(monitors)).build();
    db = managementService.database(DEFAULT_DATABASE_NAME);
    try {
        assertTrue(recoveryMonitor.recoveryWasRequired);
        // then
        assertEquals(initialIndexCount, currentIndexCount(db));
    } finally {
        // and the ability to shut down w/o failing on still open files
        managementService.shutdown();
    }
}
Also used : GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) CommittedTransactionRepresentation(org.neo4j.kernel.impl.transaction.CommittedTransactionRepresentation) TestDatabaseManagementServiceBuilder(org.neo4j.test.TestDatabaseManagementServiceBuilder) StorageEngineFactory(org.neo4j.storageengine.api.StorageEngineFactory) Monitors(org.neo4j.monitoring.Monitors) DatabaseManagementService(org.neo4j.dbms.api.DatabaseManagementService) Test(org.junit.jupiter.api.Test)

Example 25 with Monitors

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

the class SessionExtension method beforeEach.

@Override
public void beforeEach(ExtensionContext extensionContext) {
    managementService = builderFactory.get().impermanent().setConfig(GraphDatabaseSettings.auth_enabled, authEnabled).build();
    gdb = (GraphDatabaseAPI) managementService.database(GraphDatabaseSettings.DEFAULT_DATABASE_NAME);
    DependencyResolver resolver = gdb.getDependencyResolver();
    Authentication authentication = authentication(resolver.resolveDependency(AuthManager.class));
    Config config = resolver.resolveDependency(Config.class);
    SystemNanoClock clock = Clocks.nanoClock();
    DefaultDatabaseResolver defaultDatabaseResolver = new CommunityDefaultDatabaseResolver(config, () -> managementService.database(GraphDatabaseSettings.SYSTEM_DATABASE_NAME));
    BoltGraphDatabaseManagementServiceSPI databaseManagementService = new BoltKernelDatabaseManagementServiceProvider(managementService, new Monitors(), clock, ofSeconds(30));
    boltFactory = new BoltStateMachineFactoryImpl(databaseManagementService, authentication, clock, config, NullLogService.getInstance(), defaultDatabaseResolver);
}
Also used : BoltStateMachineFactoryImpl(org.neo4j.bolt.runtime.statemachine.impl.BoltStateMachineFactoryImpl) SystemNanoClock(org.neo4j.time.SystemNanoClock) AuthManager(org.neo4j.kernel.api.security.AuthManager) BoltKernelDatabaseManagementServiceProvider(org.neo4j.bolt.dbapi.impl.BoltKernelDatabaseManagementServiceProvider) Authentication(org.neo4j.bolt.security.auth.Authentication) BasicAuthentication(org.neo4j.bolt.security.auth.BasicAuthentication) Config(org.neo4j.configuration.Config) DefaultDatabaseResolver(org.neo4j.kernel.database.DefaultDatabaseResolver) CommunityDefaultDatabaseResolver(org.neo4j.server.security.systemgraph.CommunityDefaultDatabaseResolver) CommunityDefaultDatabaseResolver(org.neo4j.server.security.systemgraph.CommunityDefaultDatabaseResolver) Monitors(org.neo4j.monitoring.Monitors) DependencyResolver(org.neo4j.common.DependencyResolver) BoltGraphDatabaseManagementServiceSPI(org.neo4j.bolt.dbapi.BoltGraphDatabaseManagementServiceSPI)

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