private async Task <dynamic> AcknowledgeOperation(dynamic parameters) { var groupId = parameters.groupId; if (ArchiveOperationManager.IsArchiveInProgressFor(groupId)) { ArchiveOperationManager.DismissArchiveOperation(groupId, ArchiveType.FailureGroup); return(HttpStatusCode.OK); } using (var session = Store.OpenAsyncSession()) { var retryHistory = await session.LoadAsync <RetryHistory>(RetryHistory.MakeId()).ConfigureAwait(false); if (retryHistory != null) { if (retryHistory.Acknowledge(groupId, RetryType.FailureGroup)) { await session.StoreAsync(retryHistory).ConfigureAwait(false); await session.SaveChangesAsync().ConfigureAwait(false); return(HttpStatusCode.OK); } } } return(HttpStatusCode.NotFound); }
static HistoricRetryOperation GetLatestHistoricOperation(RetryHistory history, string requestId, RetryType retryType) { return(history.HistoricOperations .Where(v => v.RequestId == requestId && v.RetryType == retryType) .OrderByDescending(v => v.CompletionTime) .FirstOrDefault()); }
public async Task <GroupOperation[]> GetGroups(IAsyncDocumentSession session, string classifier, string classifierFilter) { var dbGroups = await GetDBGroups(session, classifier, classifierFilter).ConfigureAwait(false); var retryHistory = await session.LoadAsync <RetryHistory>(RetryHistory.MakeId()).ConfigureAwait(false) ?? RetryHistory.CreateNew(); var unacknowledgedRetries = retryHistory.GetUnacknowledgedByClassifier(classifier); var openRetryAcknowledgements = MapAcksToOpenGroups(dbGroups, unacknowledgedRetries); var closedRetryAcknowledgements = unacknowledgedRetries.Except(openRetryAcknowledgements).ToArray(); var closedGroups = MapClosedGroups(classifier, closedRetryAcknowledgements); closedGroups = closedGroups.Union(MapClosedGroups(classifier, archivingManager.GetArchivalOperations().Where(archiveOp => archiveOp.NeedsAcknowledgement()))); var openGroups = MapOpenGroups(dbGroups, retryHistory, openRetryAcknowledgements).ToList(); openGroups = MapOpenGroups(openGroups, archivingManager.GetArchivalOperations()).ToList(); openGroups = openGroups.Where(group => !closedGroups.Any(closedGroup => closedGroup.Id == group.Id)).ToList(); MakeSureForwardingBatchIsIncludedAsOpen(classifier, await GetCurrentForwardingBatch(session).ConfigureAwait(false), openGroups); var groups = openGroups.Union(closedGroups); return(groups.OrderByDescending(g => g.Last).ToArray()); }
private dynamic AcknowledgeOperation(dynamic parameters) { var groupId = parameters.groupId; if (ArchiveOperationManager.IsArchiveInProgressFor(groupId)) { ArchiveOperationManager.DismissArchiveOperation(groupId, ArchiveType.FailureGroup); return(HttpStatusCode.OK); } using (var session = Store.OpenSession()) { var retryHistory = session.Load <RetryHistory>(RetryHistory.MakeId()); if (retryHistory != null) { if (retryHistory.Acknowledge(groupId, RetryType.FailureGroup)) { session.Store(retryHistory); session.SaveChanges(); return(HttpStatusCode.OK); } } } return(HttpStatusCode.NotFound); }
async Task <dynamic> GetRetryHistory() { using (var session = Store.OpenAsyncSession()) { var retryHistory = await session.LoadAsync <RetryHistory>(RetryHistory.MakeId()).ConfigureAwait(false) ?? RetryHistory.CreateNew(); return(Negotiate .WithDeterministicEtag(retryHistory.GetHistoryOperationsUniqueIdentifier()) .WithModel(retryHistory)); } }
dynamic GetRetryHistory() { using (var session = Store.OpenSession()) { var retryHistory = session.Load <RetryHistory>(RetryHistory.MakeId()) ?? RetryHistory.CreateNew(); return(Negotiate .WithDeterministicEtag(retryHistory.GetHistoryOperationsUniqueIdentifier()) .WithModel(retryHistory)); } }
private dynamic AcknowledgeOperation(dynamic parameters) { var groupId = parameters.groupId; using (var session = Store.OpenSession()) { var retryHistory = session.Load <RetryHistory>(RetryHistory.MakeId()); if (retryHistory != null) { retryHistory.Acknowledge(groupId, RetryType.FailureGroup); } session.Store(retryHistory); session.SaveChanges(); } return(HttpStatusCode.OK); }
IEnumerable <GroupOperation> MapOpenGroups(IEnumerable <FailureGroupView> activeGroups, RetryHistory history, UnacknowledgedRetryOperation[] groupUnacknowledgements) { return(activeGroups.Select(failureGroup => { var summary = retryingManager.GetStatusForRetryOperation(failureGroup.Id, RetryType.FailureGroup); var historic = GetLatestHistoricOperation(history, failureGroup.Id, RetryType.FailureGroup); var unacknowledged = groupUnacknowledgements.FirstOrDefault(unack => unack.RequestId == failureGroup.Id && unack.RetryType == RetryType.FailureGroup); return new GroupOperation { Id = failureGroup.Id, Title = failureGroup.Title, Type = failureGroup.Type, Count = failureGroup.Count, First = failureGroup.First, Last = failureGroup.Last, OperationStatus = summary?.RetryState.ToString() ?? "None", OperationFailed = summary?.Failed, OperationProgress = summary?.GetProgress().Percentage ?? 0.0, OperationRemainingCount = summary?.GetProgress().MessagesRemaining, OperationStartTime = summary?.Started, OperationCompletionTime = summary?.CompletionTime ?? (unacknowledged?.CompletionTime ?? historic?.CompletionTime), NeedUserAcknowledgement = unacknowledged != null }; })); }