MCPcopy Create free account
hub / github.com/apache/trafficserver / registerSuccFail

Function registerSuccFail

plugins/esi/test/sampleProb.cc:78–117  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

76using FailureData = std::map<std::string, class FailureInfo *>;
77
78void
79registerSuccFail(string URL, FailureData &data, bool isSuccess)
80{
81 struct timeval currTime, result, startTime;
82 int marker;
83 FailureData::iterator it;
84 it = data.find(URL);
85 vector<pair<double, double>> &passFail = it->second->_passFail;
86 marker = it->second->_marker;
87
88 startTime = it->second->_start;
89
90 gettimeofday(&currTime, NULL);
91
92 timersub(&currTime, &startTime, &result);
93
94 if ((result.tv_sec * 1000000 + result.tv_usec) > (windowSize * 1000)) {
95 marker = ++marker % it->second->_totalSlot;
96 if (marker == it->second->_totalSlot - 1) {
97 ++it->second->_windowPassed;
98 double avg = 0;
99 for (int i = 0; i < it->second->_totalSlot; i++) {
100 if (passFail[i].first > 0) {
101 avg += passFail[i].first / (passFail[i].first + passFail[i].second);
102 }
103 }
104 it->second->_avgOverWindow += avg / it->second->_windowPassed;
105 }
106 it->second->_marker = marker;
107 gettimeofday(&it->second->_start, NULL);
108 }
109
110 if (isSuccess) {
111 passFail[marker].second++;
112 }
113
114 else {
115 passFail[marker].first++;
116 }
117}
118
119bool
120isAttemptReq(string URL, FailureData &data)

Callers 1

mainFunction · 0.85

Calls 1

findMethod · 0.45

Tested by

no test coverage detected