Exemple #1
0
        public override bool Equals(object o)
        {
            if (this == o)
            {
                return(true);
            }
            if (o == null || this.GetType() != o.GetType())
            {
                return(false);
            }
            TxPullRequest that = ( TxPullRequest )o;

            return(_previousTxId == that._previousTxId && Objects.Equals(_expectedStoreId, that._expectedStoreId));
        }
Exemple #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldEncodeAndDecodePullRequestMessage()
        public virtual void ShouldEncodeAndDecodePullRequestMessage()
        {
            // given
            EmbeddedChannel channel     = new EmbeddedChannel(new TxPullRequestEncoder(), new TxPullRequestDecoder());
            const long      arbitraryId = 23;
            TxPullRequest   sent        = new TxPullRequest(arbitraryId, new StoreId(1, 2, 3, 4));

            // when
            channel.writeOutbound(sent);
            object message = channel.readOutbound();

            channel.writeInbound(message);

            // then
            TxPullRequest received = channel.readInbound();

            assertNotSame(sent, received);
            assertEquals(sent, received);
        }
Exemple #3
0
        private bool PullAndApplyBatchOfTransactions(MemberId upstream, StoreId localStoreId, int batchCount)
        {
            long lastQueuedTxId = _applier.lastQueuedTxId();

            _pullRequestMonitor.txPullRequest(lastQueuedTxId);
            TxPullRequest txPullRequest = new TxPullRequest(lastQueuedTxId, localStoreId);

            _log.debug("Pull transactions from %s where tx id > %d [batch #%d]", upstream, lastQueuedTxId, batchCount);

            TxStreamFinishedResponse response;

            try
            {
                AdvertisedSocketAddress fromAddress = _topologyService.findCatchupAddress(upstream).orElseThrow(() => new TopologyLookupException(upstream));
                response = _catchUpClient.makeBlockingRequest(fromAddress, txPullRequest, new CatchUpResponseAdaptorAnonymousInnerClass(this, response));
            }
            catch (Exception e) when(e is CatchUpClientException || e is TopologyLookupException)
            {
                _log.warn("Exception occurred while pulling transactions. Will retry shortly.", e);
                StreamComplete();
                return(false);
            }

            _latestTxIdOfUpStream = response.LatestTxId();

            switch (response.Status())
            {
            case SUCCESS_END_OF_STREAM:
                _log.debug("Successfully pulled transactions from tx id %d", lastQueuedTxId);
                _upToDateFuture.complete(true);
                return(false);

            case E_TRANSACTION_PRUNED:
                _log.info("Tx pull unable to get transactions starting from %d since transactions have been pruned. Attempting a store copy.", lastQueuedTxId);
                _state = STORE_COPYING;
                return(false);

            default:
                _log.info("Tx pull request unable to get transactions > %d " + lastQueuedTxId);
                return(false);
            }
        }