private CommittedTransactionRepresentation Tx(int txId) { CommittedTransactionRepresentation tx = mock(typeof(CommittedTransactionRepresentation)); when(tx.CommitEntry).thenReturn(new LogEntryCommit(txId, 0)); return(tx); }
public override void OnTxReceived(TxPullResponse txPullResponse) { lock (this) { CommittedTransactionRepresentation tx = txPullResponse.Tx(); long receivedTxId = tx.CommitEntry.TxId; // neo4j admin backup clients pull transactions indefinitely and have no monitoring mechanism for tx log rotation // Other cases, ex. Read Replicas have an external mechanism that rotates independently of this process and don't need to // manually rotate while pulling if (_rotateTransactionsManually && _logFiles.LogFile.rotationNeeded()) { RotateTransactionLogs(_logFiles); } if (receivedTxId != _expectedTxId) { throw new Exception(format("Expected txId: %d but got: %d", _expectedTxId, receivedTxId)); } _lastTxId = receivedTxId; _expectedTxId++; try { _writer.append(tx.TransactionRepresentation, _lastTxId); } catch (IOException e) { _log.error("Failed when appending to transaction log", e); } } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void verifyTransaction(TransactionIdStore transactionIdStore, TransactionMetadataCache positionCache, byte[] additionalHeader, int masterId, int authorId, long timeStarted, long latestCommittedTxWhenStarted, long timeCommitted, LogicalTransactionStore store) throws java.io.IOException private void VerifyTransaction(TransactionIdStore transactionIdStore, TransactionMetadataCache positionCache, sbyte[] additionalHeader, int masterId, int authorId, long timeStarted, long latestCommittedTxWhenStarted, long timeCommitted, LogicalTransactionStore store) { TransactionMetadata expectedMetadata; using (TransactionCursor cursor = store.GetTransactions(TransactionIdStore_Fields.BASE_TX_ID + 1)) { bool hasNext = cursor.next(); assertTrue(hasNext); CommittedTransactionRepresentation tx = cursor.get(); TransactionRepresentation transaction = tx.TransactionRepresentation; assertArrayEquals(additionalHeader, transaction.AdditionalHeader()); assertEquals(masterId, transaction.MasterId); assertEquals(authorId, transaction.AuthorId); assertEquals(timeStarted, transaction.TimeStarted); assertEquals(timeCommitted, transaction.TimeCommitted); assertEquals(latestCommittedTxWhenStarted, transaction.LatestCommittedTxWhenStarted); expectedMetadata = new TransactionMetadata(masterId, authorId, tx.StartEntry.StartPosition, tx.StartEntry.checksum(), timeCommitted); } positionCache.Clear(); TransactionMetadata actualMetadata = store.GetMetadataFor(transactionIdStore.LastCommittedTransactionId); assertEquals(expectedMetadata, actualMetadata); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private org.neo4j.function.ThrowingFunction<org.neo4j.kernel.impl.transaction.log.LogPosition,org.neo4j.kernel.impl.transaction.log.TransactionCursor,java.io.IOException> log(int... transactionCounts) throws java.io.IOException private ThrowingFunction <LogPosition, TransactionCursor, IOException> Log(params int[] transactionCounts) { long baseOffset = LogPosition.start(0).ByteOffset; //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") org.neo4j.function.ThrowingFunction<org.neo4j.kernel.impl.transaction.log.LogPosition,org.neo4j.kernel.impl.transaction.log.TransactionCursor,java.io.IOException> result = mock(org.neo4j.function.ThrowingFunction.class); ThrowingFunction <LogPosition, TransactionCursor, IOException> result = mock(typeof(ThrowingFunction)); AtomicLong txId = new AtomicLong(0); CommittedTransactionRepresentation[][] logs = new CommittedTransactionRepresentation[transactionCounts.Length][]; for (int logVersion = 0; logVersion < transactionCounts.Length; logVersion++) { logs[logVersion] = Transactions(transactionCounts[logVersion], txId); } when(result.Apply(any(typeof(LogPosition)))).thenAnswer(invocation => { LogPosition position = invocation.getArgument(0); if (position == null) { // A mockito issue when calling the "when" methods, I believe return(null); } // For simplicity the offset means, in this test, the array offset CommittedTransactionRepresentation[] transactions = logs[toIntExact(position.LogVersion)]; CommittedTransactionRepresentation[] subset = copyOfRange(transactions, toIntExact(position.ByteOffset - baseOffset), transactions.Length); ArrayUtil.reverse(subset); return(given(subset)); }); return(result); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public org.neo4j.kernel.impl.transaction.log.TransactionMetadataCache.TransactionMetadata getMetadataFor(long transactionId) throws java.io.IOException public override TransactionMetadata GetMetadataFor(long transactionId) { if (transactionId <= BASE_TX_ID) { return(_metadataForEmptyStore); } TransactionMetadata transactionMetadata = _transactionMetadataCache.getTransactionMetadata(transactionId); if (transactionMetadata == null) { using (IOCursor <CommittedTransactionRepresentation> cursor = GetTransactions(transactionId)) { while (cursor.next()) { CommittedTransactionRepresentation tx = cursor.get(); LogEntryCommit commitEntry = tx.CommitEntry; long committedTxId = commitEntry.TxId; long timeWritten = commitEntry.TimeWritten; TransactionMetadata metadata = _transactionMetadataCache.cacheTransactionMetadata(committedTxId, tx.StartEntry.StartPosition, tx.StartEntry.MasterId, tx.StartEntry.LocalId, LogEntryStart.checksum(tx.StartEntry), timeWritten); if (committedTxId == transactionId) { transactionMetadata = metadata; } } } if (transactionMetadata == null) { throw new NoSuchTransactionException(transactionId); } } return(transactionMetadata); }
private CommittedTransactionRepresentation[] Transactions(int count, AtomicLong txId) { CommittedTransactionRepresentation[] result = new CommittedTransactionRepresentation[count]; for (int i = 0; i < count; i++) { CommittedTransactionRepresentation transaction = result[i] = mock(typeof(CommittedTransactionRepresentation)); LogEntryCommit commitEntry = mock(typeof(LogEntryCommit)); when(commitEntry.TxId).thenReturn(txId.AndIncrement); when(transaction.CommitEntry).thenReturn(commitEntry); } return(result); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public Object readChunk(io.netty.buffer.ByteBufAllocator allocator) throws Exception public override object ReadChunk(ByteBufAllocator allocator) { Debug.Assert(!_endOfInput); if (_pending != null) { if (_noMoreTransactions) { _endOfInput = true; } return(ConsumePending()); } else if (_noMoreTransactions) { /* finalization should always have a last ending message */ throw new System.InvalidOperationException(); } else if (_txCursor.next()) { Debug.Assert(_pending == null); CommittedTransactionRepresentation tx = _txCursor.get(); _lastTxId = tx.CommitEntry.TxId; if (_lastTxId != _expectedTxId) { string msg = format("Transaction cursor out of order. Expected %d but was %d", _expectedTxId, _lastTxId); throw new System.InvalidOperationException(msg); } _expectedTxId++; _pending = new TxPullResponse(_storeId, tx); return(ResponseMessageType.TX); } else { Debug.Assert(_pending == null); _noMoreTransactions = true; _protocol.expect(CatchupServerProtocol.State.MESSAGE_TYPE); CatchupResult result; if (_lastTxId >= _txIdPromise) { result = SUCCESS_END_OF_STREAM; } else { result = E_TRANSACTION_PRUNED; _log.warn("Transaction cursor fell short. Expected at least %d but only got to %d.", _txIdPromise, _lastTxId); } _pending = new TxStreamFinishedResponse(result, _lastTxId); return(ResponseMessageType.TX_STREAM_FINISHED); } }
public override bool Visit(CommittedTransactionRepresentation tx) { TransactionRepresentation transaction = tx.TransactionRepresentation; assertArrayEquals(AdditionalHeader, transaction.AdditionalHeader()); assertEquals(MasterId, transaction.MasterId); assertEquals(AuthorId, transaction.AuthorId); assertEquals(TimeStarted, transaction.TimeStarted); assertEquals(TimeCommitted, transaction.TimeCommitted); assertEquals(LatestCommittedTxWhenStarted, transaction.LatestCommittedTxWhenStarted); VisitedTransactionsConflict++; return(false); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public boolean next() throws java.io.IOException public override bool Next() { // Clear the previous deserialized transaction so that it won't have to be kept in heap while deserializing // the next one. Could be problematic if both are really big. _current = null; while (true) { if (!_logEntryCursor.next()) { return(false); } LogEntry entry = _logEntryCursor.get(); if (entry is CheckPoint) { // this is a good position anyhow _channel.getCurrentPosition(_lastGoodPositionMarker); continue; } Debug.Assert(entry is LogEntryStart, "Expected Start entry, read " + entry + " instead"); LogEntryStart startEntry = entry.As(); LogEntryCommit commitEntry; IList <StorageCommand> entries = new List <StorageCommand>(); while (true) { if (!_logEntryCursor.next()) { return(false); } entry = _logEntryCursor.get(); if (entry is LogEntryCommit) { commitEntry = entry.As(); break; } LogEntryCommand command = entry.As(); entries.Add(command.Command); } PhysicalTransactionRepresentation transaction = new PhysicalTransactionRepresentation(entries); transaction.SetHeader(startEntry.AdditionalHeader, startEntry.MasterId, startEntry.LocalId, startEntry.TimeWritten, startEntry.LastCommittedTxWhenTransactionStarted, commitEntry.TimeWritten, -1); _current = new CommittedTransactionRepresentation(startEntry, transaction, commitEntry); _channel.getCurrentPosition(_lastGoodPositionMarker); return(true); } }
private CommittedTransactionRepresentation CreateTxWithId(long txId) { CommittedTransactionRepresentation tx = mock(typeof(CommittedTransactionRepresentation)); LogEntryCommit commitEntry = mock(typeof(LogEntryCommit)); when(commitEntry.TxId).thenReturn(txId); TransactionRepresentation txRep = mock(typeof(TransactionRepresentation)); sbyte[] encodedRaftLogIndex = encodeLogIndexAsTxHeader(txId - 5); // just some arbitrary offset when(txRep.AdditionalHeader()).thenReturn(encodedRaftLogIndex); when(tx.TransactionRepresentation).thenReturn(txRep); when(tx.CommitEntry).thenReturn(commitEntry); return(tx); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldReverseTransactionsFromSource() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldReverseTransactionsFromSource() { // GIVEN CommittedTransactionRepresentation tx1 = mock(typeof(CommittedTransactionRepresentation)); CommittedTransactionRepresentation tx2 = mock(typeof(CommittedTransactionRepresentation)); CommittedTransactionRepresentation tx3 = mock(typeof(CommittedTransactionRepresentation)); TransactionCursor source = given(tx1, tx2, tx3); EagerlyReversedTransactionCursor cursor = new EagerlyReversedTransactionCursor(source); // WHEN CommittedTransactionRepresentation[] reversed = exhaust(cursor); // THEN assertArrayEquals(array(tx3, tx2, tx1), reversed); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: protected void decode(io.netty.channel.ChannelHandlerContext ctx, io.netty.buffer.ByteBuf msg, java.util.List<Object> out) throws Exception protected internal override void Decode(ChannelHandlerContext ctx, ByteBuf msg, IList <object> @out) { NetworkReadableClosableChannelNetty4 logChannel = new NetworkReadableClosableChannelNetty4(msg); StoreId storeId = StoreIdMarshal.INSTANCE.unmarshal(logChannel); LogEntryReader <NetworkReadableClosableChannelNetty4> reader = new VersionAwareLogEntryReader <NetworkReadableClosableChannelNetty4>(new RecordStorageCommandReaderFactory(), InvalidLogEntryHandler.STRICT); PhysicalTransactionCursor <NetworkReadableClosableChannelNetty4> transactionCursor = new PhysicalTransactionCursor <NetworkReadableClosableChannelNetty4>(logChannel, reader); transactionCursor.Next(); CommittedTransactionRepresentation tx = transactionCursor.Get(); if (tx != null) { @out.Add(new TxPullResponse(storeId, tx)); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private long applyTransactions(java.io.File fromPath, org.neo4j.kernel.internal.GraphDatabaseAPI toDb, org.neo4j.kernel.configuration.Config toConfig, long fromTxExclusive, long toTxInclusive, java.io.PrintStream out) throws Exception private long ApplyTransactions( File fromPath, GraphDatabaseAPI toDb, Config toConfig, long fromTxExclusive, long toTxInclusive, PrintStream @out ) { DependencyResolver resolver = toDb.DependencyResolver; TransactionRepresentationCommitProcess commitProcess = new TransactionRepresentationCommitProcess( resolver.ResolveDependency( typeof( TransactionAppender ) ), resolver.ResolveDependency( typeof( StorageEngine ) ) ); LifeSupport life = new LifeSupport(); try { using ( DefaultFileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction(), JobScheduler jobScheduler = createInitialisedScheduler(), PageCache pageCache = StandalonePageCacheFactory.createPageCache(fileSystem, jobScheduler) ) { LogicalTransactionStore source = life.Add( new ReadOnlyTransactionStore( pageCache, fileSystem, DatabaseLayout.of( fromPath ), Config.defaults(), new Monitors() ) ); life.Start(); long lastAppliedTx = fromTxExclusive; // Some progress if there are more than a couple of transactions to apply ProgressListener progress = toTxInclusive - fromTxExclusive >= 100 ? textual( @out ).singlePart( "Application progress", toTxInclusive - fromTxExclusive ) : Org.Neo4j.Helpers.progress.ProgressListener_Fields.None; using ( IOCursor<CommittedTransactionRepresentation> cursor = source.GetTransactions( fromTxExclusive + 1 ) ) { while ( cursor.next() ) { CommittedTransactionRepresentation transaction = cursor.get(); TransactionRepresentation transactionRepresentation = transaction.TransactionRepresentation; try { commitProcess.Commit( new TransactionToApply( transactionRepresentation ), NULL, EXTERNAL ); progress.Add( 1 ); } //JAVA TO C# CONVERTER WARNING: 'final' catch parameters are not available in C#: //ORIGINAL LINE: catch (final Throwable e) catch ( Exception e ) { Console.Error.WriteLine( "ERROR applying transaction " + transaction.CommitEntry.TxId ); throw e; } lastAppliedTx = transaction.CommitEntry.TxId; if ( lastAppliedTx == toTxInclusive ) { break; } } } return lastAppliedTx; } } finally { life.Shutdown(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldAppendCommittedTransactions() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldAppendCommittedTransactions() { // GIVEN when(_logFile.Writer).thenReturn(_channel); long nextTxId = 15; when(_transactionIdStore.nextCommittingTransactionId()).thenReturn(nextTxId); TransactionAppender appender = Life.add(new BatchingTransactionAppender(_logFiles, NO_ROTATION, _positionCache, _transactionIdStore, BYPASS, _databaseHealth)); // WHEN //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final byte[] additionalHeader = new byte[]{1, 2, 5}; sbyte[] additionalHeader = new sbyte[] { 1, 2, 5 }; const int masterId = 2; int authorId = 1; const long timeStarted = 12345; long latestCommittedTxWhenStarted = nextTxId - 5; long timeCommitted = timeStarted + 10; PhysicalTransactionRepresentation transactionRepresentation = new PhysicalTransactionRepresentation(SingleCreateNodeCommand(0)); transactionRepresentation.SetHeader(additionalHeader, masterId, authorId, timeStarted, latestCommittedTxWhenStarted, timeCommitted, -1); LogEntryStart start = new LogEntryStart(0, 0, 0L, latestCommittedTxWhenStarted, null, LogPosition.UNSPECIFIED); LogEntryCommit commit = new LogEntryCommit(nextTxId, 0L); CommittedTransactionRepresentation transaction = new CommittedTransactionRepresentation(start, transactionRepresentation, commit); appender.Append(new TransactionToApply(transactionRepresentation, transaction.CommitEntry.TxId), _logAppendEvent); // THEN LogEntryReader <ReadableLogChannel> logEntryReader = new VersionAwareLogEntryReader <ReadableLogChannel>(); using (PhysicalTransactionCursor <ReadableLogChannel> reader = new PhysicalTransactionCursor <ReadableLogChannel>(_channel, logEntryReader)) { reader.Next(); TransactionRepresentation result = reader.Get().TransactionRepresentation; assertArrayEquals(additionalHeader, result.AdditionalHeader()); assertEquals(masterId, result.MasterId); assertEquals(authorId, result.AuthorId); assertEquals(timeStarted, result.TimeStarted); assertEquals(timeCommitted, result.TimeCommitted); assertEquals(latestCommittedTxWhenStarted, result.LatestCommittedTxWhenStarted); } }
/// <summary> /// Queues a transaction for application. /// </summary> /// <param name="tx"> The transaction to be queued for application. </param> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public void queue(org.neo4j.kernel.impl.transaction.CommittedTransactionRepresentation tx) throws Exception public virtual void Queue(CommittedTransactionRepresentation tx) { long receivedTxId = tx.CommitEntry.TxId; long expectedTxId = _lastQueuedTxId + 1; if (receivedTxId != expectedTxId) { _log.warn("Out of order transaction. Received: %d Expected: %d", receivedTxId, expectedTxId); return; } _txQueue.queue(new TransactionToApply(tx.TransactionRepresentation, receivedTxId, _versionContextSupplier.VersionContext)); if (!_stopped) { _lastQueuedTxId = receivedTxId; _monitor.txPullResponse(receivedTxId); } }
private void HandleTransaction(CommittedTransactionRepresentation tx) { lock (this) { if (_state == PANIC) { return; } try { _applier.queue(tx); } catch (Exception e) { Panic(e); } } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public boolean visit(org.neo4j.kernel.impl.transaction.CommittedTransactionRepresentation tx) throws Exception public bool visit(CommittedTransactionRepresentation tx) { _actual.visit(tx); switch (nr++) { case 0: assertEquals(_outerInstance.outerInstance.lastCommittedTxStartEntry, tx.StartEntry); assertEquals(_outerInstance.outerInstance.lastCommittedTxCommitEntry, tx.CommitEntry); break; case 1: assertEquals(_outerInstance.outerInstance.expectedStartEntry, tx.StartEntry); assertEquals(_outerInstance.outerInstance.expectedCommitEntry, tx.CommitEntry); break; default: fail("Too many recovered transactions"); break; } return(false); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void verifyTransactionsInLog(org.neo4j.kernel.impl.transaction.log.files.LogFiles logFiles, long fromTxId, long endTxId) throws java.io.IOException private void VerifyTransactionsInLog(LogFiles logFiles, long fromTxId, long endTxId) { long expectedTxId = fromTxId; LogVersionedStoreChannel versionedStoreChannel = logFiles.OpenForVersion(0); using (ReadableLogChannel channel = new ReadAheadLogChannel(versionedStoreChannel, Org.Neo4j.Kernel.impl.transaction.log.LogVersionBridge_Fields.NoMoreChannels, 1024)) { using (PhysicalTransactionCursor <ReadableLogChannel> txCursor = new PhysicalTransactionCursor <ReadableLogChannel>(channel, new VersionAwareLogEntryReader <>())) { while (txCursor.Next()) { CommittedTransactionRepresentation tx = txCursor.Get(); long txId = tx.CommitEntry.TxId; assertThat(expectedTxId, lessThanOrEqualTo(endTxId)); assertEquals(expectedTxId, txId); expectedTxId++; } } } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldNotAppendCommittedTransactionsWhenTooFarAhead() public virtual void ShouldNotAppendCommittedTransactionsWhenTooFarAhead() { // GIVEN InMemoryClosableChannel channel = new InMemoryClosableChannel(); when(_logFile.Writer).thenReturn(channel); TransactionAppender appender = Life.add(CreateTransactionAppender()); // WHEN //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final byte[] additionalHeader = new byte[]{1, 2, 5}; sbyte[] additionalHeader = new sbyte[] { 1, 2, 5 }; const int masterId = 2; int authorId = 1; const long timeStarted = 12345; long latestCommittedTxWhenStarted = 4545; long timeCommitted = timeStarted + 10; PhysicalTransactionRepresentation transactionRepresentation = new PhysicalTransactionRepresentation(SingleCreateNodeCommand(0)); transactionRepresentation.SetHeader(additionalHeader, masterId, authorId, timeStarted, latestCommittedTxWhenStarted, timeCommitted, -1); when(_transactionIdStore.LastCommittedTransactionId).thenReturn(latestCommittedTxWhenStarted); LogEntryStart start = new LogEntryStart(0, 0, 0L, latestCommittedTxWhenStarted, null, LogPosition.UNSPECIFIED); LogEntryCommit commit = new LogEntryCommit(latestCommittedTxWhenStarted + 2, 0L); CommittedTransactionRepresentation transaction = new CommittedTransactionRepresentation(start, transactionRepresentation, commit); try { appender.Append(new TransactionToApply(transaction.TransactionRepresentation, transaction.CommitEntry.TxId), _logAppendEvent); fail("should have thrown"); } catch (Exception e) { assertThat(e.Message, containsString("to be applied, but appending it ended up generating an")); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public void init() throws Throwable public override void Init() { RecoveryStartInformation recoveryStartInformation = _recoveryService.RecoveryStartInformation; if (!recoveryStartInformation.RecoveryRequired) { // If there is nothing to recovery, then the schema is initialised immediately. _schemaLife.init(); return; } LogPosition recoveryPosition = recoveryStartInformation.RecoveryPosition; _monitor.recoveryRequired(recoveryPosition); _recoveryService.startRecovery(); LogPosition recoveryToPosition = recoveryPosition; CommittedTransactionRepresentation lastTransaction = null; CommittedTransactionRepresentation lastReversedTransaction = null; try { long lowestRecoveredTxId = Org.Neo4j.Kernel.impl.transaction.log.TransactionIdStore_Fields.BASE_TX_ID; using (TransactionCursor transactionsToRecover = _recoveryService.getTransactionsInReverseOrder(recoveryPosition), RecoveryApplier recoveryVisitor = _recoveryService.getRecoveryApplier(REVERSE_RECOVERY)) { while (transactionsToRecover.next()) { CommittedTransactionRepresentation transaction = transactionsToRecover.get(); if (lastReversedTransaction == null) { lastReversedTransaction = transaction; InitProgressReporter(recoveryStartInformation, lastReversedTransaction); } recoveryVisitor.visit(transaction); lowestRecoveredTxId = transaction.CommitEntry.TxId; ReportProgress(); } } _monitor.reverseStoreRecoveryCompleted(lowestRecoveredTxId); // We cannot initialise the schema (tokens, schema cache, indexing service, etc.) until we have returned the store to a consistent state. // We need to be able to read the store before we can even figure out what indexes, tokens, etc. we have. Hence we defer the initialisation // of the schema life until after we've done the reverse recovery. _schemaLife.init(); using (TransactionCursor transactionsToRecover = _recoveryService.getTransactions(recoveryPosition), RecoveryApplier recoveryVisitor = _recoveryService.getRecoveryApplier(RECOVERY)) { while (transactionsToRecover.next()) { lastTransaction = transactionsToRecover.get(); long txId = lastTransaction.CommitEntry.TxId; recoveryVisitor.visit(lastTransaction); _monitor.transactionRecovered(txId); _numberOfRecoveredTransactions++; recoveryToPosition = transactionsToRecover.Position(); ReportProgress(); } recoveryToPosition = transactionsToRecover.Position(); } } catch (Exception e) when(e is Exception || e is ClosedByInterruptException) { // We do not want to truncate logs based on these exceptions. Since users can influence them with config changes // the users are able to workaround this if truncations is really needed. throw e; } catch (Exception t) { if (_failOnCorruptedLogFiles) { ThrowUnableToCleanRecover(t); } if (lastTransaction != null) { LogEntryCommit commitEntry = lastTransaction.CommitEntry; _monitor.failToRecoverTransactionsAfterCommit(t, commitEntry, recoveryToPosition); } else { _monitor.failToRecoverTransactionsAfterPosition(t, recoveryPosition); recoveryToPosition = recoveryPosition; } } _progressReporter.completed(); _logsTruncator.truncate(recoveryToPosition); _recoveryService.transactionsRecovered(lastTransaction, recoveryToPosition); _monitor.recoveryCompleted(_numberOfRecoveredTransactions); }
private long GetNumberOfTransactionToRecover(RecoveryStartInformation recoveryStartInformation, CommittedTransactionRepresentation lastReversedTransaction) { return(lastReversedTransaction.CommitEntry.TxId - recoveryStartInformation.FirstTxIdAfterLastCheckPoint + 1); }
private void InitProgressReporter(RecoveryStartInformation recoveryStartInformation, CommittedTransactionRepresentation lastReversedTransaction) { long numberOfTransactionToRecover = GetNumberOfTransactionToRecover(recoveryStartInformation, lastReversedTransaction); // since we will process each transaction twice (doing reverse and direct detour) we need to // multiply number of transactions that we want to recover by 2 to be able to report correct progress _progressReporter.start(numberOfTransactionToRecover * 2); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public void serialize(org.neo4j.kernel.impl.transaction.CommittedTransactionRepresentation tx) throws java.io.IOException public virtual void Serialize(CommittedTransactionRepresentation tx) { WriteStartEntry(tx.StartEntry); Serialize(tx.TransactionRepresentation); WriteCommitEntry(tx.CommitEntry); }
public void transactionsRecovered(CommittedTransactionRepresentation lastRecoveredTransaction, LogPosition positionAfterLastRecoveredTransaction) { }
public override bool Next() { Transaction = new CommittedTransactionRepresentation(null, null, new LogEntryCommit(TxId++, 0)); return(true); }