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

Method _accept

src/master/master.cpp:4367–5367  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4365
4366
4367void Master::_accept(
4368 const FrameworkID& frameworkId,
4369 const SlaveID& slaveId,
4370 scheduler::Call::Accept&& accept)
4371{
4372 auto discardOffers = [this](const RepeatedPtrField<OfferID>& ids) {
4373 for (const OfferID& offerId : ids) {
4374 Offer* offer = getOffer(offerId);
4375 if (offer != nullptr) {
4376 discardOffer(offer);
4377 }
4378 }
4379 };
4380
4381 Framework* framework = getFramework(frameworkId);
4382
4383 // TODO(jieyu): Consider using the 'drop' overload mentioned in
4384 // 'accept' to consistently handle dropping ACCEPT calls.
4385 if (framework == nullptr) {
4386 LOG(WARNING)
4387 << "Ignoring ACCEPT call for framework " << frameworkId
4388 << " because the framework cannot be found";
4389
4390 // TODO(asekretenko): consider replacing this with a CHECK that there
4391 // never are any offers for a non-active (inactive/completed/...) framework.
4392 discardOffers(accept.offer_ids());
4393 return;
4394 }
4395
4396 Slave* slave = slaves.registered.get(slaveId);
4397
4398 if (slave == nullptr || !slave->connected) {
4399 TaskState newTaskState = TASK_DROPPED;
4400 if (!framework->capabilities.partitionAware) {
4401 newTaskState = TASK_LOST;
4402 }
4403
4404 foreach (const Offer::Operation& operation, accept.operations()) {
4405 if (operation.type() != Offer::Operation::LAUNCH &&
4406 operation.type() != Offer::Operation::LAUNCH_GROUP) {
4407 continue;
4408 }
4409
4410 const RepeatedPtrField<TaskInfo>& tasks = [&]() {
4411 if (operation.type() == Offer::Operation::LAUNCH) {
4412 return operation.launch().task_infos();
4413 } else {
4414 CHECK_EQ(Offer::Operation::LAUNCH_GROUP, operation.type());
4415 return operation.launch_group().task_group().tasks();
4416 }
4417 }();
4418
4419 foreach (const TaskInfo& task, tasks) {
4420 const TaskStatus::Reason reason =
4421 slave == nullptr ? TaskStatus::REASON_SLAVE_REMOVED
4422 : TaskStatus::REASON_SLAVE_DISCONNECTED;
4423 const StatusUpdate& update = protobuf::createStatusUpdate(
4424 framework->id(),

Callers

nothing calls this directly

Calls 10

getOfferFunction · 0.85
NoneClass · 0.85
getMethod · 0.45
sharedMethod · 0.45
emptyMethod · 0.45
updateAllocationMethod · 0.45
pauseMethod · 0.45
recoverResourcesMethod · 0.45
resumeMethod · 0.45

Tested by

no test coverage detected