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

Method addFramework

src/master/master.cpp:9991–10051  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9989
9990
9991void Master::addFramework(
9992 Framework* framework,
9993 ::mesos::allocator::FrameworkOptions&& allocatorOptions)
9994{
9995 CHECK_NOTNULL(framework);
9996
9997 CHECK(!frameworks.registered.contains(framework->id()))
9998 << "Framework " << *framework << " already exists!";
9999
10000 // TODO(asekretenko): Print some information about the OfferConstraintsFilter.
10001 LOG(INFO) << "Adding framework " << *framework << " with roles "
10002 << stringify(allocatorOptions.suppressedRoles) << " suppressed";
10003
10004 frameworks.registered[framework->id()] = framework;
10005
10006 if (framework->connected()) {
10007 if (framework->pid().isSome()) {
10008 link(framework->pid().get());
10009 } else {
10010 CHECK_SOME(framework->http());
10011
10012 const StreamingHttpConnection<v1::scheduler::Event>& http =
10013 framework->http().get();
10014
10015 http.closed()
10016 .onAny(defer(self(), &Self::exited, framework->id(), http));
10017 }
10018 }
10019
10020 // There should be no offered resources yet!
10021 CHECK_EQ(Resources(), framework->totalOfferedResources);
10022
10023 allocator->addFramework(
10024 framework->id(),
10025 framework->info,
10026 framework->usedResources,
10027 framework->active(),
10028 std::move(allocatorOptions));
10029
10030 // Export framework metrics if a principal is specified in `FrameworkInfo`.
10031
10032 Option<string> principal = framework->info.has_principal()
10033 ? Option<string>(framework->info.principal())
10034 : None();
10035
10036 if (framework->pid().isSome()) {
10037 CHECK(!frameworks.principals.contains(framework->pid().get()));
10038 frameworks.principals.put(framework->pid().get(), principal);
10039 }
10040
10041 if (principal.isSome()) {
10042 // Create new framework metrics if this framework is the first
10043 // one of this principal. Otherwise existing metrics are reused.
10044 if (!metrics->frameworks.contains(principal.get())) {
10045 metrics->frameworks.put(
10046 principal.get(),
10047 Owned<Metrics::Frameworks>(
10048 new Metrics::Frameworks(principal.get())));

Callers 1

trackUnderRoleMethod · 0.45

Calls 14

deferFunction · 0.85
NoneClass · 0.85
activeMethod · 0.80
principalMethod · 0.80
connectedMethod · 0.65
stringifyFunction · 0.50
ResourcesClass · 0.50
containsMethod · 0.45
idMethod · 0.45
isSomeMethod · 0.45
pidMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected