Esempio n. 1
0
 public void SyncAll()
 {
     Task.Factory
     .StartNew(() => _splitFetcher.FetchSplits().Wait())
     .ContinueWith((x) => _segmentFetcher.FetchAll().Wait())
     .ContinueWith((x) => _log.Debug("Spltis and Segments synchronized..."));
 }
Esempio n. 2
0
        public async void SyncAll()
        {
            await _splitFetcher.FetchSplits();

            await _segmentFetcher.FetchAll();

            _log.Debug("Spltis and Segments synchronized...");
        }
Esempio n. 3
0
        private async Task <SyncResult> AttempSplitsSync(long targetChangeNumber, FetchOptions fetchOptions, int maxRetries, int?retryDelayMs, bool withBackoff)
        {
            try
            {
                var remainingAttempts = maxRetries;

                if (withBackoff)
                {
                    _backOffSplits.Reset();
                }

                while (true)
                {
                    remainingAttempts--;
                    var result = await _splitFetcher.FetchSplits(fetchOptions);

                    if (targetChangeNumber <= _splitCache.GetChangeNumber())
                    {
                        return(new SyncResult(true, remainingAttempts, result.SegmentNames));
                    }
                    else if (remainingAttempts <= 0)
                    {
                        return(new SyncResult(false, remainingAttempts, result.SegmentNames));
                    }

                    var delay = withBackoff ? _backOffSplits.GetInterval(inMiliseconds: true) : retryDelayMs.Value;
                    _wrapperAdapter.TaskDelay((int)delay).Wait();
                }
            }
            catch (Exception ex)
            {
                _log.Debug("Exception while AttempSplitsSync.", ex);
            }

            return(new SyncResult(false, 0));
        }