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);
}
}
}
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);
}
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);
}
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));
}
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);
}
Aggregations