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

Method sync_task

src/proxy/HostStatus.cc:516–543  ·  view source on GitHub ↗

method to write host status records to the persistent store.

Source from the content-addressed store, hash-verified

514
515// method to write host status records to the persistent store.
516void
517HostStatusSync::sync_task()
518{
519 YAML::Node records{YAML::NodeType::Map};
520
521 YAML::Node statusList{YAML::NodeType::Sequence};
522 std::vector<HostStatuses> statuses;
523 HostStatus &hs = HostStatus::instance();
524 hs.getAllHostStatuses(statuses);
525
526 for (auto &&h : statuses) {
527 YAML::Node host{YAML::NodeType::Map};
528 host[HOST_NAME_KEY] = h.hostname;
529 host[STATUS_KEY] = h.status;
530 statusList.push_back(host);
531 }
532 records["statuses"] = statusList;
533
534 std::ofstream fout;
535 fout.open(hostRecordsFile.c_str(), std::ofstream::out | std::ofstream::trunc);
536 if (fout) {
537 fout << records;
538 fout << '\n';
539 fout.close();
540 } else {
541 Warning("failed to open %s for writing", hostRecordsFile.c_str());
542 }
543}

Callers

nothing calls this directly

Calls 5

getAllHostStatusesMethod · 0.80
push_backMethod · 0.45
openMethod · 0.45
c_strMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected