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

Method lookup_available

src/tscore/ConsistentHash.cc:124–178  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

122}
123
124ATSConsistentHashNode *
125ATSConsistentHash::lookup_available(const char *url, ATSConsistentHashIter *i, bool *w, ATSHash64 *h)
126{
127 uint64_t url_hash;
128 ATSConsistentHashIter NodeMapIterUp, *iter;
129 ATSHash64 *thash;
130 bool *wptr, wrapped = false;
131
132 if (h) {
133 thash = h;
134 } else if (hash) {
135 thash = hash;
136 } else {
137 return nullptr;
138 }
139
140 if (w) {
141 wptr = w;
142 } else {
143 wptr = &wrapped;
144 }
145
146 if (i) {
147 iter = i;
148 } else {
149 iter = &NodeMapIterUp;
150 }
151
152 if (url) {
153 thash->update(url, strlen(url));
154 thash->final();
155 url_hash = thash->get();
156 thash->clear();
157
158 *iter = NodeMap.lower_bound(url_hash);
159 }
160
161 if (*iter == NodeMap.end()) {
162 *wptr = true;
163 *iter = NodeMap.begin();
164 }
165
166 while (!(*iter)->second->available) {
167 (*iter)++;
168
169 if (!(*wptr) && *iter == NodeMap.end()) {
170 *wptr = true;
171 *iter = NodeMap.begin();
172 } else if (*wptr && *iter == NodeMap.end()) {
173 return nullptr;
174 }
175 }
176
177 return (*iter)->second;
178}
179
180ATSConsistentHashNode *
181ATSConsistentHash::lookup_by_hashval(uint64_t hashval, ATSConsistentHashIter *i, bool *w)

Callers

nothing calls this directly

Calls 7

lower_boundMethod · 0.80
updateMethod · 0.45
finalMethod · 0.45
getMethod · 0.45
clearMethod · 0.45
endMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected