MCPcopy Create free account
hub / github.com/apache/impala / BackendsHandler

Method BackendsHandler

be/src/service/impala-http-handler.cc:1467–1569  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1465}
1466
1467void ImpalaHttpHandler::BackendsHandler(const Webserver::WebRequest& req,
1468 Document* document) {
1469 AdmissionController::PerHostStats host_stats;
1470 DCHECK(admission_controller_ != nullptr);
1471 admission_controller_->PopulatePerHostMemReservedAndAdmitted(&host_stats);
1472 Value backends_list(kArrayType);
1473 int num_active_backends = 0;
1474 int num_quiescing_backends = 0;
1475 int num_blacklisted_backends = 0;
1476 DCHECK(cluster_membership_mgr_ != nullptr);
1477 ClusterMembershipMgr::SnapshotPtr membership_snapshot =
1478 cluster_membership_mgr_->GetSnapshot();
1479 DCHECK(membership_snapshot.get() != nullptr);
1480 for (const auto& entry : membership_snapshot->current_backends) {
1481 BackendDescriptorPB backend = entry.second;
1482 Value backend_obj(kObjectType);
1483 string address = NetworkAddressPBToString(backend.address());
1484 Value str(address, document->GetAllocator());
1485 Value krpc_address(NetworkAddressPBToString(backend.krpc_address()),
1486 document->GetAllocator());
1487 backend_obj.AddMember("address", str, document->GetAllocator());
1488 backend_obj.AddMember("krpc_address", krpc_address, document->GetAllocator());
1489 Value backend_id_str(PrintId(backend.backend_id()), document->GetAllocator());
1490 backend_obj.AddMember("backend_id", backend_id_str, document->GetAllocator());
1491 string webserver_url =
1492 Substitute("$0://$1", backend.secure_webserver() ? "https" : "http",
1493 NetworkAddressPBToString(backend.debug_http_address()));
1494 Value webserver_url_val(webserver_url, document->GetAllocator());
1495 backend_obj.AddMember("webserver_url", webserver_url_val, document->GetAllocator());
1496 backend_obj.AddMember(
1497 "is_coordinator", backend.is_coordinator(), document->GetAllocator());
1498 backend_obj.AddMember("is_executor", backend.is_executor(), document->GetAllocator());
1499 backend_obj.AddMember(
1500 "is_quiescing", backend.is_quiescing(), document->GetAllocator());
1501 Status blacklist_cause;
1502 int64_t blacklist_time_remaining_ms;
1503 bool is_blacklisted = membership_snapshot->executor_blacklist.IsBlacklisted(
1504 backend, &blacklist_cause, &blacklist_time_remaining_ms);
1505 backend_obj.AddMember("is_blacklisted", is_blacklisted, document->GetAllocator());
1506 backend_obj.AddMember("is_active", !is_blacklisted && !backend.is_quiescing(),
1507 document->GetAllocator());
1508 if (backend.is_quiescing()) {
1509 // Backends cannot be both blacklisted and quiescing.
1510 DCHECK(!is_blacklisted);
1511 ++num_quiescing_backends;
1512 } else if (is_blacklisted) {
1513 Value blacklist_cause_value(
1514 blacklist_cause.GetDetail(), document->GetAllocator());
1515 backend_obj.AddMember(
1516 "blacklist_cause", blacklist_cause_value, document->GetAllocator());
1517 Value blacklist_time_remaining_str(
1518 Substitute("$0 s", (blacklist_time_remaining_ms / 1000)),
1519 document->GetAllocator());
1520 backend_obj.AddMember("blacklist_time_remaining", blacklist_time_remaining_str,
1521 document->GetAllocator());
1522 ++num_blacklisted_backends;
1523 } else {
1524 ++num_active_backends;

Callers

nothing calls this directly

Calls 15

NetworkAddressPBToStringFunction · 0.85
PrintIdFunction · 0.85
SubstituteFunction · 0.85
PrintBytesFunction · 0.85
JoinStringsFunction · 0.85
GetSnapshotMethod · 0.80
is_coordinatorMethod · 0.80
IsBlacklistedMethod · 0.80
GetDetailMethod · 0.80
admit_mem_limitMethod · 0.80
admission_slotsMethod · 0.80

Tested by

no test coverage detected