private bool Recover(File storeDir, LogFiles logFiles) { 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 DefaultRecoveryServiceAnonymousInnerClass3(this, storageEngine, tailScanner, _transactionIdStore, txStore, _versionRepository, NO_MONITOR, recoveryRequired) , logPruner, _schemaLife, monitor, SilentProgressReporter.INSTANCE, false)); life.Start(); } finally { life.Shutdown(); } return(recoveryRequired.get()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldThrowWhenCachingATxWithNegativeOffsetPosition() public virtual void ShouldThrowWhenCachingATxWithNegativeOffsetPosition() { // given //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.kernel.impl.transaction.log.TransactionMetadataCache cache = new org.neo4j.kernel.impl.transaction.log.TransactionMetadataCache(); TransactionMetadataCache cache = new TransactionMetadataCache(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.kernel.impl.transaction.log.LogPosition position = new org.neo4j.kernel.impl.transaction.log.LogPosition(3, -1); LogPosition position = new LogPosition(3, -1); const int txId = 42; const int masterId = 0; const int authorId = 1; const int checksum = 2; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final long timestamp = System.currentTimeMillis(); long timestamp = DateTimeHelper.CurrentUnixTimeMillis(); // when try { cache.CacheTransactionMetadata(txId, position, masterId, authorId, checksum, timestamp); fail(); } catch (Exception ex) { assertEquals("StartEntry.position is " + position, ex.Message); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldReturnTheTxValueTIfInTheCached() public virtual void ShouldReturnTheTxValueTIfInTheCached() { // given //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.kernel.impl.transaction.log.TransactionMetadataCache cache = new org.neo4j.kernel.impl.transaction.log.TransactionMetadataCache(); TransactionMetadataCache cache = new TransactionMetadataCache(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.kernel.impl.transaction.log.LogPosition position = new org.neo4j.kernel.impl.transaction.log.LogPosition(3, 4); LogPosition position = new LogPosition(3, 4); const int txId = 42; const int masterId = 0; const int authorId = 1; const int checksum = 2; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final long timestamp = System.currentTimeMillis(); long timestamp = DateTimeHelper.CurrentUnixTimeMillis(); // when cache.CacheTransactionMetadata(txId, position, masterId, authorId, checksum, timestamp); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.kernel.impl.transaction.log.TransactionMetadataCache.TransactionMetadata metadata = cache.getTransactionMetadata(txId); TransactionMetadataCache.TransactionMetadata metadata = cache.GetTransactionMetadata(txId); // then assertEquals(new TransactionMetadataCache.TransactionMetadata(masterId, authorId, position, checksum, timestamp), metadata); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldReturnNullWhenMissingATxInTheCache() public virtual void ShouldReturnNullWhenMissingATxInTheCache() { // given //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.kernel.impl.transaction.log.TransactionMetadataCache cache = new org.neo4j.kernel.impl.transaction.log.TransactionMetadataCache(); TransactionMetadataCache cache = new TransactionMetadataCache(); // when //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.kernel.impl.transaction.log.TransactionMetadataCache.TransactionMetadata metadata = cache.getTransactionMetadata(42); TransactionMetadataCache.TransactionMetadata metadata = cache.GetTransactionMetadata(42); // then assertNull(metadata); }
//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(); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public System.Nullable<long> call() throws Exception public override long?Call() { long lastCommittedTransactionId; using (FileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction(), Lifespan life = new Lifespan()) { TransactionIdStore transactionIdStore = new SimpleTransactionIdStore(); TransactionMetadataCache transactionMetadataCache = new TransactionMetadataCache(); LogFiles logFiles = life.Add(CreateLogFiles(transactionIdStore, fileSystem)); TransactionAppender transactionAppender = life.Add(CreateBatchingTransactionAppender(transactionIdStore, transactionMetadataCache, logFiles)); ExecutorService executorService = Executors.newFixedThreadPool(_threads); try { //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: java.util.concurrent.Future<?>[] handlers = new java.util.concurrent.Future[threads]; Future <object>[] handlers = new Future[_threads]; for (int i = 0; i < _threads; i++) { TransactionRepresentationFactory factory = new TransactionRepresentationFactory(); Worker task = new Worker(transactionAppender, factory, _condition); handlers[i] = executorService.submit(task); } // wait for all the workers to complete //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: for (java.util.concurrent.Future<?> handle : handlers) foreach (Future <object> handle in handlers) { handle.get(); } } finally { executorService.shutdown(); } lastCommittedTransactionId = transactionIdStore.LastCommittedTransactionId; } return(lastCommittedTransactionId); }
private static BatchingTransactionAppender CreateBatchingTransactionAppender(TransactionIdStore transactionIdStore, TransactionMetadataCache transactionMetadataCache, LogFiles logFiles) { Log log = NullLog.Instance; KernelEventHandlers kernelEventHandlers = new KernelEventHandlers(log); DatabasePanicEventGenerator panicEventGenerator = new DatabasePanicEventGenerator(kernelEventHandlers); DatabaseHealth databaseHealth = new DatabaseHealth(panicEventGenerator, log); LogRotationImpl logRotation = new LogRotationImpl(NOOP_LOGROTATION_MONITOR, logFiles, databaseHealth); return(new BatchingTransactionAppender(logFiles, logRotation, transactionMetadataCache, transactionIdStore, IdOrderingQueue.BYPASS, databaseHealth)); }
//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(); } }