use of org.neo4j.kernel.database.Database in project neo4j by neo4j.
the class DatabaseAvailabilityIT method restartedDatabaseIsAvailable.
@Test
void restartedDatabaseIsAvailable() {
DependencyResolver dependencyResolver = database.getDependencyResolver();
DatabaseManager<?> databaseManager = getDatabaseManager(dependencyResolver);
DatabaseContext databaseContext = databaseManager.getDatabaseContext(defaultNamedDatabaseId).get();
Database database = databaseContext.database();
executeTransactionOnDefaultDatabase();
database.stop();
assertThrows(DatabaseShutdownException.class, () -> this.database.beginTx());
database.start();
executeTransactionOnDefaultDatabase();
}
use of org.neo4j.kernel.database.Database in project neo4j by neo4j.
the class AbstractDatabaseManager method startDatabase.
protected void startDatabase(NamedDatabaseId namedDatabaseId, DB context) {
try {
log.info("Starting '%s'.", namedDatabaseId);
Database database = context.database();
database.start();
} catch (Throwable t) {
throw new DatabaseManagementException(format("An error occurred! Unable to start `%s`.", namedDatabaseId), t);
}
}
use of org.neo4j.kernel.database.Database in project neo4j by neo4j.
the class AbstractDatabaseManager method stopDatabase.
protected void stopDatabase(NamedDatabaseId namedDatabaseId, DB context) {
try {
log.info("Stopping '%s'.", namedDatabaseId);
Database database = context.database();
database.stop();
log.info("Stopped '%s' successfully.", namedDatabaseId);
} catch (Throwable t) {
log.error("Error stopping '%s'.", namedDatabaseId);
throw new DatabaseManagementException(format("An error occurred! Unable to stop `%s`.", namedDatabaseId), t);
}
}
use of org.neo4j.kernel.database.Database in project neo4j by neo4j.
the class TransactionRangeDiagnosticsTest method shouldLogCorrectTransactionLogDiagnosticsForNoTransactionLogs.
@Test
void shouldLogCorrectTransactionLogDiagnosticsForNoTransactionLogs() throws IOException {
// GIVEN
Database database = databaseWithLogFilesContainingLowestTxId(noLogs());
AssertableLogProvider logProvider = new AssertableLogProvider();
Log logger = logProvider.getLog(getClass());
// WHEN
new TransactionRangeDiagnostics(database).dump(logger::info);
// THEN
assertThat(logProvider).containsMessages("Transaction log files stored on file store:").containsMessages(" - no transactions found").containsMessages(" - no checkpoints found");
}
use of org.neo4j.kernel.database.Database in project neo4j by neo4j.
the class TransactionRangeDiagnosticsTest method shouldLogCorrectTransactionLogDiagnosticsForTransactionsAndCheckpointLogs.
@Test
void shouldLogCorrectTransactionLogDiagnosticsForTransactionsAndCheckpointLogs() throws Exception {
// GIVEN
long txLogLowVersion = 2;
long txLogHighVersion = 10;
long checkpointLogLowVersion = 0;
long checkpointLogHighVersion = 3;
StoreId storeId = new StoreId(12345);
LogPosition checkpointLogPosition = new LogPosition(checkpointLogHighVersion, 34);
Database database = databaseWithLogFilesContainingLowestTxId(logs(transactionLogsWithTransaction(txLogLowVersion, txLogHighVersion, 42), checkpointLogsWithLastCheckpoint(checkpointLogLowVersion, checkpointLogHighVersion, new CheckpointInfo(new LogEntryDetachedCheckpoint(KernelVersion.LATEST, checkpointLogPosition, 1234, storeId, "testing"), checkpointLogPosition))));
AssertableLogProvider logProvider = new AssertableLogProvider();
Log logger = logProvider.getLog(getClass());
// WHEN
new TransactionRangeDiagnostics(database).dump(logger::info);
// THEN
assertThat(logProvider).containsMessages("existing transaction log versions " + txLogLowVersion + "-" + txLogHighVersion).containsMessages("existing checkpoint log versions " + checkpointLogLowVersion + "-" + checkpointLogHighVersion);
}
Aggregations