Beispiel #1
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);
            }
        }