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

Method receive

src/sched/sched.cpp:539–726  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

537 }
538
539 void receive(const UPID& from, const Event& event)
540 {
541 switch (event.type()) {
542 case Event::SUBSCRIBED: {
543 if (!event.has_subscribed()) {
544 drop(event, "Expecting 'subscribed' to be present");
545 break;
546 }
547
548 // The scheduler API requires a MasterInfo be passed during
549 // (re-)registration, so we rely on the MasterInfo provided
550 // by the detector. If it's None, the driver would have
551 // dropped the message.
552 if (master.isNone()) {
553 drop(event, "No master detected");
554 break;
555 }
556
557 const FrameworkID& frameworkId = event.subscribed().framework_id();
558
559 // Cancel the pending registration timer to avoid spurious attempts
560 // at reregistration. `Clock::cancel` is idempotent, so this call
561 // is safe even if no timer is active or pending.
562 Clock::cancel(frameworkRegistrationTimer);
563
564 // We match the existing registration semantics of the
565 // driver, except for the 3rd case in MESOS-786 (since
566 // it requires non-local knowledge and schedulers could
567 // not have possibly relied on this case).
568 if (!framework.has_id() || framework.id().value().empty()) {
569 registered(from, frameworkId, master.get());
570 } else if (failover) {
571 registered(from, frameworkId, master.get());
572 } else {
573 reregistered(from, frameworkId, master.get());
574 }
575
576 break;
577 }
578
579 case Event::OFFERS: {
580 if (!event.has_offers()) {
581 drop(event, "Expecting 'offers' to be present");
582 break;
583 }
584
585 const vector<Offer> offers =
586 google::protobuf::convert(event.offers().offers());
587
588 vector<string> pids;
589
590 foreach (const Offer& offer, offers) {
591 CHECK(offer.has_url())
592 << "Offer.url required for Event support";
593 CHECK(offer.url().has_path())
594 << "Offer.url.path required for Event support";
595
596 string id = offer.url().path();

Callers

nothing calls this directly

Calls 15

errorFunction · 0.85
typeMethod · 0.80
subscribedMethod · 0.80
CopyFromMethod · 0.80
dataMethod · 0.80
failureMethod · 0.80
errorMethod · 0.65
convertFunction · 0.50
UPIDClass · 0.50
isNoneMethod · 0.45
emptyMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected