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

Method chashLookup

src/proxy/http/remap/NextHopConsistentHash.cc:56–84  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

54}
55
56std::shared_ptr<HostRecord>
57NextHopConsistentHash::chashLookup(const std::shared_ptr<ATSConsistentHash> &ring, uint32_t cur_ring, ParentResult &result,
58 HttpRequestData &request_info, bool *wrapped, uint64_t sm_id)
59{
60 uint64_t hash_key = 0;
61 ATSHash64Sip24 hash;
62 HostRecord *host_rec = nullptr;
63 ATSConsistentHashIter *iter = &result.chashIter[cur_ring];
64
65 if (result.chash_init[cur_ring] == false) {
66 hash_key = getHashKey(sm_id, request_info, &hash);
67 host_rec = static_cast<HostRecord *>(ring->lookup_by_hashval(hash_key, iter, wrapped));
68 result.chash_init[cur_ring] = true;
69 } else {
70 host_rec = static_cast<HostRecord *>(ring->lookup(nullptr, iter, wrapped, &hash));
71 }
72 bool wrap_around = *wrapped;
73 *wrapped = (result.mapWrapped[cur_ring] && *wrapped) ? true : false;
74 if (!result.mapWrapped[cur_ring] && wrap_around) {
75 result.mapWrapped[cur_ring] = true;
76 }
77
78 if (host_rec == nullptr) {
79 return nullptr;
80 } else {
81 std::shared_ptr<HostRecord> h = host_groups[host_rec->group_index][host_rec->host_index];
82 return h;
83 }
84}
85
86NextHopConsistentHash::~NextHopConsistentHash()
87{

Callers

nothing calls this directly

Calls 2

lookup_by_hashvalMethod · 0.80
lookupMethod · 0.45

Tested by

no test coverage detected