@Override void flush( GraphDatabaseAPI db ) { IOLimiter limiter = IOLimiter.UNLIMITED; db.getDependencyResolver().resolveDependency( StorageEngine.class ).flushAndForce( limiter ); } },
private static void flush( GraphDatabaseService db ) { ((GraphDatabaseAPI)db).getDependencyResolver().resolveDependency( StorageEngine.class ).flushAndForce( IOLimiter.UNLIMITED ); }
private void flushAll() { db.getDependencyResolver().resolveDependency( StorageEngine.class ).flushAndForce( IOLimiter.UNLIMITED ); } }
@Test public void shouldCheckPointAlwaysWhenThereIsNoRunningCheckPoint() throws Throwable { // Given CheckPointerImpl checkPointing = checkPointer(); when( threshold.isCheckPointingNeeded( anyLong(), eq( INFO ) ) ).thenReturn( false ); mockTxIdStore(); checkPointing.start(); // When long txId = checkPointing.tryCheckPoint( INFO ); // Then assertEquals( transactionId, txId ); verify( storageEngine, times( 1 ) ).flushAndForce( limiter ); verify( health, times( 2 ) ).assertHealthy( IOException.class ); verify( appender, times( 1 ) ).checkPoint( eq( logPosition ), any( LogCheckPointEvent.class ) ); verify( threshold, times( 1 ) ).initialize( initialTransactionId ); verify( threshold, times( 1 ) ).checkPointHappened( transactionId ); verify( threshold, never() ).isCheckPointingNeeded( transactionId, INFO ); verify( logPruning, times( 1 ) ).pruneLogs( logPosition.getLogVersion() ); verifyZeroInteractions( tracer ); verifyNoMoreInteractions( storageEngine, health, appender, threshold, tracer ); }
@Test public void shouldForceCheckPointAlways() throws Throwable { // Given CheckPointerImpl checkPointing = checkPointer(); when( threshold.isCheckPointingNeeded( anyLong(), eq( INFO ) ) ).thenReturn( false ); mockTxIdStore(); checkPointing.start(); // When long txId = checkPointing.forceCheckPoint( INFO ); // Then assertEquals( transactionId, txId ); verify( storageEngine, times( 1 ) ).flushAndForce( limiter ); verify( health, times( 2 ) ).assertHealthy( IOException.class ); verify( appender, times( 1 ) ).checkPoint( eq( logPosition ), any( LogCheckPointEvent.class ) ); verify( threshold, times( 1 ) ).initialize( initialTransactionId ); verify( threshold, times( 1 ) ).checkPointHappened( transactionId ); verify( threshold, never() ).isCheckPointingNeeded( transactionId, INFO ); verify( logPruning, times( 1 ) ).pruneLogs( logPosition.getLogVersion() ); verifyZeroInteractions( tracer ); verifyNoMoreInteractions( storageEngine, health, appender, threshold, tracer ); }
@Test public void shouldFlushIfItIsNeeded() throws Throwable { // Given CheckPointerImpl checkPointing = checkPointer(); when( threshold.isCheckPointingNeeded( anyLong(), eq( INFO ) ) ).thenReturn( true, false ); mockTxIdStore(); checkPointing.start(); // When long txId = checkPointing.checkPointIfNeeded( INFO ); // Then assertEquals( transactionId, txId ); verify( storageEngine, times( 1 ) ).flushAndForce( limiter ); verify( health, times( 2 ) ).assertHealthy( IOException.class ); verify( appender, times( 1 ) ).checkPoint( eq( logPosition ), any( LogCheckPointEvent.class ) ); verify( threshold, times( 1 ) ).initialize( initialTransactionId ); verify( threshold, times( 1 ) ).checkPointHappened( transactionId ); verify( threshold, times( 1 ) ).isCheckPointingNeeded( transactionId, INFO ); verify( logPruning, times( 1 ) ).pruneLogs( logPosition.getLogVersion() ); verify( tracer, times( 1 ) ).beginCheckPoint(); verifyNoMoreInteractions( storageEngine, health, appender, threshold, tracer ); }
@Test public void mustUseIoLimiterFromFlushing() throws Throwable { limiter = new IOLimiter() { @Override public long maybeLimitIO( long previousStamp, int recentlyCompletedIOs, Flushable flushable ) { return 42; } @Override public boolean isLimited() { return true; } }; when( threshold.isCheckPointingNeeded( anyLong(), eq( INFO ) ) ).thenReturn( true, false ); mockTxIdStore(); CheckPointerImpl checkPointing = checkPointer(); checkPointing.start(); checkPointing.checkPointIfNeeded( INFO ); verify( storageEngine ).flushAndForce( limiter ); }
storageEngine.flushAndForce( ioLimiter );
observedRushCount.set( newValue ); return null; } ).when( storageEngine ).flushAndForce( limiter );
storageEngine.flushAndForce( ioLimiter );