use of org.neo4j.dbms.api.DatabaseManagementService in project neo4j by neo4j.
the class DatabaseStartupTest method dumpSystemDiagnosticLoggingOnStartup.
@Test
void dumpSystemDiagnosticLoggingOnStartup() {
AssertableLogProvider logProvider = new AssertableLogProvider();
DatabaseManagementService managementService = new TestDatabaseManagementServiceBuilder(databaseLayout).setInternalLogProvider(logProvider).setConfig(GraphDatabaseInternalSettings.dump_diagnostics, true).build();
managementService.database(DEFAULT_DATABASE_NAME);
try {
assertThat(logProvider).containsMessages("System diagnostics", "System memory information", "JVM memory information", "Operating system information", "JVM information", "Java classpath", "Library path", "System properties", "(IANA) TimeZone database version", "Network information", "DBMS config");
} finally {
managementService.shutdown();
}
}
use of org.neo4j.dbms.api.DatabaseManagementService 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.dbms.api.DatabaseManagementService in project neo4j by neo4j.
the class DatabaseShutdownTest method invokeDatabaseShutdownListenersOnShutdown.
@Test
void invokeDatabaseShutdownListenersOnShutdown() {
DatabaseManagementService managementService = new TestDatabaseManagementServiceBuilder(databaseLayout).setFileSystem(fs).build();
ShutdownListenerDatabaseEventListener shutdownHandler = new ShutdownListenerDatabaseEventListener();
managementService.registerDatabaseEventListener(shutdownHandler);
managementService.shutdown();
assertEquals(2, shutdownHandler.shutdownCounter());
}
use of org.neo4j.dbms.api.DatabaseManagementService in project neo4j by neo4j.
the class DatabaseShutdownTest method shouldShutdownCorrectlyWhenCheckPointingOnShutdownFails.
@Test
void shouldShutdownCorrectlyWhenCheckPointingOnShutdownFails() {
TestDatabaseManagementServiceBuilderWithFailingPageCacheFlush factory = new TestDatabaseManagementServiceBuilderWithFailingPageCacheFlush(databaseLayout.databaseDirectory(), fs);
DatabaseManagementService managementService = factory.build();
GraphDatabaseAPI databaseService = (GraphDatabaseAPI) managementService.database(DEFAULT_DATABASE_NAME);
DatabaseStateService dbStateService = databaseService.getDependencyResolver().resolveDependency(DatabaseStateService.class);
factory.setFailFlush(true);
managementService.shutdown();
assertTrue(dbStateService.causeOfFailure(databaseService.databaseId()).isPresent());
assertEquals(LifecycleStatus.SHUTDOWN, factory.getDatabaseStatus());
}
use of org.neo4j.dbms.api.DatabaseManagementService in project neo4j by neo4j.
the class RecoveryRequiredCheckerTest method startStopAndCreateDefaultData.
private void startStopAndCreateDefaultData() {
DatabaseManagementService managementService = startDatabase(fileSystem, storeDir);
try {
GraphDatabaseService database = managementService.database(DEFAULT_DATABASE_NAME);
try (Transaction transaction = database.beginTx()) {
transaction.createNode();
transaction.commit();
}
} finally {
managementService.shutdown();
}
}
Aggregations