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());
}
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());
}
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);
}
Aggregations