//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: protected void channelRead0(io.netty.channel.ChannelHandlerContext ctx, final TxPullRequest msg) throws Exception //JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected: protected internal override void ChannelRead0(ChannelHandlerContext ctx, TxPullRequest msg) { _monitor.increment(); if (msg.PreviousTxId() <= 0) { _log.error("Illegal tx pull request"); EndInteraction(ctx, E_INVALID_REQUEST, -1); return; } StoreId localStoreId = _storeIdSupplier.get(); StoreId expectedStoreId = msg.ExpectedStoreId(); long firstTxId = msg.PreviousTxId() + 1; /* * This is the minimum transaction id we must send to consider our streaming operation successful. The kernel can * concurrently prune even future transactions while iterating and the cursor will silently fail on iteration, so * we need to add our own protection for this reason and also as a generally important sanity check for the fulfillment * of the consistent recovery contract which requires us to stream transactions at least as far as the time when the * file copy operation completed. */ long txIdPromise = _transactionIdStore.LastCommittedTransactionId; IOCursor <CommittedTransactionRepresentation> txCursor = GetCursor(txIdPromise, ctx, firstTxId, localStoreId, expectedStoreId); if (txCursor != null) { ChunkedTransactionStream txStream = new ChunkedTransactionStream(_log, localStoreId, firstTxId, txIdPromise, txCursor, _protocol); // chunked transaction stream ends the interaction internally and closes the cursor ctx.writeAndFlush(txStream).addListener(f => { if (_log.DebugEnabled || !f.Success) { string message = format("Streamed transactions [%d--%d] to %s", firstTxId, txStream.LastTxId(), ctx.channel().remoteAddress()); if (f.Success) { _log.debug(message); } else { _log.warn(message, f.cause()); } } }); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("SameParameterValue") private void testTransactionStream(int firstTxId, int lastTxId, int txIdPromise, org.neo4j.causalclustering.catchup.CatchupResult expectedResult) throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: private void TestTransactionStream(int firstTxId, int lastTxId, int txIdPromise, CatchupResult expectedResult) { ChunkedTransactionStream txStream = new ChunkedTransactionStream(NullLog.Instance, _storeId, firstTxId, txIdPromise, _cursor, _protocol); IList <bool> more = new List <bool>(); IList <CommittedTransactionRepresentation> txs = new List <CommittedTransactionRepresentation>(); for (int txId = firstTxId; txId <= lastTxId; txId++) { more.Add(true); txs.Add(Tx(txId)); } txs.Add(null); more.Add(false); when(_cursor.next()).thenAnswer(returnsElementsOf(more)); when(_cursor.get()).thenAnswer(returnsElementsOf(txs)); // when/then assertFalse(txStream.EndOfInput); for (int txId = firstTxId; txId <= lastTxId; txId++) { assertEquals(ResponseMessageType.TX, txStream.ReadChunk(_allocator)); assertEquals(new TxPullResponse(_storeId, txs[txId - firstTxId]), txStream.ReadChunk(_allocator)); } assertEquals(ResponseMessageType.TX_STREAM_FINISHED, txStream.ReadChunk(_allocator)); assertEquals(new TxStreamFinishedResponse(expectedResult, lastTxId), txStream.ReadChunk(_allocator)); assertTrue(txStream.EndOfInput); // when txStream.Close(); // then verify(_cursor).close(); }