Search in sources :

Example 1 with EmptyIOController

use of org.neo4j.io.pagecache.EmptyIOController in project neo4j by neo4j.

the class CheckPointerImplTest method mustFlushAsFastAsPossibleDuringTryCheckPoint.

@Test
void mustFlushAsFastAsPossibleDuringTryCheckPoint() throws Exception {
    AtomicBoolean doneDisablingLimits = new AtomicBoolean();
    limiter = new EmptyIOController() {

        @Override
        public void enable() {
            doneDisablingLimits.set(true);
        }

        @Override
        public boolean isEnabled() {
            return doneDisablingLimits.get();
        }
    };
    mockTxIdStore();
    CheckPointerImpl checkPointer = checkPointer();
    checkPointer.tryCheckPoint(INFO);
    assertTrue(doneDisablingLimits.get());
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) EmptyIOController(org.neo4j.io.pagecache.EmptyIOController) Test(org.junit.jupiter.api.Test)

Example 2 with EmptyIOController

use of org.neo4j.io.pagecache.EmptyIOController in project neo4j by neo4j.

the class CheckPointerImplTest method mustFlushAsFastAsPossibleDuringForceCheckPoint.

@Test
void mustFlushAsFastAsPossibleDuringForceCheckPoint() throws Exception {
    AtomicBoolean doneDisablingLimits = new AtomicBoolean();
    limiter = new EmptyIOController() {

        @Override
        public void enable() {
            doneDisablingLimits.set(true);
        }

        @Override
        public boolean isEnabled() {
            return doneDisablingLimits.get();
        }
    };
    mockTxIdStore();
    CheckPointerImpl checkPointer = checkPointer();
    checkPointer.forceCheckPoint(new SimpleTriggerInfo("test"));
    assertTrue(doneDisablingLimits.get());
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) EmptyIOController(org.neo4j.io.pagecache.EmptyIOController) Test(org.junit.jupiter.api.Test)

Example 3 with EmptyIOController

use of org.neo4j.io.pagecache.EmptyIOController in project neo4j by neo4j.

the class CheckPointerImplTest method verifyAsyncActionCausesConcurrentFlushingRush.

private void verifyAsyncActionCausesConcurrentFlushingRush(ThrowingConsumer<CheckPointerImpl, IOException> asyncAction) throws Exception {
    AtomicLong limitDisableCounter = new AtomicLong();
    AtomicLong observedRushCount = new AtomicLong();
    BinaryLatch backgroundCheckPointStartedLatch = new BinaryLatch();
    BinaryLatch forceCheckPointStartLatch = new BinaryLatch();
    limiter = new EmptyIOController() {

        @Override
        public void disable() {
            limitDisableCounter.getAndIncrement();
            forceCheckPointStartLatch.release();
        }

        @Override
        public void enable() {
            limitDisableCounter.getAndDecrement();
        }

        @Override
        public boolean isEnabled() {
            return limitDisableCounter.get() != 0;
        }
    };
    mockTxIdStore();
    CheckPointerImpl checkPointer = checkPointer();
    doAnswer(invocation -> {
        backgroundCheckPointStartedLatch.release();
        forceCheckPointStartLatch.await();
        long newValue = limitDisableCounter.get();
        observedRushCount.set(newValue);
        return null;
    }).when(forceOperation).flushAndForce(any());
    Future<Object> forceCheckPointer = forkFuture(() -> {
        backgroundCheckPointStartedLatch.await();
        asyncAction.accept(checkPointer);
        return null;
    });
    when(threshold.isCheckPointingNeeded(anyLong(), anyLong(), eq(INFO))).thenReturn(true);
    checkPointer.checkPointIfNeeded(INFO);
    forceCheckPointer.get();
    assertThat(observedRushCount.get()).isEqualTo(1L);
}
Also used : AtomicLong(java.util.concurrent.atomic.AtomicLong) EmptyIOController(org.neo4j.io.pagecache.EmptyIOController) BinaryLatch(org.neo4j.util.concurrent.BinaryLatch)

Aggregations

EmptyIOController (org.neo4j.io.pagecache.EmptyIOController)3 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 Test (org.junit.jupiter.api.Test)2 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 BinaryLatch (org.neo4j.util.concurrent.BinaryLatch)1