예제 #1
0
        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);
        }
예제 #2
0
 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());
 }
예제 #3
0
        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);
        }
예제 #5
0
        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));
            }
        }
예제 #6
0
        dynamic GetRetryHistory()
        {
            using (var session = Store.OpenSession())
            {
                var retryHistory = session.Load <RetryHistory>(RetryHistory.MakeId()) ?? RetryHistory.CreateNew();

                return(Negotiate
                       .WithDeterministicEtag(retryHistory.GetHistoryOperationsUniqueIdentifier())
                       .WithModel(retryHistory));
            }
        }
예제 #7
0
        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);
        }
예제 #8
0
        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
                };
            }));
        }