Search in sources :

Example 16 with DatabaseLayout

use of org.neo4j.io.layout.DatabaseLayout in project neo4j by neo4j.

the class GlobalModule method checkLegacyDefaultDatabase.

private void checkLegacyDefaultDatabase() {
    if (!globalConfig.isExplicitlySet(default_database)) {
        StorageEngineFactory storageEngineFactory = StorageEngineFactory.defaultStorageEngine();
        DatabaseLayout defaultDatabaseLayout = neo4jLayout.databaseLayout(globalConfig.get(default_database));
        if (storageEngineFactory.storageExists(fileSystem, defaultDatabaseLayout, pageCache)) {
            return;
        }
        final String legacyDatabaseName = "graph.db";
        DatabaseLayout legacyDatabaseLayout = neo4jLayout.databaseLayout(legacyDatabaseName);
        if (storageEngineFactory.storageExists(fileSystem, legacyDatabaseLayout, pageCache)) {
            Log internalLog = logService.getInternalLog(getClass());
            globalConfig.set(default_database, legacyDatabaseName);
            internalLog.warn("Legacy `%s` database was found and default database was set to point to into it. Please consider setting default database explicitly.", legacyDatabaseName);
        }
    }
}
Also used : Log(org.neo4j.logging.Log) StorageEngineFactory(org.neo4j.storageengine.api.StorageEngineFactory) DatabaseLayout(org.neo4j.io.layout.DatabaseLayout)

Example 17 with DatabaseLayout

use of org.neo4j.io.layout.DatabaseLayout in project neo4j by neo4j.

the class FullCheckCountsStoreIT method shouldReportBadCountsStore.

private void shouldReportBadCountsStore(ThrowingFunction<Path, Boolean, IOException> fileAction, Function<DatabaseLayout, Path> store, String errorMessage) throws Exception {
    // given
    DatabaseLayout databaseLayout = db.databaseLayout();
    dbms.shutdown();
    boolean corrupted = fileAction.apply(store.apply(databaseLayout));
    assertTrue(corrupted);
    // when
    ConsistencyCheckService.Result result = new ConsistencyCheckService().runFullConsistencyCheck(databaseLayout, defaults(GraphDatabaseSettings.logs_directory, databaseLayout.databaseDirectory()), NONE, nullLogProvider(), false, DEFAULT);
    // then
    assertThat(result.summary().getGenericErrors()).contains(errorMessage);
}
Also used : DatabaseLayout(org.neo4j.io.layout.DatabaseLayout) ConsistencyCheckService(org.neo4j.consistency.ConsistencyCheckService)

Example 18 with DatabaseLayout

use of org.neo4j.io.layout.DatabaseLayout in project neo4j by neo4j.

the class StoreUpgraderInterruptionTestIT method shouldSucceedWithUpgradeAfterPreviousAttemptDiedDuringMigration.

@Test
public void shouldSucceedWithUpgradeAfterPreviousAttemptDiedDuringMigration() throws IOException, ConsistencyCheckIncompleteException {
    MigrationTestUtils.prepareSampleLegacyDatabase(version, fs, workingDatabaseLayout.databaseDirectory(), prepareDirectory);
    RecordStoreVersionCheck versionCheck = new RecordStoreVersionCheck(fs, pageCache, workingDatabaseLayout, NullLogProvider.getInstance(), Config.defaults(), NULL);
    MigrationProgressMonitor progressMonitor = MigrationProgressMonitor.SILENT;
    LogService logService = NullLogService.getInstance();
    RecordStorageMigrator failingStoreMigrator = new RecordStorageMigrator(fs, pageCache, CONFIG, logService, jobScheduler, NULL, batchImporterFactory, INSTANCE) {

        @Override
        public void migrate(DatabaseLayout directoryLayout, DatabaseLayout migrationLayout, ProgressReporter progressReporter, String versionToMigrateFrom, String versionToMigrateTo, IndexImporterFactory indexImporterFactory) throws IOException, KernelException {
            super.migrate(directoryLayout, migrationLayout, progressReporter, versionToMigrateFrom, versionToMigrateTo, indexImporterFactory);
            throw new RuntimeException("This upgrade is failing");
        }
    };
    try {
        newUpgrader(versionCheck, progressMonitor, createIndexMigrator(), failingStoreMigrator).migrateIfNeeded(workingDatabaseLayout, false);
        fail("Should throw exception");
    } catch (RuntimeException e) {
        assertEquals("This upgrade is failing", e.getMessage());
    }
    assertTrue(checkNeoStoreHasFormatVersion(versionCheck, baselineFormat));
    RecordStorageMigrator migrator = new RecordStorageMigrator(fs, pageCache, CONFIG, logService, jobScheduler, NULL, batchImporterFactory, INSTANCE);
    IdGeneratorMigrator idMigrator = new IdGeneratorMigrator(fs, pageCache, CONFIG, NULL);
    SchemaIndexMigrator indexMigrator = createIndexMigrator();
    newUpgrader(versionCheck, progressMonitor, indexMigrator, migrator, idMigrator).migrateIfNeeded(workingDatabaseLayout, false);
    assertTrue(checkNeoStoreHasFormatVersion(versionCheck, successorFormat));
    // Since consistency checker is in read only mode we need to start/stop db to generate label scan store.
    startStopDatabase(neo4jLayout.homeDirectory());
    assertConsistentStore(workingDatabaseLayout);
}
Also used : MigrationProgressMonitor(org.neo4j.storageengine.migration.MigrationProgressMonitor) RecordStoreVersionCheck(org.neo4j.kernel.impl.storemigration.RecordStoreVersionCheck) RecordStorageMigrator(org.neo4j.kernel.impl.storemigration.RecordStorageMigrator) DatabaseLayout(org.neo4j.io.layout.DatabaseLayout) IndexImporterFactory(org.neo4j.internal.batchimport.IndexImporterFactory) ProgressReporter(org.neo4j.common.ProgressReporter) IdGeneratorMigrator(org.neo4j.kernel.impl.storemigration.IdGeneratorMigrator) SchemaIndexMigrator(org.neo4j.storageengine.migration.SchemaIndexMigrator) NullLogService(org.neo4j.logging.internal.NullLogService) LogService(org.neo4j.logging.internal.LogService) Test(org.junit.Test)

Example 19 with DatabaseLayout

use of org.neo4j.io.layout.DatabaseLayout in project neo4j by neo4j.

the class LoadCommandTest method shouldCalculateTheTxLogDirectoryFromConfig.

@Test
void shouldCalculateTheTxLogDirectoryFromConfig() throws Exception {
    Path dataDir = testDirectory.directory("some-other-path");
    Path txLogsDir = testDirectory.directory("txLogsPath");
    Path databaseDir = dataDir.resolve("databases/foo");
    Files.write(configDir.resolve(Config.DEFAULT_CONFIG_FILE_NAME), asList(formatProperty(data_directory, dataDir), formatProperty(transaction_logs_root_path, txLogsDir)));
    execute("foo", archive);
    DatabaseLayout databaseLayout = createDatabaseLayout(dataDir, databaseDir.getParent(), "foo", txLogsDir);
    verify(loader).load(any(), eq(databaseLayout));
}
Also used : Path(java.nio.file.Path) DatabaseLayout(org.neo4j.io.layout.DatabaseLayout) Test(org.junit.jupiter.api.Test)

Example 20 with DatabaseLayout

use of org.neo4j.io.layout.DatabaseLayout in project neo4j by neo4j.

the class LoadCommandTest method shouldLoadTheDatabaseFromTheArchive.

@Test
void shouldLoadTheDatabaseFromTheArchive() throws CommandFailedException, IOException, IncorrectFormat {
    execute("foo", archive);
    DatabaseLayout databaseLayout = createDatabaseLayout(homeDir.resolve("data"), homeDir.resolve("data/databases"), "foo", homeDir.resolve("data/" + DEFAULT_TX_LOGS_ROOT_DIR_NAME));
    verify(loader).load(archive, databaseLayout);
}
Also used : DatabaseLayout(org.neo4j.io.layout.DatabaseLayout) Test(org.junit.jupiter.api.Test)

Aggregations

DatabaseLayout (org.neo4j.io.layout.DatabaseLayout)108 Test (org.junit.jupiter.api.Test)66 Path (java.nio.file.Path)51 Config (org.neo4j.configuration.Config)35 FileSystemAbstraction (org.neo4j.io.fs.FileSystemAbstraction)24 GraphDatabaseAPI (org.neo4j.kernel.internal.GraphDatabaseAPI)19 DefaultFileSystemAbstraction (org.neo4j.io.fs.DefaultFileSystemAbstraction)17 PageCache (org.neo4j.io.pagecache.PageCache)17 IOException (java.io.IOException)16 ConsistencyCheckService (org.neo4j.consistency.ConsistencyCheckService)16 Transaction (org.neo4j.graphdb.Transaction)13 DefaultIdGeneratorFactory (org.neo4j.internal.id.DefaultIdGeneratorFactory)10 DatabaseManagementService (org.neo4j.dbms.api.DatabaseManagementService)9 TestDatabaseManagementServiceBuilder (org.neo4j.test.TestDatabaseManagementServiceBuilder)9 CommandFailedException (org.neo4j.cli.CommandFailedException)8 ExecutionContext (org.neo4j.cli.ExecutionContext)8 PageCacheTracer (org.neo4j.io.pagecache.tracing.PageCacheTracer)8 StorageEngineFactory (org.neo4j.storageengine.api.StorageEngineFactory)8 Closeable (java.io.Closeable)7 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)7