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

Method initialize

src/master/allocator/mesos/hierarchical.cpp:621–672  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

619
620
621void HierarchicalAllocatorProcess::initialize(
622 const Options& _options,
623 const lambda::function<
624 void(const FrameworkID&,
625 const hashmap<string, hashmap<SlaveID, Resources>>&)>&
626 _offerCallback,
627 const lambda::function<
628 void(const FrameworkID&,
629 const hashmap<SlaveID, UnavailableResources>&)>&
630 _inverseOfferCallback)
631{
632 options = _options;
633 offerCallback = _offerCallback;
634 inverseOfferCallback = _inverseOfferCallback;
635 initialized = true;
636 paused = false;
637
638 completedFrameworkMetrics =
639 BoundedHashMap<FrameworkID, process::Owned<FrameworkMetrics>>(
640 options.maxCompletedFrameworks);
641
642 route("/offer_constraints_debug",
643 options.readonlyHttpAuthenticationRealm.getOrElse(""),
644 OFFER_CONSTRAINTS_DEBUG_HELP(),
645 [this](const process::http::Request& request,
646 const Option<Principal>& principal) {
647 logRequest(request);
648 return offerConstraintsDebug(request, principal)
649 .onReady([request](const process::http::Response& response) {
650 logResponse(request, response);
651 });
652 });
653
654 roleSorter->initialize(options.fairnessExcludeResourceNames);
655
656 VLOG(1) << "Initialized hierarchical allocator process";
657
658 // Start a loop to run allocation periodically.
659 PID<HierarchicalAllocatorProcess> _self = self();
660
661 // Set a temporary variable for the lambda capture.
662 Duration allocationInterval = options.allocationInterval;
663 loop(
664 None(), // Use `None` so we iterate outside the allocator process.
665 [allocationInterval]() {
666 return after(allocationInterval);
667 },
668 [_self](const Nothing&) {
669 return dispatch(_self, &HierarchicalAllocatorProcess::generateOffers)
670 .then([]() -> ControlFlow<Nothing> { return Continue(); });
671 });
672}
673
674
675void HierarchicalAllocatorProcess::recover(

Callers 1

Calls 10

logRequestFunction · 0.85
logResponseFunction · 0.85
loopFunction · 0.85
NoneClass · 0.85
getOrElseMethod · 0.80
afterFunction · 0.50
dispatchFunction · 0.50
ContinueClass · 0.50
thenMethod · 0.45

Tested by

no test coverage detected