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

Method offers

src/cli/execute.cpp:493–644  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

491 }
492
493 void offers(const vector<Offer>& offers)
494 {
495 CHECK_EQ(SUBSCRIBED, state);
496
497 foreach (const Offer& offer, offers) {
498 // Strip the allocation from the offer since we use a single role.
499 Resources offered = offer.resources();
500 offered.unallocate();
501
502 Resources requiredResources;
503
504 CHECK_NE(task.isSome(), taskGroup.isSome())
505 << "Either task or task group should be set but not both";
506
507 if (task.isSome()) {
508 requiredResources = Resources(task->resources());
509 } else {
510 foreach (const TaskInfo& _task, taskGroup->tasks()) {
511 requiredResources += Resources(_task.resources());
512 }
513 }
514
515 if (!launched && offered.toUnreserved().contains(requiredResources)) {
516 TaskInfo _task;
517 TaskGroupInfo _taskGroup;
518
519 if (task.isSome()) {
520 _task = task.get();
521 _task.mutable_agent_id()->MergeFrom(offer.agent_id());
522
523 // Takes resources first from the specified role, then from '*'.
524 Option<Resources> resources = [&]() {
525 if (frameworkInfo.role() == "*") {
526 return offered.find(Resources(_task.resources()));
527 } else {
528 Resource::ReservationInfo reservation;
529 reservation.set_type(Resource::ReservationInfo::STATIC);
530 reservation.set_role(frameworkInfo.role());
531
532 return offered.find(
533 Resources(_task.resources()).pushReservation(reservation));
534 }
535 }();
536
537 CHECK_SOME(resources);
538
539 _task.mutable_resources()->CopyFrom(resources.get());
540 } else {
541 foreach (TaskInfo _task, taskGroup->tasks()) {
542 _task.mutable_agent_id()->MergeFrom(offer.agent_id());
543
544 // Takes resources first from the specified role, then from '*'.
545 Option<Resources> resources = [&]() {
546 if (frameworkInfo.role() == "*") {
547 return offered.find(Resources(_task.resources()));
548 } else {
549 Resource::ReservationInfo reservation;
550 reservation.set_type(Resource::ReservationInfo::STATIC);

Callers 15

receiveMethod · 0.45
receivedMethod · 0.45
evolveFunction · 0.45
TEST_FFunction · 0.45
TEST_PFunction · 0.45
TEST_FFunction · 0.45
TEST_PFunction · 0.45
TEST_PFunction · 0.45
TEST_PFunction · 0.45
TEST_FFunction · 0.45

Calls

no outgoing calls

Tested by 15

TEST_FFunction · 0.36
TEST_PFunction · 0.36
TEST_FFunction · 0.36
TEST_PFunction · 0.36
TEST_PFunction · 0.36
TEST_PFunction · 0.36
TEST_FFunction · 0.36
TYPED_TESTFunction · 0.36
TEST_FFunction · 0.36
TEST_FFunction · 0.36