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

Function getConsumedResources

src/common/protobuf_utils.cpp:1092–1128  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1090
1091
1092Try<Resources> getConsumedResources(const Offer::Operation& operation)
1093{
1094 switch (operation.type()) {
1095 case Offer::Operation::CREATE_DISK:
1096 return operation.create_disk().source();
1097 case Offer::Operation::DESTROY_DISK:
1098 return operation.destroy_disk().source();
1099 case Offer::Operation::RESERVE:
1100 case Offer::Operation::UNRESERVE:
1101 case Offer::Operation::CREATE:
1102 case Offer::Operation::DESTROY:
1103 case Offer::Operation::GROW_VOLUME:
1104 case Offer::Operation::SHRINK_VOLUME: {
1105 Try<vector<ResourceConversion>> conversions =
1106 getResourceConversions(operation);
1107
1108 if (conversions.isError()) {
1109 return Error(conversions.error());
1110 }
1111
1112 Resources consumed;
1113 foreach (const ResourceConversion& conversion, conversions.get()) {
1114 consumed += conversion.consumed;
1115 }
1116
1117 return consumed;
1118 }
1119 case Offer::Operation::LAUNCH:
1120 case Offer::Operation::LAUNCH_GROUP:
1121 // TODO(bbannier): Consider adding support for 'LAUNCH' and
1122 // 'LAUNCH_GROUP' operations.
1123 case Offer::Operation::UNKNOWN:
1124 return Error("Unsupported operation");
1125 }
1126
1127 UNREACHABLE();
1128}
1129
1130
1131namespace slave {

Callers 14

allowsReconciliationMethod · 0.85
foreachFunction · 0.85
getOperationsMethod · 0.85
applyMethod · 0.85
_operationMethod · 0.85
foreachFunction · 0.85
updateOperationMethod · 0.85
removeOperationMethod · 0.85
addOperationMethod · 0.85
recoverResourcesMethod · 0.85
markOperationAsOrphanMethod · 0.85
getOperationsMethod · 0.85

Calls 5

getResourceConversionsFunction · 0.85
typeMethod · 0.80
errorMethod · 0.65
ErrorFunction · 0.50
isErrorMethod · 0.45

Tested by 1

foreachFunction · 0.68