| 2195 | } |
| 2196 | |
| 2197 | void AdmissionController::HandleTopicUpdates( |
| 2198 | const vector<TTopicItem>& topic_updates, set<string>& pool_stats_removed_nodes) { |
| 2199 | string topic_key_prefix; |
| 2200 | string topic_key_suffix; |
| 2201 | string pool_name; |
| 2202 | string topic_backend_id; |
| 2203 | for (const TTopicItem& item : topic_updates) { |
| 2204 | if (!ParseTopicKey(item.key, &topic_key_prefix, &topic_key_suffix)) continue; |
| 2205 | if (topic_key_prefix == TOPIC_KEY_POOL_PREFIX) { |
| 2206 | if (!ParsePoolTopicKey(topic_key_suffix, &pool_name, &topic_backend_id)) continue; |
| 2207 | // The topic entry from this subscriber is handled specially; the stats coming |
| 2208 | // from the statestore are likely already outdated. |
| 2209 | if (topic_backend_id == host_id_) continue; |
| 2210 | if (item.deleted) { |
| 2211 | GetPoolStats(pool_name)->UpdateRemoteStats(topic_backend_id, nullptr); |
| 2212 | pool_stats_removed_nodes.insert(topic_backend_id); |
| 2213 | continue; |
| 2214 | } |
| 2215 | TPoolStats remote_update; |
| 2216 | uint32_t len = item.value.size(); |
| 2217 | Status status = |
| 2218 | DeserializeThriftMsg(reinterpret_cast<const uint8_t*>(item.value.data()), &len, |
| 2219 | false, &remote_update); |
| 2220 | if (!status.ok()) { |
| 2221 | VLOG_QUERY << "Error deserializing pool update with key: " << item.key; |
| 2222 | continue; |
| 2223 | } |
| 2224 | GetPoolStats(pool_name)->UpdateRemoteStats(topic_backend_id, &remote_update); |
| 2225 | } else if (topic_key_prefix == TOPIC_KEY_STAT_PREFIX) { |
| 2226 | topic_backend_id = topic_key_suffix; |
| 2227 | if (topic_backend_id == host_id_) continue; |
| 2228 | if (item.deleted) { |
| 2229 | remote_per_host_stats_.erase(topic_backend_id); |
| 2230 | continue; |
| 2231 | } |
| 2232 | TPerHostStatsUpdate remote_update; |
| 2233 | uint32_t len = item.value.size(); |
| 2234 | Status status = |
| 2235 | DeserializeThriftMsg(reinterpret_cast<const uint8_t*>(item.value.data()), &len, |
| 2236 | false, &remote_update); |
| 2237 | if (!status.ok()) { |
| 2238 | VLOG_QUERY << "Error deserializing stats update with key: " << item.key; |
| 2239 | continue; |
| 2240 | } |
| 2241 | PerHostStats& stats = remote_per_host_stats_[topic_backend_id]; |
| 2242 | for (const auto& elem : remote_update.per_host_stats) { |
| 2243 | stats[elem.host_addr] = elem.stats; |
| 2244 | } |
| 2245 | } else { |
| 2246 | VLOG_QUERY << "Invalid topic key prefix: " << topic_key_prefix; |
| 2247 | } |
| 2248 | } |
| 2249 | } |
| 2250 | |
| 2251 | void AdmissionController::PoolStats::UpdateAggregates(HostMemMap* host_mem_reserved) { |
| 2252 | const string& coord_id = parent_->host_id_; |
nothing calls this directly
no test coverage detected