Skip to content

Commit

Permalink
Add num_suspect_servers stat
Browse files Browse the repository at this point in the history
Summary: add current number of "suspect" servers to stats.

Test Plan: mcrouter unit tests

Reviewed By: @alikhtarov

Differential Revision: D2049957
  • Loading branch information
Pavlo Kushnir committed May 28, 2015
1 parent 9f53976 commit e59c5f9
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
13 changes: 13 additions & 0 deletions mcrouter/TkoTracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,19 @@ TkoTrackerMap::getSuspectServers() {
return result;
}

size_t TkoTrackerMap::getSuspectServersCount() {
size_t result = 0;
std::lock_guard<std::mutex> lock(mx_);
for (const auto& it : trackers_) {
if (auto tracker = it.second.lock()) {
if (tracker->consecutiveFailureCount() > 0) {
++result;
}
}
}
return result;
}

std::weak_ptr<TkoTracker> TkoTrackerMap::getTracker(folly::StringPiece key) {
std::lock_guard<std::mutex> lock(mx_);
return folly::get_default(trackers_, key);
Expand Down
7 changes: 6 additions & 1 deletion mcrouter/TkoTracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,12 @@ class TkoTrackerMap {
const size_t maxSoftTkos);

/**
* @return servers that recently received error replies.
* @return number of servers that recently returned error replies.
*/
size_t getSuspectServersCount();

/**
* @return servers that recently returned error replies.
* Format: {
* server ip => ( is server marked as TKO?, number of failures )
* }
Expand Down
1 change: 1 addition & 0 deletions mcrouter/stat_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
STUI(num_servers_down, 0, 1)
STUI(num_servers_closed, 0, 1)
STUI(num_clients, 0, 1)
STUI(num_suspect_servers, 0, 1)
#undef GROUP
#define GROUP ods_stats | mcproxy_stats
/* Total reqs in mc client yet to be sent to memcache. */
Expand Down
3 changes: 3 additions & 0 deletions mcrouter/stats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,9 @@ void prepare_stats(McrouterInstance* router, stat_t* stats) {
);
}

stat_set_uint64(stats, num_suspect_servers_stat,
router->tkoTrackerMap().getSuspectServersCount());

stat_set_uint64(stats, mcc_txbuf_reqs_stat, destStats.pendingRequests);
stat_set_uint64(stats, mcc_waiting_replies_stat, destStats.inflightRequests);

Expand Down

0 comments on commit e59c5f9

Please sign in to comment.