use of org.neo4j.monitoring.Health in project neo4j by neo4j.
the class BatchingTransactionAppenderRotationIT method correctLastAppliedToPreviousLogTransactionInHeaderOnLogFileRotation.
@Test
void correctLastAppliedToPreviousLogTransactionInHeaderOnLogFileRotation() throws IOException {
LogFiles logFiles = getLogFiles(logVersionRepository, transactionIdStore);
life.add(logFiles);
Health databaseHealth = getDatabaseHealth();
LogRotation logRotation = FileLogRotation.transactionLogRotation(logFiles, Clock.systemUTC(), databaseHealth, monitors.newMonitor(LogRotationMonitor.class));
TransactionMetadataCache transactionMetadataCache = new TransactionMetadataCache();
BatchingTransactionAppender transactionAppender = new BatchingTransactionAppender(logFiles, logRotation, transactionMetadataCache, transactionIdStore, databaseHealth);
life.add(transactionAppender);
LogAppendEvent logAppendEvent = new RotationLogAppendEvent(logRotation);
TransactionToApply transactionToApply = prepareTransaction();
transactionAppender.append(transactionToApply, logAppendEvent);
LogFile logFile = logFiles.getLogFile();
assertEquals(1, logFile.getHighestLogVersion());
Path highestLogFile = logFile.getHighestLogFile();
LogHeader logHeader = LogHeaderReader.readLogHeader(fileSystem, highestLogFile, INSTANCE);
assertEquals(2, logHeader.getLastCommittedTxId());
}
use of org.neo4j.monitoring.Health in project neo4j by neo4j.
the class RecoveryCleanupIT method dirtyDatabase.
private void dirtyDatabase() throws IOException {
db = startDatabase();
Health databaseHealth = databaseHealth(db);
index(db);
someData(db);
checkpoint(db);
someData(db);
databaseHealth.panic(new Throwable("Trigger recovery on next startup"));
managementService.shutdown();
db = null;
}
use of org.neo4j.monitoring.Health in project neo4j by neo4j.
the class DatabaseHealthTest method shouldGenerateDatabasePanicEvents.
@Test
void shouldGenerateDatabasePanicEvents() {
// GIVEN
DatabasePanicEventGenerator generator = mock(DatabasePanicEventGenerator.class);
Health databaseHealth = new DatabaseHealth(generator, NullLogProvider.getInstance().getLog(DatabaseHealth.class));
databaseHealth.healed();
// WHEN
Exception cause = new Exception("My own fault");
databaseHealth.panic(cause);
databaseHealth.panic(cause);
// THEN
verify(generator).panic(cause);
}
use of org.neo4j.monitoring.Health in project neo4j by neo4j.
the class DatabaseHealthTest method databaseWithCriticalErrorsCanNotBeHealed.
@Test
void databaseWithCriticalErrorsCanNotBeHealed() {
AssertableLogProvider logProvider = new AssertableLogProvider();
Health databaseHealth = new DatabaseHealth(mock(DatabasePanicEventGenerator.class), logProvider.getLog(DatabaseHealth.class));
assertTrue(databaseHealth.isHealthy());
IOException criticalException = new IOException("Space exception.", new OutOfMemoryError("Out of memory."));
databaseHealth.panic(criticalException);
assertFalse(databaseHealth.isHealthy());
assertFalse(databaseHealth.healed());
assertThat(logProvider).doesNotContainMessage("Database health set to OK").containsMessages("Database encountered a critical error and can't be healed. Restart required.");
}
use of org.neo4j.monitoring.Health in project neo4j by neo4j.
the class DatabaseHealthTest method healDatabaseWithoutCriticalErrors.
@Test
void healDatabaseWithoutCriticalErrors() {
AssertableLogProvider logProvider = new AssertableLogProvider();
Health databaseHealth = new DatabaseHealth(mock(DatabasePanicEventGenerator.class), logProvider.getLog(DatabaseHealth.class));
assertTrue(databaseHealth.isHealthy());
databaseHealth.panic(new IOException("Space exception."));
assertFalse(databaseHealth.isHealthy());
assertTrue(databaseHealth.healed());
assertThat(logProvider).containsMessages("Database health set to OK").doesNotContainMessage("Database encountered a critical error and can't be healed. Restart required.");
}
Aggregations