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

Method masterLaunchTaskResourceDecorator

src/examples/test_hook_module.cpp:114–140  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

112 }
113
114 Result<Resources> masterLaunchTaskResourceDecorator(
115 const TaskInfo& taskInfo,
116 const Resources& slaveResources) override
117 {
118 LOG(INFO) << "Executing 'masterLaunchTaskResourceDecorator' hook";
119
120 // If slave does not declare network bandwidth resource,
121 // don't set a default value for it.
122 if (slaveResources.names().count("network_bandwidth") == 0) {
123 return taskInfo.resources();
124 }
125
126 Resources taskResources = taskInfo.resources();
127
128 // Add a default value for network bandwidth if absent.
129 if (taskResources.names().count("network_bandwidth") == 0) {
130 Resources bandwidth =
131 CHECK_NOTERROR(Resources::parse("network_bandwidth:10"));
132
133 CHECK(!taskResources.allocations().empty());
134 bandwidth.allocate(taskResources.allocations().begin()->first);
135
136 taskResources += bandwidth;
137 }
138
139 return taskResources;
140 }
141
142 Try<Nothing> masterSlaveLostHook(const SlaveInfo& slaveInfo) override
143 {

Callers

nothing calls this directly

Calls 8

namesMethod · 0.65
parseFunction · 0.50
countMethod · 0.45
resourcesMethod · 0.45
emptyMethod · 0.45
allocationsMethod · 0.45
allocateMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected