Search in sources :

Example 21 with Dependencies

use of org.neo4j.collection.Dependencies in project neo4j by neo4j.

the class TestDatabaseManagementServiceBuilder method build.

@Override
public DatabaseManagementService build() {
    Config cfg = config.set(GraphDatabaseSettings.neo4j_home, homeDirectory.toAbsolutePath()).fromConfig(fromConfig).build();
    var originalDependencies = dependencies;
    if (noOpSystemGraphInitializer) {
        dependencies = TestDatabaseIdRepository.noOpSystemGraphInitializer(dependencies, cfg);
    }
    if (lazyProcedures) {
        var dependencyWrapper = new Dependencies(dependencies);
        dependencyWrapper.satisfyDependency(new LazyProcedures());
        dependencies = dependencyWrapper;
    }
    var dbms = newDatabaseManagementService(cfg, databaseDependencies());
    dependencies = originalDependencies;
    return dbms;
}
Also used : Config(org.neo4j.configuration.Config) Dependencies(org.neo4j.collection.Dependencies) GraphDatabaseDependencies(org.neo4j.graphdb.facade.GraphDatabaseDependencies) ExternalDependencies(org.neo4j.graphdb.facade.ExternalDependencies) LazyProcedures(org.neo4j.procedure.LazyProcedures)

Example 22 with Dependencies

use of org.neo4j.collection.Dependencies in project neo4j by neo4j.

the class DatabaseRecoveryIT method shouldSeeTheSameRecordsAtCheckpointAsAfterReverseRecovery.

@Test
void shouldSeeTheSameRecordsAtCheckpointAsAfterReverseRecovery() throws Exception {
    // given
    EphemeralFileSystemAbstraction fs = new EphemeralFileSystemAbstraction();
    managementService = new TestDatabaseManagementServiceBuilder(directory.homePath()).setFileSystem(fs).impermanent().build();
    GraphDatabaseService db = managementService.database(DEFAULT_DATABASE_NAME);
    produceRandomGraphUpdates(db, 100);
    checkPoint(db);
    EphemeralFileSystemAbstraction checkPointFs = fs.snapshot();
    // when
    produceRandomGraphUpdates(db, 100);
    flush(db);
    EphemeralFileSystemAbstraction crashedFs = fs.snapshot();
    managementService.shutdown();
    fs.close();
    Dependencies dependencies = new Dependencies();
    Monitors monitors;
    AtomicReference<EphemeralFileSystemAbstraction> reversedFs;
    try (PageCache pageCache = pageCacheExtension.getPageCache(crashedFs)) {
        dependencies.satisfyDependencies(pageCache);
        monitors = new Monitors();
        reversedFs = new AtomicReference<>();
        monitors.addMonitorListener(new RecoveryMonitor() {

            @Override
            public void reverseStoreRecoveryCompleted(long checkpointTxId) {
                try {
                    // Flush the page cache which will fished out of the GlobalModule at the point of constructing the database
                    pageCache.flushAndForce();
                } catch (IOException e) {
                    throw new UncheckedIOException(e);
                }
                // The stores should now be equal in content to the db as it was right after the checkpoint.
                // Grab a snapshot so that we can compare later.
                reversedFs.set(crashedFs.snapshot());
            }
        });
        DatabaseManagementService managementService = new TestDatabaseManagementServiceBuilder(directory.homePath()).setFileSystem(crashedFs).setExternalDependencies(dependencies).setMonitors(monitors).impermanent().build();
        managementService.shutdown();
    }
    // then
    fs.close();
    try {
        // Here we verify that the neostore contents, record by record are exactly the same when comparing
        // the store as it was right after the checkpoint with the store as it was right after reverse recovery completed.
        assertSameStoreContents(checkPointFs, reversedFs.get(), databaseLayout);
    } finally {
        IOUtils.closeAll(checkPointFs, reversedFs.get());
    }
}
Also used : GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) EphemeralFileSystemAbstraction(org.neo4j.io.fs.EphemeralFileSystemAbstraction) UncheckedIOException(java.io.UncheckedIOException) UncheckedIOException(java.io.UncheckedIOException) IOException(java.io.IOException) TestDatabaseManagementServiceBuilder(org.neo4j.test.TestDatabaseManagementServiceBuilder) Monitors(org.neo4j.monitoring.Monitors) Dependencies(org.neo4j.collection.Dependencies) DatabaseManagementService(org.neo4j.dbms.api.DatabaseManagementService) PageCache(org.neo4j.io.pagecache.PageCache) Test(org.junit.jupiter.api.Test)

Example 23 with Dependencies

use of org.neo4j.collection.Dependencies in project neo4j by neo4j.

the class DbmsDiagnosticsManager method dumpDatabaseDiagnostics.

private static void dumpDatabaseDiagnostics(Database database, Log log, boolean checkStatus) {
    dumpAsSingleMessageWithDbPrefix(log, stringJoiner -> {
        dumpDatabaseSectionName(database, stringJoiner::add);
        if (checkStatus) {
            logDatabaseStatus(database, stringJoiner::add);
            if (!database.isStarted()) {
                return;
            }
        }
        Dependencies databaseResolver = database.getDependencyResolver();
        DbmsInfo dbmsInfo = databaseResolver.resolveDependency(DbmsInfo.class);
        FileSystemAbstraction fs = databaseResolver.resolveDependency(FileSystemAbstraction.class);
        StorageEngineFactory storageEngineFactory = databaseResolver.resolveDependency(StorageEngineFactory.class);
        StorageEngine storageEngine = databaseResolver.resolveDependency(StorageEngine.class);
        DiagnosticsManager.dump(new VersionDiagnostics(dbmsInfo, database.getStoreId()), log, stringJoiner::add);
        DiagnosticsManager.dump(new StoreFilesDiagnostics(storageEngineFactory, fs, database.getDatabaseLayout()), log, stringJoiner::add);
        DiagnosticsManager.dump(new TransactionRangeDiagnostics(database), log, stringJoiner::add);
        storageEngine.dumpDiagnostics(log, stringJoiner::add);
    }, database.getNamedDatabaseId());
}
Also used : FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) StorageEngineFactory(org.neo4j.storageengine.api.StorageEngineFactory) DbmsInfo(org.neo4j.kernel.impl.factory.DbmsInfo) Dependencies(org.neo4j.collection.Dependencies) StorageEngine(org.neo4j.storageengine.api.StorageEngine)

Example 24 with Dependencies

use of org.neo4j.collection.Dependencies in project neo4j by neo4j.

the class IndexingServiceTest method buildIndexDependencies.

private static DependencyResolver buildIndexDependencies(IndexProvider... providers) {
    Dependencies dependencies = new Dependencies();
    dependencies.satisfyDependencies((Object[]) providers);
    dependencies.satisfyDependency(tokenProvider());
    return dependencies;
}
Also used : Dependencies(org.neo4j.collection.Dependencies)

Example 25 with Dependencies

use of org.neo4j.collection.Dependencies in project neo4j by neo4j.

the class KernelTransactionsTest method createDependencies.

private static Dependencies createDependencies() {
    Dependencies dependencies = new Dependencies();
    dependencies.satisfyDependency(mock(GraphDatabaseFacade.class));
    dependencies.satisfyDependency(CommunitySecurityLog.NULL_LOG);
    return dependencies;
}
Also used : Dependencies(org.neo4j.collection.Dependencies) GraphDatabaseFacade(org.neo4j.kernel.impl.factory.GraphDatabaseFacade)

Aggregations

Dependencies (org.neo4j.collection.Dependencies)40 Test (org.junit.jupiter.api.Test)13 TestDatabaseManagementServiceBuilder (org.neo4j.test.TestDatabaseManagementServiceBuilder)7 Config (org.neo4j.configuration.Config)6 Monitors (org.neo4j.monitoring.Monitors)6 PageCache (org.neo4j.io.pagecache.PageCache)5 LifeSupport (org.neo4j.kernel.lifecycle.LifeSupport)5 DatabaseHealth (org.neo4j.monitoring.DatabaseHealth)5 StorageEngine (org.neo4j.storageengine.api.StorageEngine)5 BeforeEach (org.junit.jupiter.api.BeforeEach)4 DatabaseReadOnlyChecker (org.neo4j.configuration.helpers.DatabaseReadOnlyChecker)4 DatabaseManagementService (org.neo4j.dbms.api.DatabaseManagementService)4 FileSystemAbstraction (org.neo4j.io.fs.FileSystemAbstraction)4 Database (org.neo4j.kernel.database.Database)4 IndexingService (org.neo4j.kernel.impl.api.index.IndexingService)4 StorageEngineFactory (org.neo4j.storageengine.api.StorageEngineFactory)4 IOException (java.io.IOException)3 RecoveryCleanupWorkCollector (org.neo4j.index.internal.gbptree.RecoveryCleanupWorkCollector)3 GlobalExtensionContext (org.neo4j.kernel.extension.context.GlobalExtensionContext)3 IndexStatisticsStore (org.neo4j.kernel.impl.api.index.stats.IndexStatisticsStore)3