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

Method update

src/resource_provider/daemon.cpp:258–309  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

256
257
258Future<bool> LocalResourceProviderDaemonProcess::update(
259 const ResourceProviderInfo& info)
260{
261 CHECK(!info.has_id()); // Should have already been validated by the agent.
262
263 if (configDir.isNone()) {
264 return Failure("Missing required flag --resource_provider_config_dir");
265 }
266
267 if (!providers[info.type()].contains(info.name())) {
268 return false;
269 }
270
271 ProviderData& data = providers[info.type()].at(info.name());
272
273 if (data.removing.isSome()) {
274 return Failure(
275 "Failed to update resource provider with type '" + info.type() +
276 "' and name '" + info.name() + "' as a removal is still in progress");
277 }
278
279 // Return true if the info has been updated for idempotency.
280 if (data.info == info) {
281 return true;
282 }
283
284 Try<Nothing> _save = save(data.path, info);
285 if (_save.isError()) {
286 return Failure(
287 "Failed to write config file '" + data.path + "': " + _save.error());
288 }
289
290 data.info = info;
291
292 // Update `version` to indicate that the config has been updated.
293 data.version = id::UUID::random();
294
295 // Launch the resource provider if the daemon is already started.
296 if (slaveId.isSome()) {
297 auto err = [](const ResourceProviderInfo& info, const string& message) {
298 LOG(ERROR)
299 << "Failed to launch resource provider with type '" << info.type()
300 << "' and name '" << info.name() << "': " << message;
301 };
302
303 launch(info.type(), info.name())
304 .onFailed(std::bind(err, info, lambda::_1))
305 .onDiscarded(std::bind(err, info, "future discarded"));
306 }
307
308 return true;
309}
310
311
312Future<Nothing> LocalResourceProviderDaemonProcess::remove(

Callers 3

foreachpairFunction · 0.45
dropOperationMethod · 0.45
updateOperationStatusMethod · 0.45

Calls 14

FailureClass · 0.85
randomFunction · 0.85
typeMethod · 0.80
atMethod · 0.80
errorMethod · 0.65
launchFunction · 0.50
bindFunction · 0.50
dispatchFunction · 0.50
isNoneMethod · 0.45
containsMethod · 0.45
nameMethod · 0.45
isSomeMethod · 0.45

Tested by

no test coverage detected