Add active or standby status for catalog or statestore.
| 305 | |
| 306 | // Add active or standby status for catalog or statestore. |
| 307 | void AddActiveStatus(Document* document, MetricGroup* metric_group) { |
| 308 | DaemonEnv* d_env = DaemonEnv::GetInstance(); |
| 309 | bool is_statestore = false; |
| 310 | bool is_catalog = false; |
| 311 | if (d_env != nullptr) { |
| 312 | if (d_env->name() == "statestore") { |
| 313 | is_statestore = true; |
| 314 | } else if (d_env->name() == "catalog") { |
| 315 | is_catalog = true; |
| 316 | } else { |
| 317 | // Only deal with the status of catalog or statestore. |
| 318 | return; |
| 319 | } |
| 320 | document->AddMember("is_statestore", is_statestore, document->GetAllocator()); |
| 321 | document->AddMember("is_catalog", is_catalog, document->GetAllocator()); |
| 322 | } |
| 323 | |
| 324 | if (metric_group != nullptr) { |
| 325 | if (is_catalog) { |
| 326 | BooleanProperty* metric = metric_group->FindMetricForTesting<BooleanProperty>( |
| 327 | "catalog-server.active-status"); |
| 328 | if (metric != nullptr) { |
| 329 | if (metric->GetValue()) { |
| 330 | document->AddMember( |
| 331 | "catalogd_active_status", "Active", document->GetAllocator()); |
| 332 | } else { |
| 333 | document->AddMember( |
| 334 | "catalogd_active_status", "Standby", document->GetAllocator()); |
| 335 | } |
| 336 | } |
| 337 | } |
| 338 | if (is_statestore) { |
| 339 | BooleanProperty* metric = |
| 340 | metric_group->FindMetricForTesting<BooleanProperty>("statestore.active-status"); |
| 341 | if (metric != nullptr) { |
| 342 | if (metric->GetValue()) { |
| 343 | document->AddMember( |
| 344 | "statestore_active_status", "Active", document->GetAllocator()); |
| 345 | } else { |
| 346 | document->AddMember( |
| 347 | "statestore_active_status", "Standby", document->GetAllocator()); |
| 348 | } |
| 349 | } |
| 350 | } |
| 351 | } |
| 352 | } |
| 353 | |
| 354 | void RootHandler( |
| 355 | const Webserver::WebRequest& req, Document* document, MetricGroup* metric_group) { |
no test coverage detected