Exemplo n.º 1
0
        /// <summary>
        /// 汇总状态信息
        /// </summary>
        /// <returns></returns>
        private SummaryStatus GetSummaryStatus()
        {
            //从缓存获取数据
            var status = CacheHelper.Get <SummaryStatus>("GetSummaryStatus");

            if (status == null)
            {
                //获取状态列表
                var list = GetTimeStatusList();

                //统计状态信息
                status = new SummaryStatus
                {
                    RunningSeconds = list.Count,
                    RequestCount   = list.Sum(p => p.RequestCount),
                    SuccessCount   = list.Sum(p => p.SuccessCount),
                    ErrorCount     = list.Sum(p => p.ErrorCount),
                    ElapsedTime    = list.Sum(p => p.ElapsedTime)
                };

                //缓存10秒
                CacheHelper.Insert("GetSummaryStatus", status, 10);
            }

            return(status);
        }
Exemplo n.º 2
0
        public static async Task Get_summary_returns_request_status(
            RequestStatus requestStatus,
            SummaryStatus expectedSummaryStatus,
            bool expectedIsProblem)
        {
            var activeDates = new[] { 28.June(2021) };

            var requests = new[] { new Request("user1", 28.June(2021), requestStatus) };

            var dateCalculator = CreateDateCalculator.WithActiveDates(activeDates);

            var controller = new SummaryController(
                dateCalculator,
                CreateRequestRepository.WithRequests("user1", activeDates, requests))
            {
                ControllerContext = CreateControllerContext.WithUsername("user1")
            };

            var result = await controller.GetSummaryAsync();

            var resultValue = GetResultValue <SummaryResponse>(result);

            var data = GetDailyData(resultValue.Summary, 28.June(2021));

            Assert.Equal(expectedSummaryStatus, data.Status);
            Assert.Equal(expectedIsProblem, data.IsProblem);
        }
 public void BucketDone(
     String bucketDescription,
     Int64 eventsDispatched,
     Int64 durationInMilliseconds,
     Int64 totalEventsToDispatchWithoutFiltering)
 {
     Interlocked.Decrement(ref _bucketActiveCount);
     SummaryStatus.Add(new BucketSummaryStatus()
     {
         BucketDescription      = bucketDescription,
         EventsDispatched       = eventsDispatched,
         DurationInMilliseconds = durationInMilliseconds,
         TotalEventsToDispatchWithoutFiltering = totalEventsToDispatchWithoutFiltering,
     });
 }