| 3308 | } |
| 3309 | |
| 3310 | void AdmissionController::UpdateExecGroupMetricMap( |
| 3311 | const ClusterMembershipMgr::SnapshotPtr& snapshot) { |
| 3312 | std::unordered_set<string> grp_names; |
| 3313 | for (const auto& group : snapshot->executor_groups) { |
| 3314 | if (group.second.NumHosts() > 0) grp_names.insert(group.first); |
| 3315 | } |
| 3316 | lock_guard<mutex> l(admission_ctrl_lock_); |
| 3317 | auto it = exec_group_query_load_map_.begin(); |
| 3318 | while (it != exec_group_query_load_map_.end()) { |
| 3319 | // Erase existing groups from the set so that only new ones are left. |
| 3320 | if (grp_names.erase(it->first) == 0) { |
| 3321 | // Existing group not in the set means it no longer exists. |
| 3322 | string group_name = it->first; |
| 3323 | it = exec_group_query_load_map_.erase(it); |
| 3324 | metrics_group_->RemoveMetric(EXEC_GROUP_QUERY_LOAD_KEY_FORMAT, group_name); |
| 3325 | } else { |
| 3326 | ++it; |
| 3327 | } |
| 3328 | } |
| 3329 | // Now only the new groups are remaining in the set, add a metric for them. |
| 3330 | for (const string& new_grp : grp_names) { |
| 3331 | // There might be lingering queries from when this group was active. |
| 3332 | int64_t currently_running = 0; |
| 3333 | auto new_grp_it = snapshot->executor_groups.find(new_grp); |
| 3334 | DCHECK(new_grp_it != snapshot->executor_groups.end()); |
| 3335 | ExecutorGroup group = new_grp_it->second; |
| 3336 | for (const BackendDescriptorPB& be_desc : group.GetAllExecutorDescriptors()) { |
| 3337 | const string& host = NetworkAddressPBToString(be_desc.address()); |
| 3338 | auto stats = host_stats_.find(host); |
| 3339 | if (stats != host_stats_.end()) { |
| 3340 | currently_running = std::max(currently_running, stats->second.num_admitted); |
| 3341 | } |
| 3342 | } |
| 3343 | exec_group_query_load_map_[new_grp] = metrics_group_->AddGauge( |
| 3344 | EXEC_GROUP_QUERY_LOAD_KEY_FORMAT, currently_running, new_grp); |
| 3345 | } |
| 3346 | } |
| 3347 | |
| 3348 | void AdmissionController::UpdateExecGroupMetric(const string& grp_name, int64_t delta) { |
| 3349 | auto entry = exec_group_query_load_map_.find(grp_name); |
no test coverage detected