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

Function foreach

src/common/resources_utils.cpp:54–93  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

52 Resources totalResources = resources;
53
54 foreach (const Resource& resource, checkpointedResources) {
55 if (!needCheckpointing(resource)) {
56 return Error("Unexpected checkpointed resources " + stringify(resource));
57 }
58
59 Resource stripped = resource;
60
61 // Since only unreserved and statically reserved resources can be specified
62 // on the agent, we strip away all of the dynamic reservations here to
63 // deduce the agent resources on which to apply the checkpointed resources.
64 if (Resources::isDynamicallyReserved(resource)) {
65 Resource::ReservationInfo reservation = stripped.reservations(0);
66 stripped.clear_reservations();
67 if (reservation.type() == Resource::ReservationInfo::STATIC) {
68 stripped.add_reservations()->CopyFrom(reservation);
69 }
70 }
71
72 // Strip persistence and volume from the disk info so that we can
73 // check whether it is contained in the `totalResources`.
74 if (Resources::isPersistentVolume(resource)) {
75 if (stripped.disk().has_source()) {
76 stripped.mutable_disk()->clear_persistence();
77 stripped.mutable_disk()->clear_volume();
78 } else {
79 stripped.clear_disk();
80 }
81 }
82
83 stripped.clear_shared();
84
85 if (!totalResources.contains(stripped)) {
86 return Error(
87 "Incompatible agent resources: " + stringify(totalResources) +
88 " does not contain " + stringify(stripped));
89 }
90
91 totalResources -= stripped;
92 totalResources += resource;
93 }
94
95 return totalResources;
96}

Callers 2

convertResourceFormatFunction · 0.70
downgradeResourcesFunction · 0.70

Calls 15

needCheckpointingFunction · 0.85
NothingClass · 0.85
typeMethod · 0.80
CopyFromMethod · 0.80
executorMethod · 0.80
validateFunction · 0.70
ErrorFunction · 0.50
stringifyFunction · 0.50
reservationsMethod · 0.45
diskMethod · 0.45
containsMethod · 0.45
popReservationMethod · 0.45

Tested by

no test coverage detected