use of org.neo4j.kernel.impl.transaction.log.rotation.monitor.LogRotationMonitorAdapter in project neo4j by neo4j.
the class TransactionLogFileIT method doNotScanDirectoryOnRotate.
@Test
@EnabledOnOs(OS.LINUX)
void doNotScanDirectoryOnRotate() throws IOException {
LogFiles logFiles = LogFilesBuilder.builder(databaseLayout, fileSystem).withTransactionIdStore(transactionIdStore).withLogVersionRepository(logVersionRepository).withStoreId(StoreId.UNKNOWN).build();
life.add(logFiles);
life.start();
MutableLong rotationObservedVersion = new MutableLong();
LogRotation logRotation = FileLogRotation.transactionLogRotation(logFiles, Clock.systemUTC(), new DatabaseHealth(NO_OP, NullLog.getInstance()), new LogRotationMonitorAdapter() {
@Override
public void startRotation(long currentLogVersion) {
rotationObservedVersion.setValue(currentLogVersion);
}
});
for (int i = 0; i < 6; i++) {
for (Path path : logFiles.logFiles()) {
FileUtils.deleteFile(path);
}
logRotation.rotateLogFile(LogAppendEvent.NULL);
}
assertEquals(5, rotationObservedVersion.getValue());
assertEquals(6, logFiles.getLogFile().getCurrentLogVersion());
}
use of org.neo4j.kernel.impl.transaction.log.rotation.monitor.LogRotationMonitorAdapter in project neo4j by neo4j.
the class TestStartTransactionDuringLogRotation method setUp.
@BeforeEach
void setUp() throws InterruptedException {
executor = Executors.newCachedThreadPool();
startLogRotationLatch = new CountDownLatch(1);
completeLogRotationLatch = new CountDownLatch(1);
writerStopped = new AtomicBoolean();
LogRotationMonitor rotationListener = new LogRotationMonitorAdapter() {
@Override
public void startRotation(long currentLogVersion) {
startLogRotationLatch.countDown();
try {
completeLogRotationLatch.await();
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
};
monitors.addMonitorListener(rotationListener);
label = Label.label("Label");
rotationFuture = t2.execute(forceLogRotation(database));
// Waiting for the writer task to start a log rotation
startLogRotationLatch.await();
// Then we should be able to start a transaction, though perhaps not be able to finish it.
// This is what the individual test methods will be doing.
// The test passes when transaction.close completes within the test timeout, that is, it didn't deadlock.
}
Aggregations