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

Method createStrategy

src/proxy/http/remap/NextHopStrategyFactory.cc:129–162  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

127}
128
129void
130NextHopStrategyFactory::createStrategy(const std::string &name, const NHPolicyType policy_type, ts::Yaml::Map &node)
131{
132 std::shared_ptr<NextHopSelectionStrategy> strat;
133 std::shared_ptr<NextHopRoundRobin> strat_rr;
134 std::shared_ptr<NextHopConsistentHash> strat_chash;
135
136 strat = strategyInstance(name.c_str());
137 if (strat != nullptr) {
138 NH_Note("A strategy named '%s' has already been loaded and another will not be created.", name.data());
139 node.bad();
140 return;
141 }
142
143 try {
144 switch (policy_type) {
145 case NH_FIRST_LIVE:
146 case NH_RR_STRICT:
147 case NH_RR_IP:
148 case NH_RR_LATCHED:
149 strat_rr = std::make_shared<NextHopRoundRobin>(name, policy_type, node);
150 _strategies.emplace(std::make_pair(std::string(name), strat_rr));
151 break;
152 case NH_CONSISTENT_HASH:
153 strat_chash = std::make_shared<NextHopConsistentHash>(name, policy_type, node);
154 _strategies.emplace(std::make_pair(std::string(name), strat_chash));
155 break;
156 default: // handles P_UNDEFINED, no strategy is added
157 break;
158 };
159 } catch (std::exception &ex) {
160 strat.reset();
161 }
162}
163
164std::shared_ptr<NextHopSelectionStrategy>
165NextHopStrategyFactory::strategyInstance(const char *name)

Callers

nothing calls this directly

Calls 6

stringClass · 0.85
badMethod · 0.80
emplaceMethod · 0.80
c_strMethod · 0.45
dataMethod · 0.45
resetMethod · 0.45

Tested by

no test coverage detected