Beispiel #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);
        }
Beispiel #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void forceCheckPointShouldWaitTheCurrentCheckPointingToCompleteBeforeRunning() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ForceCheckPointShouldWaitTheCurrentCheckPointingToCompleteBeforeRunning()
        {
            // Given
            Lock @lock = new ReentrantLock();
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.concurrent.locks.Lock spyLock = spy(lock);
            Lock spyLock = spy(@lock);

            doAnswer(invocation =>
            {
                verify(_appender).checkPoint(any(typeof(LogPosition)), any(typeof(LogCheckPointEvent)));
                reset(_appender);
                invocation.callRealMethod();
                return(null);
            }).when(spyLock).unlock();

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final CheckPointerImpl checkPointing = checkPointer(mutex(spyLock));
            CheckPointerImpl checkPointing = CheckPointer(Mutex(spyLock));

            MockTxIdStore();

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.concurrent.CountDownLatch startSignal = new java.util.concurrent.CountDownLatch(2);
            System.Threading.CountdownEvent startSignal = new System.Threading.CountdownEvent(2);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.concurrent.CountDownLatch completed = new java.util.concurrent.CountDownLatch(2);
            System.Threading.CountdownEvent completed = new System.Threading.CountdownEvent(2);

            checkPointing.Start();

            Thread checkPointerThread = new CheckPointerThread(checkPointing, startSignal, completed);

            Thread forceCheckPointThread = new Thread(() =>
            {
                try
                {
                    startSignal.Signal();
                    startSignal.await();
                    checkPointing.ForceCheckPoint(_info);

                    completed.Signal();
                }
                catch (Exception e)
                {
                    throw new Exception(e);
                }
            });

            // when
            checkPointerThread.Start();
            forceCheckPointThread.Start();

            completed.await();

            verify(spyLock, times(2)).@lock();
            verify(spyLock, times(2)).unlock();
        }
Beispiel #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void mustUseIoLimiterFromFlushing() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void MustUseIoLimiterFromFlushing()
        {
            _limiter = new IOLimiterAnonymousInnerClass(this);
            when(_threshold.isCheckPointingNeeded(anyLong(), eq(_info))).thenReturn(true, false);
            MockTxIdStore();
            CheckPointerImpl checkPointing = CheckPointer();

            checkPointing.Start();
            checkPointing.CheckPointIfNeeded(_info);

            verify(_storageEngine).flushAndForce(_limiter);
        }
Beispiel #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotFlushIfItIsNotNeeded() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldNotFlushIfItIsNotNeeded()
        {
            // Given
            CheckPointerImpl checkPointing = CheckPointer();

            when(_threshold.isCheckPointingNeeded(anyLong(), any(typeof(TriggerInfo)))).thenReturn(false);

            checkPointing.Start();

            // When
            long txId = checkPointing.CheckPointIfNeeded(_info);

            // Then
            assertEquals(-1, txId);
            verifyZeroInteractions(_storageEngine);
            verifyZeroInteractions(_tracer);
            verifyZeroInteractions(_appender);
        }