Ejemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldSeeThatACleanDatabaseShouldNotRequireRecovery() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldSeeThatACleanDatabaseShouldNotRequireRecovery()
        {
            File file = _logFiles.getLogFileForVersion(_logVersion);

            WriteSomeData(file, pair =>
            {
                LogEntryWriter writer = pair.first();
                Consumer <LogPositionMarker> consumer = pair.other();
                LogPositionMarker marker = new LogPositionMarker();

                // last committed tx
                consumer.accept(marker);
                writer.writeStartEntry(0, 1, 2L, 3L, new sbyte[0]);
                writer.writeCommitEntry(4L, 5L);

                // check point
                consumer.accept(marker);
                writer.writeCheckPointEntry(marker.newPosition());

                return(true);
            });

            LifeSupport     life    = new LifeSupport();
            RecoveryMonitor monitor = mock(typeof(RecoveryMonitor));

            try
            {
                StorageEngine storageEngine = mock(typeof(StorageEngine));
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.kernel.impl.transaction.log.entry.LogEntryReader<org.neo4j.kernel.impl.transaction.log.ReadableClosablePositionAwareChannel> reader = new org.neo4j.kernel.impl.transaction.log.entry.VersionAwareLogEntryReader<>();
                LogEntryReader <ReadableClosablePositionAwareChannel> reader = new VersionAwareLogEntryReader <ReadableClosablePositionAwareChannel>();
                LogTailScanner tailScanner = GetTailScanner(_logFiles, reader);

                TransactionMetadataCache metadataCache = new TransactionMetadataCache();
                LogicalTransactionStore  txStore       = new PhysicalLogicalTransactionStore(_logFiles, metadataCache, reader, _monitors, false);
                CorruptedLogsTruncator   logPruner     = new CorruptedLogsTruncator(_storeDir, _logFiles, FileSystemRule.get());
                life.add(new Recovery(new DefaultRecoveryServiceAnonymousInnerClass2(this, storageEngine, tailScanner, _transactionIdStore, txStore, _versionRepository, NO_MONITOR)
                                      , logPruner, _schemaLife, monitor, SilentProgressReporter.INSTANCE, false));

                life.Start();

                verifyZeroInteractions(monitor);
            }
            finally
            {
                life.Shutdown();
            }
        }
Ejemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldRecoverExistingData() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldRecoverExistingData()
        {
            File file = _logFiles.getLogFileForVersion(_logVersion);

            WriteSomeData(file, pair =>
            {
                LogEntryWriter writer = pair.first();
                Consumer <LogPositionMarker> consumer = pair.other();
                LogPositionMarker marker = new LogPositionMarker();

                // last committed tx
                consumer.accept(marker);
                LogPosition lastCommittedTxPosition = marker.newPosition();
                writer.writeStartEntry(0, 1, 2L, 3L, new sbyte[0]);
                _lastCommittedTxStartEntry = new LogEntryStart(0, 1, 2L, 3L, new sbyte[0], lastCommittedTxPosition);
                writer.writeCommitEntry(4L, 5L);
                _lastCommittedTxCommitEntry = new LogEntryCommit(4L, 5L);

                // check point pointing to the previously committed transaction
                writer.writeCheckPointEntry(lastCommittedTxPosition);
                _expectedCheckPointEntry = new CheckPoint(lastCommittedTxPosition);

                // tx committed after checkpoint
                consumer.accept(marker);
                writer.writeStartEntry(0, 1, 6L, 4L, new sbyte[0]);
                _expectedStartEntry = new LogEntryStart(0, 1, 6L, 4L, new sbyte[0], marker.newPosition());

                writer.writeCommitEntry(5L, 7L);
                _expectedCommitEntry = new LogEntryCommit(5L, 7L);

                return(true);
            });

            LifeSupport     life    = new LifeSupport();
            RecoveryMonitor monitor = mock(typeof(RecoveryMonitor));
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.concurrent.atomic.AtomicBoolean recoveryRequired = new java.util.concurrent.atomic.AtomicBoolean();
            AtomicBoolean recoveryRequired = new AtomicBoolean();

            try
            {
                StorageEngine storageEngine = mock(typeof(StorageEngine));
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.kernel.impl.transaction.log.entry.LogEntryReader<org.neo4j.kernel.impl.transaction.log.ReadableClosablePositionAwareChannel> reader = new org.neo4j.kernel.impl.transaction.log.entry.VersionAwareLogEntryReader<>();
                LogEntryReader <ReadableClosablePositionAwareChannel> reader = new VersionAwareLogEntryReader <ReadableClosablePositionAwareChannel>();
                LogTailScanner tailScanner = GetTailScanner(_logFiles, reader);

                TransactionMetadataCache metadataCache = new TransactionMetadataCache();
                LogicalTransactionStore  txStore       = new PhysicalLogicalTransactionStore(_logFiles, metadataCache, reader, _monitors, false);
                CorruptedLogsTruncator   logPruner     = new CorruptedLogsTruncator(_storeDir, _logFiles, FileSystemRule.get());
                life.add(new Recovery(new DefaultRecoveryServiceAnonymousInnerClass(this, storageEngine, tailScanner, _transactionIdStore, txStore, _versionRepository, NO_MONITOR, recoveryRequired)
                                      , logPruner, _schemaLife, monitor, SilentProgressReporter.INSTANCE, false));

                life.Start();

                InOrder order = inOrder(monitor);
                order.verify(monitor, times(1)).recoveryRequired(any(typeof(LogPosition)));
                order.verify(monitor, times(1)).recoveryCompleted(2);
                assertTrue(recoveryRequired.get());
            }
            finally
            {
                life.Shutdown();
            }
        }