use of org.neo4j.monitoring.Health in project neo4j by neo4j.
the class DatabaseHealthTest method shouldLogDatabasePanicEvent.
@Test
void shouldLogDatabasePanicEvent() {
// GIVEN
AssertableLogProvider logProvider = new AssertableLogProvider();
Health databaseHealth = new DatabaseHealth(mock(DatabasePanicEventGenerator.class), logProvider.getLog(DatabaseHealth.class));
databaseHealth.healed();
// WHEN
String message = "Listen everybody... panic!";
Exception exception = new Exception(message);
databaseHealth.panic(exception);
// THEN
assertThat(logProvider).forClass(DatabaseHealth.class).forLevel(ERROR).containsMessageWithException("Database panic: The database has encountered a critical error, " + "and needs to be restarted. Please see database logs for more details.", exception);
}
use of org.neo4j.monitoring.Health in project neo4j by neo4j.
the class Runner method createBatchingTransactionAppender.
private static BatchingTransactionAppender createBatchingTransactionAppender(TransactionIdStore transactionIdStore, TransactionMetadataCache transactionMetadataCache, LogFiles logFiles) {
Log log = NullLog.getInstance();
Health databaseHealth = new DatabaseHealth(PanicEventGenerator.NO_OP, log);
LogRotation logRotation = transactionLogRotation(logFiles, Clock.systemUTC(), databaseHealth, EMPTY);
return new BatchingTransactionAppender(logFiles, logRotation, transactionMetadataCache, transactionIdStore, databaseHealth);
}
use of org.neo4j.monitoring.Health in project neo4j by neo4j.
the class TransactionLogAppendAndRotateIT method shouldKeepTransactionsIntactWhenConcurrentlyRotationAndAppending.
@Test
void shouldKeepTransactionsIntactWhenConcurrentlyRotationAndAppending() throws Throwable {
// GIVEN
LogVersionRepository logVersionRepository = new SimpleLogVersionRepository();
LogFiles logFiles = LogFilesBuilder.builder(databaseLayout, fileSystem).withLogVersionRepository(logVersionRepository).withRotationThreshold(ByteUnit.mebiBytes(1)).withTransactionIdStore(new SimpleTransactionIdStore()).withLogEntryReader(logEntryReader()).withStoreId(StoreId.UNKNOWN).build();
life.add(logFiles);
final AtomicBoolean end = new AtomicBoolean();
AllTheMonitoring monitoring = new AllTheMonitoring(end, 100);
TransactionIdStore txIdStore = new SimpleTransactionIdStore();
TransactionMetadataCache metadataCache = new TransactionMetadataCache();
monitoring.setLogFile(logFiles.getLogFile());
Health health = new DatabaseHealth(mock(DatabasePanicEventGenerator.class), NullLog.getInstance());
LogRotation rotation = transactionLogRotation(logFiles, Clock.systemUTC(), health, monitoring);
final TransactionAppender appender = life.add(new BatchingTransactionAppender(logFiles, rotation, metadataCache, txIdStore, health));
// WHEN
Race race = new Race();
for (int i = 0; i < 4; i++) {
race.addContestant(() -> {
while (!end.get()) {
try {
appender.append(new TransactionToApply(sillyTransaction(1_000), CursorContext.NULL), LogAppendEvent.NULL);
} catch (Exception e) {
e.printStackTrace(System.out);
end.set(true);
fail(e.getMessage(), e);
}
}
});
}
race.addContestant(endAfterMax(250, MILLISECONDS, end, monitoring));
race.go();
// THEN
assertTrue(monitoring.numberOfRotations() > 0);
}
Aggregations