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

Method _reconfigure

src/proxy/http/PreWarmManager.cc:904–964  ·  view source on GitHub ↗

Reconfigure _map based on new SNIConfig */

Source from the content-addressed store, hash-verified

902 Reconfigure _map based on new SNIConfig
903 */
904void
905PreWarmQueue::_reconfigure()
906{
907 {
908 PreWarmConfig::scoped_config prewarm_conf;
909
910 _event_period = HRTIME_MSECONDS(prewarm_conf->event_period);
911 _algorithm = PreWarm::algorithm_version(prewarm_conf->algorithm);
912 }
913
914 // build new map based on new SNIConfig
915 const PreWarm::ParsedSNIConf &new_conf_list = prewarmManager.get_parsed_conf();
916 const PreWarm::StatsIdMap &new_stats_id_map = prewarmManager.get_stats_id_map();
917
918 Map new_map;
919 for (auto &entry : new_conf_list) {
920 const PreWarm::SPtrConstDst &dst = entry.first;
921 PreWarm::SPtrConstConf conf = entry.second;
922
923 if (const auto &res = _map.find(dst); res != _map.end()) {
924 // copy from old info
925 const Info &old_info = res->second;
926
927 new_map[dst] = Info{old_info.init_list, old_info.open_list, conf, old_info.stats_ids, old_info.stat};
928 } else {
929 // make new info
930 PreWarm::SPtrConstStatsIds stats_ids;
931 if (const auto &res = new_stats_id_map.find(dst); res != new_stats_id_map.end()) {
932 stats_ids = res->second;
933 } else {
934 Error("no stats ids found for %s", dst->host.c_str());
935 continue;
936 }
937
938 Queue *init_list = new Queue();
939 Queue *open_list = new Queue();
940 new_map[dst] = Info{init_list, open_list, conf, stats_ids, {}};
941 }
942 }
943
944 // free unexisting entries
945 for (auto &[dst, info] : _map) {
946 if (auto entry = new_conf_list.find(dst); entry == new_conf_list.end()) {
947 auto &[_, gauges] = *info.stats_ids;
948
949 ts::Metrics::Gauge::store(gauges[static_cast<int>(PreWarm::GaugeStat::INIT_LIST_SIZE)], 0);
950 ts::Metrics::Gauge::store(gauges[static_cast<int>(PreWarm::GaugeStat::OPEN_LIST_SIZE)], 0);
951
952 _make_queue_empty(info.init_list);
953 delete info.init_list;
954
955 _make_queue_empty(info.open_list);
956 delete info.open_list;
957
958 info.conf.reset();
959 info.stats_ids.reset();
960 }
961 }

Callers

nothing calls this directly

Calls 7

algorithm_versionFunction · 0.85
swapFunction · 0.85
ErrorClass · 0.50
findMethod · 0.45
endMethod · 0.45
c_strMethod · 0.45
resetMethod · 0.45

Tested by

no test coverage detected