Exemplo n.º 1
0
        protected internal override void Decode(ChannelHandlerContext ctx, ByteBuf msg, IList <object> @out)
        {
            int           ordinal    = msg.readInt();
            long          latestTxid = msg.readLong();
            CatchupResult status     = Enum.GetValues(typeof(CatchupResult))[ordinal];

            @out.Add(new TxStreamFinishedResponse(status, latestTxid));
        }
Exemplo n.º 2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void copy(org.neo4j.causalclustering.catchup.CatchupAddressProvider addressProvider, org.neo4j.causalclustering.identity.StoreId expectedStoreId, org.neo4j.io.layout.DatabaseLayout destinationLayout, boolean rotateTransactionsManually) throws StoreCopyFailedException
        public virtual void Copy(CatchupAddressProvider addressProvider, StoreId expectedStoreId, DatabaseLayout destinationLayout, bool rotateTransactionsManually)
        {
            try
            {
                long lastFlushedTxId;
                StreamToDiskProvider streamToDiskProvider = new StreamToDiskProvider(destinationLayout.DatabaseDirectory(), _fs, _monitors);
                lastFlushedTxId = _storeCopyClient.copyStoreFiles(addressProvider, expectedStoreId, streamToDiskProvider, () => new MaximumTotalTime(_config.get(CausalClusteringSettings.store_copy_max_retry_time_per_request).Seconds, TimeUnit.SECONDS), destinationLayout.DatabaseDirectory());

                _log.info("Store files need to be recovered starting from: %d", lastFlushedTxId);

                CatchupResult catchupResult = PullTransactions(addressProvider.Primary(), expectedStoreId, destinationLayout, lastFlushedTxId, true, true, rotateTransactionsManually);
                if (catchupResult != SUCCESS_END_OF_STREAM)
                {
                    throw new StoreCopyFailedException("Failed to pull transactions: " + catchupResult);
                }
            }
            catch (Exception e) when(e is CatchupAddressResolutionException || e is IOException)
            {
                throw new StoreCopyFailedException(e);
            }
        }
Exemplo n.º 3
0
 public TxPullRequestResult(CatchupResult catchupResult, long lastTxId)
 {
     this._catchupResult = catchupResult;
     this._lastTxId      = lastTxId;
 }
Exemplo n.º 4
0
//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();
        }
Exemplo n.º 5
0
 private void EndInteraction(ChannelHandlerContext ctx, CatchupResult status, long lastCommittedTransactionId)
 {
     ctx.write(ResponseMessageType.TX_STREAM_FINISHED);
     ctx.writeAndFlush(new TxStreamFinishedResponse(status, lastCommittedTransactionId));
     _protocol.expect(CatchupServerProtocol.State.MESSAGE_TYPE);
 }
Exemplo n.º 6
0
 internal TxStreamFinishedResponse(CatchupResult status, long latestTxId)
 {
     this._status     = status;
     this._latestTxId = latestTxId;
 }