44 m_TotalMinutesCollected(1),
53 ssize_t current_values_start_sec,
54 ssize_t current_values_end_sec)
const
56 if (most_recent_time >= 0) {
58 if (most_recent_time > current_values_end_sec) {
59 return EPSGS_SkipCheckResult::ePSGS_SkipBegin;
63 if (most_ancient_time >= 0) {
65 if (most_ancient_time < current_values_start_sec) {
66 return EPSGS_SkipCheckResult::ePSGS_SkipEnd;
70 return EPSGS_SkipCheckResult::ePSGS_DontSkip;
98 new_current_index = 0;
107 if (new_current_index == 0) {
131 int most_ancient_time,
132 int most_recent_time,
133 bool loop,
size_t current_index)
const
139 most_ancient_time, most_recent_time,
140 loop, current_index));
147 int most_ancient_time,
148 int most_recent_time,
150 size_t current_index)
const
154 if (current_index == 0 && loop ==
false) {
163 if (current_index == 0) {
167 raw_index = current_index - 1;
170 size_t current_accumulated_mins = 0;
171 double current_accumulated_vals = 0;
172 size_t output_data_index = 0;
173 double total_processed_vals = 0.0;
174 double max_observed_val = 0.0;
175 size_t observed_minutes = 0;
176 double total_observed_vals = 0.0;
181 size_t range_index = 0;
182 size_t current_mins_to_accumulate = time_series[range_index].first;
183 size_t current_last_seq_index = time_series[range_index].second;
185 ssize_t actual_range_start_sec = -1;
186 ssize_t actual_range_end_sec = -1;
190 total_processed_vals +=
m_Values[raw_index];
193 ssize_t current_values_start_sec = past_minute * 60;
194 ssize_t current_values_end_sec = current_values_start_sec + 59;
196 auto skip_check =
CheckToSkip(most_ancient_time, most_recent_time,
197 current_values_start_sec,
198 current_values_end_sec);
199 if (skip_check != EPSGS_SkipCheckResult::ePSGS_DontSkip) {
210 if (actual_range_start_sec < 0) {
211 actual_range_start_sec = current_values_start_sec;
213 actual_range_end_sec = current_values_end_sec;
217 if (
val > max_observed_val) {
218 max_observed_val =
val;
221 total_observed_vals +=
val;
223 ++current_accumulated_mins;
224 current_accumulated_vals +=
val;
226 if (current_accumulated_mins >= current_mins_to_accumulate) {
227 output_series.
AppendDouble(
double(current_accumulated_vals) /
228 double(current_accumulated_mins));
229 current_accumulated_mins = 0;
230 current_accumulated_vals = 0.0;
234 if (output_data_index > current_last_seq_index) {
236 current_mins_to_accumulate = time_series[range_index].first;
237 current_last_seq_index = time_series[range_index].second;
247 while (raw_index > current_index + 1) {
248 total_processed_vals +=
m_Values[raw_index];
251 ssize_t current_values_start_sec = past_minute * 60;
252 ssize_t current_values_end_sec = current_values_start_sec + 59;
253 auto skip_check =
CheckToSkip(most_ancient_time, most_recent_time,
254 current_values_start_sec,
255 current_values_end_sec);
256 if (skip_check != EPSGS_SkipCheckResult::ePSGS_DontSkip) {
265 if (actual_range_start_sec < 0) {
266 actual_range_start_sec = current_values_start_sec;
268 actual_range_end_sec = current_values_end_sec;
271 if (
val > max_observed_val) {
272 max_observed_val =
val;
275 total_observed_vals +=
val;
279 ++current_accumulated_mins;
280 current_accumulated_vals +=
val;
282 if (current_accumulated_mins >= current_mins_to_accumulate) {
283 output_series.
AppendDouble(
double(current_accumulated_vals) /
284 double(current_accumulated_mins));
285 current_accumulated_mins = 0;
286 current_accumulated_vals = 0;
290 if (output_data_index > current_last_seq_index) {
292 current_mins_to_accumulate = time_series[range_index].first;
293 current_last_seq_index = time_series[range_index].second;
298 if (actual_range_start_sec == -1 && actual_range_end_sec == -1) {
306 if (current_accumulated_mins > 0) {
307 output_series.
AppendDouble(
double(current_accumulated_vals) /
308 double(current_accumulated_mins));
311 if (loop && most_ancient_time == -1) {
317 ret.
SetDouble(
"RestAvgPerSec", rest_vals / (rest_mins * 60.0));
325 ret.
SetDouble(
"MaxObservedPerSec", max_observed_val / 60.0);
326 ret.
SetDouble(
"AvgObservedPerSec", total_observed_vals / (observed_minutes * 60.0));
328 ret.
SetByKey(
"time_series", output_series);
349 new_current_index = 0;
359 if (new_current_index == 0) {
386 int most_ancient_time,
387 int most_recent_time,
388 bool loop,
size_t current_index)
const
394 most_ancient_time, most_recent_time,
395 loop, current_index));
402 int most_ancient_time,
403 int most_recent_time,
405 size_t current_index)
const
409 if (current_index == 0 && loop ==
false) {
418 if (current_index == 0) {
422 raw_index = current_index - 1;
425 size_t current_accumulated_mins = 0;
427 uint64_t current_accumulated_sums = 0;
428 size_t current_accumulated_count = 0;
430 double total_max_avg = 0.0;
431 double total_min_avg = 0.0;
432 double observed_max_avg = 0.0;
433 double observed_min_avg = 0.0;
435 size_t output_data_index = 0;
440 size_t range_index = 0;
441 size_t current_mins_to_accumulate = time_series[range_index].first;
442 size_t current_last_seq_index = time_series[range_index].second;
444 ssize_t actual_range_start_sec = -1;
445 ssize_t actual_range_end_sec = -1;
449 double current_avg = 0.0;
453 if (current_avg > total_max_avg) {
454 total_max_avg = current_avg;
456 if (current_avg > 0.0) {
457 if (current_avg < total_min_avg || total_min_avg == 0.0) {
458 total_min_avg = current_avg;
463 ssize_t current_values_start_sec = past_minute * 60;
464 ssize_t current_values_end_sec = current_values_start_sec + 59;
466 auto skip_check =
CheckToSkip(most_ancient_time, most_recent_time,
467 current_values_start_sec,
468 current_values_end_sec);
469 if (skip_check != EPSGS_SkipCheckResult::ePSGS_DontSkip) {
480 if (actual_range_start_sec < 0) {
481 actual_range_start_sec = current_values_start_sec;
483 actual_range_end_sec = current_values_end_sec;
489 if (current_avg > observed_max_avg) {
490 observed_max_avg = current_avg;
492 if (current_avg > 0.0) {
493 if (current_avg < observed_min_avg || observed_min_avg == 0.0) {
494 observed_min_avg = current_avg;
498 ++current_accumulated_mins;
499 current_accumulated_sums += val_sum;
500 current_accumulated_count += val_cnt;
502 if (current_accumulated_mins >= current_mins_to_accumulate) {
503 if (current_accumulated_count > 0) {
505 lround(
double(current_accumulated_sums) /
506 double(current_accumulated_count)));
510 current_accumulated_sums = 0;
511 current_accumulated_count = 0;
512 current_accumulated_mins = 0;
516 if (output_data_index > current_last_seq_index) {
518 current_mins_to_accumulate = time_series[range_index].first;
519 current_last_seq_index = time_series[range_index].second;
529 while (raw_index > current_index + 1) {
530 double current_avg = 0.0;
534 if (current_avg > total_max_avg) {
535 total_max_avg = current_avg;
537 if (current_avg > 0.0) {
538 if (current_avg < total_min_avg || total_min_avg == 0.0) {
539 total_min_avg = current_avg;
544 ssize_t current_values_start_sec = past_minute * 60;
545 ssize_t current_values_end_sec = current_values_start_sec + 59;
546 auto skip_check =
CheckToSkip(most_ancient_time, most_recent_time,
547 current_values_start_sec,
548 current_values_end_sec);
549 if (skip_check != EPSGS_SkipCheckResult::ePSGS_DontSkip) {
558 if (actual_range_start_sec < 0) {
559 actual_range_start_sec = current_values_start_sec;
561 actual_range_end_sec = current_values_end_sec;
566 if (current_avg > observed_max_avg) {
567 observed_max_avg = current_avg;
569 if (current_avg > 0.0) {
570 if (current_avg < observed_min_avg || observed_min_avg == 0.0) {
571 observed_min_avg = current_avg;
577 ++current_accumulated_mins;
578 current_accumulated_sums += val_sum;
579 current_accumulated_count += val_cnt;
581 if (current_accumulated_mins >= current_mins_to_accumulate) {
582 if (current_accumulated_count > 0) {
584 lround(
double(current_accumulated_sums) /
585 double(current_accumulated_count)));
589 current_accumulated_sums = 0;
590 current_accumulated_count = 0;
591 current_accumulated_mins = 0;
595 if (output_data_index > current_last_seq_index) {
597 current_mins_to_accumulate = time_series[range_index].first;
598 current_last_seq_index = time_series[range_index].second;
603 if (actual_range_start_sec == -1 && actual_range_end_sec == -1) {
611 if (current_accumulated_mins > 0) {
612 if (current_accumulated_count > 0) {
614 lround(
double(current_accumulated_sums) /
615 double(current_accumulated_count)));
621 ret.
SetString(
"Description",
"The time_series array contains "
622 "average mks required to complete an operation");
623 ret.
SetInteger(
"AllTimeMaxAvg", lround(total_max_avg));
624 ret.
SetInteger(
"AllTimeMinAvg", lround(total_min_avg));
625 ret.
SetInteger(
"ObservedMaxAvg", lround(observed_max_avg));
626 ret.
SetInteger(
"ObservedMinAvg", lround(observed_min_avg));
630 ret.
SetByKey(
"time_series", output_series);
651 new_current_index = 0;
660 if (new_current_index == 0) {
680 int most_ancient_time,
681 int most_recent_time,
682 bool loop,
size_t current_index)
const
689 most_ancient_time, most_recent_time,
690 loop, current_index));
698 const vector<pair<int, int>> & time_series,
699 int most_ancient_time,
700 int most_recent_time,
702 size_t current_index)
const
706 if (current_index == 0 && loop ==
false) {
715 if (current_index == 0) {
719 raw_index = current_index - 1;
722 size_t current_accumulated_mins = 0;
723 uint64_t current_accumulated_vals = 0;
724 size_t output_data_index = 0;
727 size_t observed_minutes = 0;
733 size_t range_index = 0;
734 size_t current_mins_to_accumulate = time_series[range_index].first;
735 size_t current_last_seq_index = time_series[range_index].second;
737 ssize_t actual_range_start_sec = -1;
738 ssize_t actual_range_end_sec = -1;
742 total_processed_vals += values[raw_index];
745 ssize_t current_values_start_sec = past_minute * 60;
746 ssize_t current_values_end_sec = current_values_start_sec + 59;
748 auto skip_check =
CheckToSkip(most_ancient_time, most_recent_time,
749 current_values_start_sec,
750 current_values_end_sec);
751 if (skip_check != EPSGS_SkipCheckResult::ePSGS_DontSkip) {
762 if (actual_range_start_sec < 0) {
763 actual_range_start_sec = current_values_start_sec;
765 actual_range_end_sec = current_values_end_sec;
769 if (vals > max_observed_val) {
770 max_observed_val = vals;
773 total_observed_vals += vals;
775 ++current_accumulated_mins;
776 current_accumulated_vals += vals;
778 if (current_accumulated_mins >= current_mins_to_accumulate) {
780 current_accumulated_mins = 0;
781 current_accumulated_vals = 0;
785 if (output_data_index > current_last_seq_index) {
787 current_mins_to_accumulate = time_series[range_index].first;
788 current_last_seq_index = time_series[range_index].second;
798 while (raw_index > current_index + 1) {
799 total_processed_vals += values[raw_index];
802 ssize_t current_values_start_sec = past_minute * 60;
803 ssize_t current_values_end_sec = current_values_start_sec + 59;
804 auto skip_check =
CheckToSkip(most_ancient_time, most_recent_time,
805 current_values_start_sec,
806 current_values_end_sec);
807 if (skip_check != EPSGS_SkipCheckResult::ePSGS_DontSkip) {
816 if (actual_range_start_sec < 0) {
817 actual_range_start_sec = current_values_start_sec;
819 actual_range_end_sec = current_values_end_sec;
822 if (vals > max_observed_val) {
823 max_observed_val = vals;
826 total_observed_vals += vals;
830 ++current_accumulated_mins;
831 current_accumulated_vals += vals;
833 if (current_accumulated_mins >= current_mins_to_accumulate) {
835 current_accumulated_mins = 0;
836 current_accumulated_vals = 0;
840 if (output_data_index > current_last_seq_index) {
842 current_mins_to_accumulate = time_series[range_index].first;
843 current_last_seq_index = time_series[range_index].second;
848 if (actual_range_start_sec == -1 && actual_range_end_sec == -1) {
856 if (current_accumulated_mins > 0) {
860 if (loop && most_ancient_time == -1) {
864 uint64_t rest_vals = grand_total - total_processed_vals - values[current_index];
867 ret.
SetDouble(
"RestAvgPerSec", rest_vals / (rest_mins * 60.0));
872 ret.
SetDouble(
"AvgAllTimePerSec", grand_total /
875 ret.
SetDouble(
"MaxObservedPerSec", max_observed_val / 60.0);
876 ret.
SetDouble(
"AvgObservedPerSec", total_observed_vals / (observed_minutes * 60.0));
878 ret.
SetInteger(
"ValObserved", total_observed_vals);
879 ret.
SetInteger(
"ValAllTime", grand_total - values[current_index]);
881 ret.
SetByKey(
"time_series", output_series);
908 new_current_index = 0;
917 if (new_current_index == 0) {
937 int most_ancient_time,
int most_recent_time,
938 bool loop,
size_t current_index)
const
944 time_series, most_ancient_time,
945 most_recent_time, loop, current_index));
954 const vector<pair<int, int>> & time_series,
955 int most_ancient_time,
956 int most_recent_time,
958 size_t current_index)
const
962 if (current_index == 0 && loop ==
false) {
976 if (current_index == 0) {
980 raw_index = current_index - 1;
983 size_t current_accumulated_mins = 0;
984 uint64_t current_accumulated_reqs = 0;
985 size_t output_data_index = 0;
991 size_t range_index = 0;
992 size_t current_mins_to_accumulate = time_series[range_index].first;
993 size_t current_last_seq_index = time_series[range_index].second;
996 ssize_t actual_range_start_sec = -1;
997 ssize_t actual_range_end_sec = -1;
1001 total_processed_vals += values[raw_index];
1004 ssize_t current_values_start_sec = past_minute * 60;
1005 ssize_t current_values_end_sec = current_values_start_sec + 59;
1007 auto skip_check =
CheckToSkip(most_ancient_time, most_recent_time,
1008 current_values_start_sec,
1009 current_values_end_sec);
1010 if (skip_check != EPSGS_SkipCheckResult::ePSGS_DontSkip) {
1021 if (actual_range_start_sec < 0) {
1022 actual_range_start_sec = current_values_start_sec;
1024 actual_range_end_sec = current_values_end_sec;
1028 if (reqs > max_observed_val) {
1029 max_observed_val = reqs;
1032 total_observed_vals += reqs;
1034 ++current_accumulated_mins;
1035 current_accumulated_reqs += reqs;
1037 if (current_accumulated_mins >= current_mins_to_accumulate) {
1038 output_series.
AppendDouble(
double(current_accumulated_reqs) /
1039 (
double(current_accumulated_mins) * 60.0));
1040 current_accumulated_mins = 0;
1041 current_accumulated_reqs = 0;
1044 ++output_data_index;
1045 if (output_data_index > current_last_seq_index) {
1047 current_mins_to_accumulate = time_series[range_index].first;
1048 current_last_seq_index = time_series[range_index].second;
1058 while (raw_index > current_index + 1) {
1059 total_processed_vals += values[raw_index];
1062 ssize_t current_values_start_sec = past_minute * 60;
1063 ssize_t current_values_end_sec = current_values_start_sec + 59;
1064 auto skip_check =
CheckToSkip(most_ancient_time, most_recent_time,
1065 current_values_start_sec,
1066 current_values_end_sec);
1067 if (skip_check != EPSGS_SkipCheckResult::ePSGS_DontSkip) {
1076 if (actual_range_start_sec < 0) {
1077 actual_range_start_sec = current_values_start_sec;
1079 actual_range_end_sec = current_values_end_sec;
1084 if (reqs > max_observed_val) {
1085 max_observed_val = reqs;
1088 total_observed_vals += reqs;
1090 ++current_accumulated_mins;
1091 current_accumulated_reqs += reqs;
1093 if (current_accumulated_mins >= current_mins_to_accumulate) {
1094 output_series.
AppendDouble(
double(current_accumulated_reqs) /
1095 (
double(current_accumulated_mins) * 60.0));
1096 current_accumulated_mins = 0;
1097 current_accumulated_reqs = 0;
1100 ++output_data_index;
1101 if (output_data_index > current_last_seq_index) {
1103 current_mins_to_accumulate = time_series[range_index].first;
1104 current_last_seq_index = time_series[range_index].second;
1109 if (actual_range_start_sec == -1 && actual_range_end_sec == -1) {
1117 if (current_accumulated_mins > 0) {
1118 output_series.
AppendDouble(
double(current_accumulated_reqs) /
1119 (
double(current_accumulated_mins) * 60.0));
1122 if (loop && most_ancient_time == -1) {
1125 uint64_t rest_reqs = grand_total - total_processed_vals - values[current_index];
1127 if (rest_mins > 0) {
1128 ret.
SetDouble(
"RestAvgPerSec", rest_reqs / (rest_mins * 60.0));
1132 ret.
SetDouble(
"MaxAllTimePerSec", grand_max / 60.0);
1133 ret.
SetDouble(
"AvgAllTimePerSec", grand_total /
1136 ret.
SetDouble(
"MaxObservedPerSec", max_observed_val / 60.0);
1137 ret.
SetDouble(
"AvgObservedPerSec", total_observed_vals / (observed_minutes * 60.0));
1139 ret.
SetInteger(
"ValObserved", total_observed_vals);
1140 ret.
SetInteger(
"ValAllTime", grand_total - values[current_index]);
1142 ret.
SetByKey(
"time_series", output_series);
1215 new_current_index = 0;
1217 ++new_current_index;
1227 if (new_current_index == 0) {
1256 int most_ancient_time,
int most_recent_time,
1257 bool loop,
size_t current_index)
const
1264 most_ancient_time, most_recent_time,
1265 loop, current_index));
1269 most_ancient_time, most_recent_time,
1270 loop, current_index));
1274 most_ancient_time, most_recent_time,
1275 loop, current_index));
1279 most_ancient_time, most_recent_time,
1280 loop, current_index));
static CJsonNode NewArrayNode()
Create a new JSON array node.
void SetDouble(const string &key, double value)
Set a JSON object element to the specified floating point value.
void SetString(const string &key, const string &value)
Set a JSON object element to the specified string value.
void AppendInteger(Int8 value)
For an array node, add a integer node at the end of the array.
void SetInteger(const string &key, Int8 value)
Set a JSON object element to the specified integer value.
void SetByKey(const string &key, CJsonNode::TInstance value)
For a JSON object node, insert a new element or update an existing element.
void AppendDouble(double value)
For an array node, add a floating point node at the end of the array.
static CJsonNode NewObjectNode()
Create a new JSON object node.
size_t m_AccumulatedCount
CJsonNode x_SerializeOneSeries(const vector< pair< int, int >> &time_series, int most_ancient_time, int most_recent_time, bool loop, size_t current_index) const
CJsonNode Serialize(const vector< pair< int, int >> &time_series, int most_ancient_time, int most_recent_time, bool loop, size_t current_index) const
uint64_t m_Values[kSeriesIntervals]
CJsonNode Serialize(const vector< pair< int, int >> &time_series, int most_ancient_time, int most_recent_time, bool loop, size_t current_index) const
CJsonNode x_SerializeOneSeries(const uint64_t *values, uint64_t grand_total, const vector< pair< int, int >> &time_series, int most_ancient_time, int most_recent_time, bool loop, size_t current_index) const
uint64_t m_Values[kSeriesIntervals]
CJsonNode x_SerializeOneSeries(const uint64_t *values, uint64_t grand_total, uint64_t grand_max, const vector< pair< int, int >> &time_series, int most_ancient_time, int most_recent_time, bool loop, size_t current_index) const
uint64_t m_Requests[kSeriesIntervals]
CJsonNode Serialize(const vector< pair< int, int >> &time_series, int most_ancient_time, int most_recent_time, bool loop, size_t current_index) const
CProcessorRequestTimeSeries()
CJsonNode Serialize(const vector< pair< int, int >> &time_series, int most_ancient_time, int most_recent_time, bool loop, size_t current_index) const
static EPSGSCounter RequestStatusToCounter(CRequestStatus::ECode status)
uint64_t m_Warnings[kSeriesIntervals]
uint64_t m_NotFound[kSeriesIntervals]
uint64_t m_Errors[kSeriesIntervals]
atomic_uint_fast64_t m_CurrentIndex
atomic_uint_fast64_t m_TotalMinutesCollected
EPSGS_SkipCheckResult CheckToSkip(int most_ancient_time, int most_recent_time, ssize_t current_values_start_sec, ssize_t current_values_end_sec) const
Include a standard set of the NCBI C++ Toolkit most basic headers.
@ e500_InternalServerError
static string kActualTimeRangeStart("TimeRangeStart")
static string kActualTimeRangeEnd("TimeRangeEnd")
static constexpr size_t kSeriesIntervals