예제 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCheckPointAlwaysWhenThereIsNoRunningCheckPoint() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldCheckPointAlwaysWhenThereIsNoRunningCheckPoint()
        {
            // 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(typeof(IOException));
            verify(_appender, times(1)).checkPoint(eq(_logPosition), any(typeof(LogCheckPointEvent)));
            verify(_threshold, times(1)).initialize(_initialTransactionId);
            verify(_threshold, times(1)).checkPointHappened(_transactionId);
            verify(_threshold, never()).isCheckPointingNeeded(_transactionId, _info);
            verify(_logPruning, times(1)).pruneLogs(_logPosition.LogVersion);
            verify(_tracer, times(1)).beginCheckPoint();
            verifyNoMoreInteractions(_storageEngine, _health, _appender, _threshold);
        }
예제 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void mustFlushAsFastAsPossibleDuringTryCheckPoint() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void MustFlushAsFastAsPossibleDuringTryCheckPoint()
        {
            AtomicBoolean doneDisablingLimits = new AtomicBoolean();

            _limiter = new IOLimiterAnonymousInnerClass3(this, doneDisablingLimits);
            MockTxIdStore();
            CheckPointerImpl checkPointer = checkPointer();

            checkPointer.TryCheckPoint(_info);
            assertTrue(doneDisablingLimits.get());
        }
예제 #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void tryCheckPointMustWaitForOnGoingCheckPointsToCompleteAsLongAsTimeoutPredicateIsFalse() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void TryCheckPointMustWaitForOnGoingCheckPointsToCompleteAsLongAsTimeoutPredicateIsFalse()
        {
            MockTxIdStore();
            CheckPointerImpl checkPointer        = checkPointer();
            BinaryLatch      arriveFlushAndForce = new BinaryLatch();
            BinaryLatch      finishFlushAndForce = new BinaryLatch();

            doAnswer(invocation =>
            {
                arriveFlushAndForce.Release();
                finishFlushAndForce.Await();
                return(null);
            }).when(_storageEngine).flushAndForce(_limiter);

            Thread forceCheckPointThread = new Thread(() =>
            {
                try
                {
                    checkPointer.ForceCheckPoint(_info);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.ToString());
                    Console.Write(e.StackTrace);
                    throw new Exception(e);
                }
            });

            forceCheckPointThread.Start();

            arriveFlushAndForce.Await();               // Wait for force-thread to arrive in flushAndForce().

            System.Func <bool> predicate = mock(typeof(System.Func <bool>));
            when(predicate()).thenReturn(false, false, true);
            assertThat(checkPointer.TryCheckPoint(_info, predicate), @is(-1L)); // We decided to not wait for the on-going check point to finish.

            finishFlushAndForce.Release();                                      // Let the flushAndForce complete.
            forceCheckPointThread.Join();

            assertThat(checkPointer.TryCheckPoint(_info, predicate), @is(this._transactionId));
        }
예제 #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void tryCheckPointShouldWaitTheCurrentCheckPointingToCompleteNoRunCheckPointButUseTheTxIdOfTheEarlierRun() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void TryCheckPointShouldWaitTheCurrentCheckPointingToCompleteNoRunCheckPointButUseTheTxIdOfTheEarlierRun()
        {
            // Given
            Lock @lock = mock(typeof(Lock));

            when(@lock.tryLock(anyLong(), any(typeof(TimeUnit)))).thenReturn(true);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final CheckPointerImpl checkPointing = checkPointer(mutex(lock));
            CheckPointerImpl checkPointing = CheckPointer(Mutex(@lock));

            MockTxIdStore();

            checkPointing.ForceCheckPoint(_info);

            verify(_appender).checkPoint(eq(_logPosition), any(typeof(LogCheckPointEvent)));
            reset(_appender);

            checkPointing.TryCheckPoint(_info);

            verifyNoMoreInteractions(_appender);
        }