| 9989 | |
| 9990 | |
| 9991 | void 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()))); |
no test coverage detected