MCPcopy Create free account
hub / github.com/apache/trafficserver / server_set_status

Function server_set_status

src/proxy/HostStatus.cc:481–513  ·  view source on GitHub ↗

JSON-RPC method to mark up or down a host.

Source from the content-addressed store, hash-verified

479
480// JSON-RPC method to mark up or down a host.
481swoc::Rv<YAML::Node>
482server_set_status(std::string_view id, YAML::Node const &params)
483{
484 Dbg(dbg_ctl_host_statuses, "id=%s", id.data());
485 namespace err = rpc::handlers::errors;
486 swoc::Rv<YAML::Node> resp;
487
488 try {
489 if (!params.IsNull()) {
490 auto cmdInfo = params.as<HostCmdInfo>();
491
492 for (auto const &name : cmdInfo.hosts) {
493 HostStatus &hs = HostStatus::instance();
494 std::string statName = stat_prefix + name;
495 Dbg(dbg_ctl_host_statuses, "marking server %s : %s", name.c_str(),
496 (cmdInfo.type == TSHostStatus::TS_HOST_STATUS_UP ? "up" : "down"));
497 hs.setHostStatus(name.c_str(), cmdInfo.type, cmdInfo.time, cmdInfo.reasonType);
498 }
499 } else {
500 resp.errata().assign(std::error_code{rpc::handlers::errors::Codes::SERVER}).note("Invalid input parameters, null");
501 }
502
503 // schedule a write to the persistent store.
504 Dbg(dbg_ctl_host_statuses, "updating persistent store");
505 eventProcessor.schedule_imm(HostStatusSync::new_instance(), ET_TASK);
506 } catch (std::exception const &ex) {
507 Dbg(dbg_ctl_host_statuses, "Got an error HostCmdInfo decoding: %s", ex.what());
508 resp.errata()
509 .assign(std::error_code{rpc::handlers::errors::Codes::SERVER})
510 .note("Error found during host status set: {}", ex.what());
511 }
512 return resp;
513}
514
515// method to write host status records to the persistent store.
516void

Callers

nothing calls this directly

Calls 7

dataMethod · 0.45
c_strMethod · 0.45
setHostStatusMethod · 0.45
noteMethod · 0.45
assignMethod · 0.45
schedule_immMethod · 0.45
whatMethod · 0.45

Tested by

no test coverage detected