public void ReplicateRouteContents(IRoute route, IEnumerable <IContentIdentifier> contentIdentifiers, int connectionCountLimit) { if (_completeMomentProvider == null) { Task.WhenAll(contentIdentifiers.Select(x => ReplicateContentAsync(route, x))).Wait(); } else { var aTaskFaulted = false; var headedTaskQueue = new HeadedTaskQueue <DateTimeOffset>( (connectionCountLimit <= 0 ? DefaultConnectionCountLimit : connectionCountLimit), (task) => { if (task.IsFaulted || task.IsCanceled) { aTaskFaulted = true; } if (!aTaskFaulted) { _completeMomentProvider.SetCompleteMoment(route.Source.ID, route.Destination.ID, task.Result); } }); foreach (var contentIdentifier in contentIdentifiers) { headedTaskQueue.Add(ReplicateContentAsync(route, contentIdentifier)); } headedTaskQueue.Wait(); } }
public void RunRoute(IRouteConfig routeConfig) { try { var route = _routeProvider.GetRoute(routeConfig); var completeMoment = (routeConfig.ForceAllContents ? DateTimeOffset.MinValue : _completeMomentProvider.GetCompleteMoment(route.Source.ID, route.Destination.ID)); DateTimeOffset sourceLastModifiedMoment; var contentIdentifiersList = GetReplicateContentIdentifiers(routeConfig, route, completeMoment, out sourceLastModifiedMoment).ToList(); if (contentIdentifiersList.Any()) { _routeReplicator.ReplicateRouteContents(route, contentIdentifiersList, routeConfig.ConnectionCountLimit); } else { var newCompleteMoment = new[] { completeMoment, sourceLastModifiedMoment }.Max(); _completeMomentProvider.SetCompleteMoment(route.Source.ID, route.Destination.ID, newCompleteMoment); } } finally { _completeMomentProvider.Finish(); } }
public void SetCompleteMoment(string sourceID, string destinationID, DateTimeOffset moment) { _completeMomentProvider.SetCompleteMoment(sourceID, destinationID, moment); }