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

Method insert

src/tscore/ConsistentHash.cc:38–66  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36ATSConsistentHash::ATSConsistentHash(int r, ATSHash64 *h) : replicas(r), hash(h) {}
37
38void
39ATSConsistentHash::insert(ATSConsistentHashNode *node, float weight, ATSHash64 *h)
40{
41 int i;
42 char numstr[256];
43 ATSHash64 *thash;
44 std::ostringstream string_stream;
45 std::string std_string;
46
47 if (h) {
48 thash = h;
49 } else if (hash) {
50 thash = hash;
51 } else {
52 return;
53 }
54
55 string_stream << *node;
56 std_string = string_stream.str();
57
58 for (i = 0; i < static_cast<int>(roundf(replicas * weight)); i++) {
59 snprintf(numstr, 256, "%d-", i);
60 thash->update(numstr, strlen(numstr));
61 thash->update(std_string.c_str(), strlen(std_string.c_str()));
62 thash->final();
63 NodeMap.insert(std::pair<uint64_t, ATSConsistentHashNode *>(thash->get(), node));
64 thash->clear();
65 }
66}
67
68ATSConsistentHashNode *
69ATSConsistentHash::lookup(const char *url, ATSConsistentHashIter *i, bool *w, ATSHash64 *h)

Callers 10

InsertMethod · 0.45
Headers.ccFile · 0.45
add_statMethod · 0.45
mainFunction · 0.45
_new_referenceMethod · 0.45
parseMethod · 0.45
getPortMethod · 0.45
allocStripeMethod · 0.45
StatsMethod · 0.45

Calls 6

strMethod · 0.45
updateMethod · 0.45
c_strMethod · 0.45
finalMethod · 0.45
getMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected