Beispiel #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void reportProgressOnRecovery() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ReportProgressOnRecovery()
        {
            RecoveryService                    recoveryService           = mock(typeof(RecoveryService), Answers.RETURNS_MOCKS);
            CorruptedLogsTruncator             logsTruncator             = mock(typeof(CorruptedLogsTruncator));
            RecoveryMonitor                    recoveryMonitor           = mock(typeof(RecoveryMonitor));
            TransactionCursor                  reverseTransactionCursor  = mock(typeof(TransactionCursor));
            TransactionCursor                  transactionCursor         = mock(typeof(TransactionCursor));
            CommittedTransactionRepresentation transactionRepresentation = mock(typeof(CommittedTransactionRepresentation));

            int         transactionsToRecover         = 5;
            int         expectedMax                   = transactionsToRecover * 2;
            int         lastCommittedTransactionId    = 14;
            LogPosition recoveryStartPosition         = LogPosition.start(0);
            int         firstTxIdAfterLastCheckPoint  = 10;
            RecoveryStartInformation startInformation = new RecoveryStartInformation(recoveryStartPosition, firstTxIdAfterLastCheckPoint);

            when(reverseTransactionCursor.next()).thenAnswer(new NextTransactionAnswer(transactionsToRecover));
            when(transactionCursor.next()).thenAnswer(new NextTransactionAnswer(transactionsToRecover));
            when(reverseTransactionCursor.get()).thenReturn(transactionRepresentation);
            when(transactionCursor.get()).thenReturn(transactionRepresentation);
            when(transactionRepresentation.CommitEntry).thenReturn(new LogEntryCommit(lastCommittedTransactionId, 1L));

            when(recoveryService.RecoveryStartInformation).thenReturn(startInformation);
            when(recoveryService.GetTransactionsInReverseOrder(recoveryStartPosition)).thenReturn(reverseTransactionCursor);
            when(recoveryService.GetTransactions(recoveryStartPosition)).thenReturn(transactionCursor);

            AssertableProgressReporter progressReporter = new AssertableProgressReporter(expectedMax);
            Recovery recovery = new Recovery(recoveryService, logsTruncator, new LifecycleAdapter(), recoveryMonitor, progressReporter, true);

            Recovery.init();

            progressReporter.Verify();
        }
Beispiel #2
0
 public Recovery(RecoveryService recoveryService, CorruptedLogsTruncator logsTruncator, Lifecycle schemaLife, RecoveryMonitor monitor, ProgressReporter progressReporter, bool failOnCorruptedLogFiles)
 {
     this._recoveryService         = recoveryService;
     this._monitor                 = monitor;
     this._logsTruncator           = logsTruncator;
     this._schemaLife              = schemaLife;
     this._progressReporter        = progressReporter;
     this._failOnCorruptedLogFiles = failOnCorruptedLogFiles;
 }
Beispiel #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void setUp() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void SetUp()
        {
            _databaseDirectory = TestDirectory.databaseDir();
            SimpleLogVersionRepository logVersionRepository = new SimpleLogVersionRepository();
            SimpleTransactionIdStore   transactionIdStore   = new SimpleTransactionIdStore();

            _logFiles = LogFilesBuilder.logFilesBasedOnlyBuilder(_databaseDirectory, FileSystemRule).withRotationThreshold(LogHeader.LOG_HEADER_SIZE + 9L).withLogVersionRepository(logVersionRepository).withTransactionIdStore(transactionIdStore).build();
            Life.add(_logFiles);
            _logPruner = new CorruptedLogsTruncator(_databaseDirectory, _logFiles, FileSystemRule);
        }