Search in sources :

Example 1 with LogRotationMonitor

use of org.neo4j.kernel.impl.transaction.log.rotation.monitor.LogRotationMonitor 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.
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) LogRotationMonitor(org.neo4j.kernel.impl.transaction.log.rotation.monitor.LogRotationMonitor) CountDownLatch(java.util.concurrent.CountDownLatch) LogRotationMonitorAdapter(org.neo4j.kernel.impl.transaction.log.rotation.monitor.LogRotationMonitorAdapter) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

CountDownLatch (java.util.concurrent.CountDownLatch)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1 LogRotationMonitor (org.neo4j.kernel.impl.transaction.log.rotation.monitor.LogRotationMonitor)1 LogRotationMonitorAdapter (org.neo4j.kernel.impl.transaction.log.rotation.monitor.LogRotationMonitorAdapter)1