MCPcopy Create free account
hub / github.com/apache/mesos / foreach

Function foreach

src/master/weights.cpp:37–64  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35 }
36
37 foreach (const WeightInfo& weightInfo, weightInfos) {
38 bool hasStored = false;
39 for (int i = 0; i < registry->weights().size(); ++i) {
40 Registry::Weight* weight = registry->mutable_weights(i);
41
42 if (weight->info().role() != weightInfo.role()) {
43 continue;
44 }
45
46 hasStored = true;
47
48 // If there is already weight stored for the specified role
49 // and also its value is changed, update the entry.
50 if (weight->info().weight() != weightInfo.weight()) {
51 weight->mutable_info()->CopyFrom(weightInfo);
52 mutated = true;
53 }
54
55 break;
56 }
57
58 // If there is no weight yet for this role in registry,
59 // create a new entry.
60 if (!hasStored) {
61 registry->add_weights()->mutable_info()->CopyFrom(weightInfo);
62 mutated = true;
63 }
64 }
65
66 return mutated;
67}

Callers

nothing calls this directly

Calls 5

weightsMethod · 0.80
infoMethod · 0.80
weightMethod · 0.80
CopyFromMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected