use of org.neo4j.io.layout.DatabaseLayout in project neo4j by neo4j.
the class LegacyTransactionLogsLocatorTest method transactionLogsDirectoryEqualsToDatabaseDirectoryForSystemDatabase.
@Test
void transactionLogsDirectoryEqualsToDatabaseDirectoryForSystemDatabase() {
Path customDirectory = testDirectory.directory("customDirectory");
Config config = Config.defaults(GraphDatabaseInternalSettings.logical_logs_location, customDirectory.toAbsolutePath());
DatabaseLayout systemDbLayout = neo4jLayout.databaseLayout(GraphDatabaseSettings.SYSTEM_DATABASE_NAME);
LegacyTransactionLogsLocator logsLocator = new LegacyTransactionLogsLocator(config, systemDbLayout);
assertEquals(systemDbLayout.databaseDirectory(), logsLocator.getTransactionLogsDirectory());
}
use of org.neo4j.io.layout.DatabaseLayout in project neo4j by neo4j.
the class Neo4jLayoutSupportExtensionTest method shouldUseDefaultConfig.
@Test
void shouldUseDefaultConfig() {
Config defaultConfig = Config.defaults(neo4j_home, testDirectory.homePath());
Neo4jLayout defaultNeo4jLayout = Neo4jLayout.of(defaultConfig);
DatabaseLayout defaultDatabaseLayout = defaultNeo4jLayout.databaseLayout(defaultConfig.get(default_database));
assertEquals(defaultNeo4jLayout.homeDirectory(), neo4jLayout.homeDirectory());
assertEquals(defaultNeo4jLayout.databasesDirectory(), neo4jLayout.databasesDirectory());
assertEquals(defaultNeo4jLayout.transactionLogsRootDirectory(), neo4jLayout.transactionLogsRootDirectory());
assertEquals(defaultDatabaseLayout.databaseDirectory(), databaseLayout.databaseDirectory());
assertEquals(defaultDatabaseLayout.getTransactionLogsDirectory(), databaseLayout.getTransactionLogsDirectory());
}
use of org.neo4j.io.layout.DatabaseLayout in project neo4j by neo4j.
the class FulltextProceduresTest method checkDatabaseConsistency.
private void checkDatabaseConsistency() {
DatabaseLayout layout = db.databaseLayout();
controller.restartDbms(b -> {
try {
ConsistencyCheckService cc = new ConsistencyCheckService();
ConsistencyCheckService.Result result = cc.runFullConsistencyCheck(layout, Config.defaults(), ProgressMonitorFactory.NONE, NullLogProvider.nullLogProvider(), false, ConsistencyFlags.DEFAULT);
if (!result.isSuccessful()) {
Files.lines(result.reportFile()).forEach(System.out::println);
}
assertTrue(result.isSuccessful());
} catch (Exception e) {
throw new RuntimeException(e);
}
return b;
});
}
use of org.neo4j.io.layout.DatabaseLayout in project neo4j by neo4j.
the class DatabaseStartupTest method startDatabaseWithoutStoreFilesAndWithTransactionLogFilesFailure.
@Test
void startDatabaseWithoutStoreFilesAndWithTransactionLogFilesFailure() throws IOException {
// Create a store
DatabaseManagementService managementService = new TestDatabaseManagementServiceBuilder(databaseLayout).build();
GraphDatabaseAPI db = (GraphDatabaseAPI) managementService.database(DEFAULT_DATABASE_NAME);
DatabaseLayout databaseLayout = db.databaseLayout();
try (Transaction tx = db.beginTx()) {
tx.createNode();
tx.commit();
}
managementService.shutdown();
fs.deleteRecursively(databaseLayout.databaseDirectory());
// Try to start
managementService = new TestDatabaseManagementServiceBuilder(databaseLayout).build();
try {
db = (GraphDatabaseAPI) managementService.database(DEFAULT_DATABASE_NAME);
assertFalse(db.isAvailable(10));
DatabaseStateService dbStateService = db.getDependencyResolver().resolveDependency(DatabaseStateService.class);
Optional<Throwable> cause = dbStateService.causeOfFailure(db.databaseId());
assertTrue(cause.isPresent());
assertThat(cause.get()).hasStackTraceContaining("Fail to start '" + db.databaseId() + "' since transaction logs were found, while database ");
} finally {
managementService.shutdown();
}
}
use of org.neo4j.io.layout.DatabaseLayout in project neo4j by neo4j.
the class CommunitySystemDatabaseIT method systemAndDefaultDatabasesAreConsistentAfterShutdown.
@Test
void systemAndDefaultDatabasesAreConsistentAfterShutdown() throws ConsistencyCheckIncompleteException {
int systemDatabaseTransactions = 100;
int defaultDatabaseTransactions = 15;
DatabaseLayout systemDatabaseLayout = systemDb.databaseLayout();
DatabaseLayout defaultDbLayout = defaultDb.databaseLayout();
for (int i = 0; i < systemDatabaseTransactions; i++) {
try (Transaction transaction = systemDb.beginTx()) {
Node nodeA = transaction.createNode();
Node nodeB = transaction.createNode();
nodeA.createRelationshipTo(nodeB, RelationshipType.withName(valueOf(i)));
transaction.commit();
}
}
for (int i = 0; i < defaultDatabaseTransactions; i++) {
try (Transaction transaction = defaultDb.beginTx()) {
transaction.createNode(label(valueOf(i)));
transaction.commit();
}
}
managementService.shutdown();
ConsistencyCheckService consistencyCheckService = new ConsistencyCheckService();
assertTrue(runConsistencyCheck(systemDatabaseLayout, consistencyCheckService).isSuccessful());
assertTrue(runConsistencyCheck(defaultDbLayout, consistencyCheckService).isSuccessful());
}
Aggregations