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

Method subscribe

src/master/master.cpp:2657–2731  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2655
2656
2657void Master::subscribe(
2658 StreamingHttpConnection<v1::scheduler::Event> http,
2659 scheduler::Call::Subscribe&& subscribe)
2660{
2661 // TODO(anand): Authenticate the framework.
2662
2663 FrameworkInfo& frameworkInfo = *subscribe.mutable_framework_info();
2664
2665 // Update messages_{re}register_framework accordingly.
2666 if (!frameworkInfo.has_id() || frameworkInfo.id() == "") {
2667 ++metrics->messages_register_framework;
2668 } else {
2669 ++metrics->messages_reregister_framework;
2670 }
2671
2672 LOG(INFO) << "Received subscription request for"
2673 << " HTTP framework '" << frameworkInfo.name() << "'";
2674
2675 Option<Error> validationError =
2676 validateFramework(frameworkInfo, subscribe.suppressed_roles());
2677
2678 allocator::FrameworkOptions allocatorOptions;
2679
2680 // TODO(asekretenko): Validate roles in offer constraints (see MESOS-10176).
2681 if (validationError.isNone()) {
2682 Try<OfferConstraintsFilter> filter = OfferConstraintsFilter::create(
2683 offerConstraintsFilterOptions,
2684 OfferConstraints(subscribe.offer_constraints()));
2685
2686 if (filter.isError()) {
2687 validationError = Error(std::move(filter.error()));
2688 } else {
2689 allocatorOptions.offerConstraintsFilter = std::move(*filter);
2690 }
2691 }
2692
2693 if (validationError.isSome()) {
2694 LOG(INFO) << "Refusing subscription of framework"
2695 << " '" << frameworkInfo.name() << "': "
2696 << validationError->message;
2697
2698 FrameworkErrorMessage message;
2699 message.set_message(validationError->message);
2700
2701 http.send(message);
2702 http.close();
2703 return;
2704 }
2705
2706 allocatorOptions.suppressedRoles = set<string>(
2707 make_move_iterator(subscribe.mutable_suppressed_roles()->begin()),
2708 make_move_iterator(subscribe.mutable_suppressed_roles()->end()));
2709
2710 // Need to disambiguate for the compiler.
2711 void (Master::*_subscribe)(
2712 StreamingHttpConnection<v1::scheduler::Event>,
2713 FrameworkInfo&&,
2714 OfferConstraints&&,

Callers

nothing calls this directly

Calls 15

validateFrameworkFunction · 0.85
deferFunction · 0.85
exitedFunction · 0.85
errorMethod · 0.65
sendMethod · 0.65
createFunction · 0.50
ErrorFunction · 0.50
sendFunction · 0.50
idMethod · 0.45
nameMethod · 0.45
isNoneMethod · 0.45
isErrorMethod · 0.45

Tested by

no test coverage detected