Apache Mesos
hierarchical.hpp
Go to the documentation of this file.
1 // Licensed to the Apache Software Foundation (ASF) under one
2 // or more contributor license agreements. See the NOTICE file
3 // distributed with this work for additional information
4 // regarding copyright ownership. The ASF licenses this file
5 // to you under the Apache License, Version 2.0 (the
6 // "License"); you may not use this file except in compliance
7 // with the License. You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 
17 #ifndef __MASTER_ALLOCATOR_MESOS_HIERARCHICAL_HPP__
18 #define __MASTER_ALLOCATOR_MESOS_HIERARCHICAL_HPP__
19 
20 #include <set>
21 #include <string>
22 
23 #include <mesos/mesos.hpp>
24 
25 #include <process/future.hpp>
26 #include <process/id.hpp>
27 #include <process/owned.hpp>
28 
29 #include <stout/boundedhashmap.hpp>
30 #include <stout/duration.hpp>
31 #include <stout/hashmap.hpp>
32 #include <stout/hashset.hpp>
33 #include <stout/lambda.hpp>
34 #include <stout/option.hpp>
35 
37 
40 
43 
44 #include "master/constants.hpp"
45 
46 namespace mesos {
47 namespace internal {
48 namespace master {
49 namespace allocator {
50 
51 // We forward declare the hierarchical allocator process so that we
52 // can typedef an instantiation of it with DRF sorters.
53 template <
54  typename RoleSorter,
55  typename FrameworkSorter,
56  typename QuotaRoleSorter>
58 
61 
64 
67 
70 
71 
72 namespace internal {
73 
74 // Forward declarations.
75 class OfferFilter;
76 class InverseOfferFilter;
77 
78 
79 // Implements the basic allocator algorithm - first pick a role by
80 // some criteria, then pick one of their frameworks to allocate to.
82 {
83 public:
85  const std::function<Sorter*()>& roleSorterFactory,
86  const std::function<Sorter*()>& _frameworkSorterFactory,
87  const std::function<Sorter*()>& quotaRoleSorterFactory)
88  : initialized(false),
89  paused(true),
90  metrics(*this),
92  roleSorter(roleSorterFactory()),
93  quotaRoleSorter(quotaRoleSorterFactory()),
94  frameworkSorterFactory(_frameworkSorterFactory) {}
95 
97 
99  {
100  return process::PID<Self>(this);
101  }
102 
103  void initialize(
105  const lambda::function<
106  void(const FrameworkID&,
107  const hashmap<std::string, hashmap<SlaveID, Resources>>&)>&
109  const lambda::function<
110  void(const FrameworkID&,
113  const Option<std::set<std::string>>&
115  bool filterGpuResources = true,
116  const Option<DomainInfo>& domain = None(),
117  const Option<std::vector<Resources>>&
119  const size_t maxCompletedFrameworks = 0) override;
120 
121  void recover(
122  const int _expectedAgentCount,
123  const hashmap<std::string, Quota>& quotas) override;
124 
125  void addFramework(
126  const FrameworkID& frameworkId,
127  const FrameworkInfo& frameworkInfo,
129  bool active,
130  const std::set<std::string>& suppressedRoles) override;
131 
132  void removeFramework(
133  const FrameworkID& frameworkId) override;
134 
135  void activateFramework(
136  const FrameworkID& frameworkId) override;
137 
138  void deactivateFramework(
139  const FrameworkID& frameworkId) override;
140 
141  void updateFramework(
142  const FrameworkID& frameworkId,
143  const FrameworkInfo& frameworkInfo,
144  const std::set<std::string>& suppressedRoles) override;
145 
146  void addSlave(
147  const SlaveID& slaveId,
148  const SlaveInfo& slaveInfo,
149  const std::vector<SlaveInfo::Capability>& capabilities,
151  const Resources& total,
152  const hashmap<FrameworkID, Resources>& used) override;
153 
154  void removeSlave(
155  const SlaveID& slaveId) override;
156 
157  void updateSlave(
158  const SlaveID& slave,
159  const SlaveInfo& slaveInfo,
160  const Option<Resources>& total = None(),
161  const Option<std::vector<SlaveInfo::Capability>>& capabilities = None())
162  override;
163 
164  void addResourceProvider(
165  const SlaveID& slave,
166  const Resources& total,
167  const hashmap<FrameworkID, Resources>& used) override;
168 
169  void deactivateSlave(
170  const SlaveID& slaveId) override;
171 
172  void activateSlave(
173  const SlaveID& slaveId) override;
174 
175  void updateWhitelist(
176  const Option<hashset<std::string>>& whitelist) override;
177 
178  void requestResources(
179  const FrameworkID& frameworkId,
180  const std::vector<Request>& requests) override;
181 
182  void updateAllocation(
183  const FrameworkID& frameworkId,
184  const SlaveID& slaveId,
185  const Resources& offeredResources,
186  const std::vector<ResourceConversion>& conversions) override;
187 
189  const SlaveID& slaveId,
190  const std::vector<Offer::Operation>& operations) override;
191 
193  const SlaveID& slaveId,
194  const Option<Unavailability>& unavailability) override;
195 
196  void updateInverseOffer(
197  const SlaveID& slaveId,
198  const FrameworkID& frameworkId,
199  const Option<UnavailableResources>& unavailableResources,
201  const Option<Filters>& filters) override;
202 
204  hashmap<SlaveID,
206  getInverseOfferStatuses() override;
207 
208  void recoverResources(
209  const FrameworkID& frameworkId,
210  const SlaveID& slaveId,
211  const Resources& resources,
212  const Option<Filters>& filters) override;
213 
214  void suppressOffers(
215  const FrameworkID& frameworkId,
216  const std::set<std::string>& roles) override;
217 
218  void reviveOffers(
219  const FrameworkID& frameworkId,
220  const std::set<std::string>& roles) override;
221 
222  void setQuota(
223  const std::string& role,
224  const Quota& quota) override;
225 
226  void removeQuota(
227  const std::string& role) override;
228 
229  void updateWeights(
230  const std::vector<WeightInfo>& weightInfos) override;
231 
232  void pause() override;
233 
234  void resume() override;
235 
236 protected:
237  // Useful typedefs for dispatch/delay/defer to self()/this.
240 
241  // Allocate any allocatable resources from all known agents.
243 
244  // Allocate resources from the specified agent.
245  process::Future<Nothing> allocate(const SlaveID& slaveId);
246 
247  // Allocate resources from the specified agents. The allocation
248  // is deferred and batched with other allocation requests.
250 
251  // Method that performs allocation work.
252  Nothing _allocate();
253 
254  // Helper for `_allocate()` that allocates resources for offers.
255  void __allocate();
256 
257  // Helper for `_allocate()` that deallocates resources for inverse offers.
258  void deallocate();
259 
260  // Remove an offer filter for the specified role of the framework.
261  void expire(
262  const FrameworkID& frameworkId,
263  const std::string& role,
264  const SlaveID& slaveId,
265  OfferFilter* offerFilter);
266 
267  void _expire(
268  const FrameworkID& frameworkId,
269  const std::string& role,
270  const SlaveID& slaveId,
271  OfferFilter* offerFilter);
272 
273  // Remove an inverse offer filter for the specified framework.
274  void expire(
275  const FrameworkID& frameworkId,
276  const SlaveID& slaveId,
277  InverseOfferFilter* inverseOfferFilter);
278 
279  // Checks whether the slave is whitelisted.
280  bool isWhitelisted(const SlaveID& slaveId) const;
281 
282  // Returns true if there is a resource offer filter for the
283  // specified role of this framework on this slave.
284  bool isFiltered(
285  const FrameworkID& frameworkId,
286  const std::string& role,
287  const SlaveID& slaveId,
288  const Resources& resources) const;
289 
290  // Returns true if there is an inverse offer filter for this framework
291  // on this slave.
292  bool isFiltered(
293  const FrameworkID& frameworkID,
294  const SlaveID& slaveID) const;
295 
296  bool allocatable(const Resources& resources);
297 
299  bool paused;
300 
301  // Recovery data.
303 
305 
306  lambda::function<
307  void(const FrameworkID&,
308  const hashmap<std::string, hashmap<SlaveID, Resources>>&)>
310 
311  lambda::function<
312  void(const FrameworkID&,
315 
316  friend Metrics;
318 
319  // TODO(mzhu): Pull out the nested Framework struct for clearer
320  // logic division with the allocator.
321  struct Framework
322  {
323  Framework(
324  const FrameworkInfo& frameworkInfo,
325  const std::set<std::string>& suppressedRoles,
326  bool active);
327 
328  std::set<std::string> roles;
329 
330  std::set<std::string> suppressedRoles;
331 
333 
334  // Active offer and inverse offer filters for the framework.
335  // Offer filters are tied to the role the filtered resources
336  // were allocated to.
339 
340  bool active;
341 
343  };
344 
346  {
347  return static_cast<double>(eventCount<process::DispatchEvent>());
348  }
349 
350  double _resources_total(
351  const std::string& resource);
352 
354  const std::string& resource);
355 
356  double _quota_allocated(
357  const std::string& role,
358  const std::string& resource);
359 
360  double _offer_filters_active(
361  const std::string& role);
362 
364 
367 
368  // TODO(mzhu): Pull out the nested Slave class for clearer
369  // logic division with the allocator.
370  class Slave
371  {
372  public:
374  const SlaveInfo& _info,
375  const protobuf::slave::Capabilities& _capabilities,
376  bool _activated,
377  const Resources& _total,
378  const Resources& _allocated)
379  : info(_info),
380  capabilities(_capabilities),
381  activated(_activated),
382  total(_total),
383  allocated(_allocated),
384  shared(_total.shared())
385  {
386  updateAvailable();
387  }
388 
389  const Resources& getTotal() const { return total; }
390 
391  const Resources& getAllocated() const { return allocated; }
392 
393  const Resources& getAvailable() const { return available; }
394 
395  void updateTotal(const Resources& newTotal) {
396  total = newTotal;
397  shared = total.shared();
398 
399  updateAvailable();
400  }
401 
402  void allocate(const Resources& toAllocate)
403  {
404  allocated += toAllocate;
405 
406  updateAvailable();
407  }
408 
409  void unallocate(const Resources& toUnallocate)
410  {
411  allocated -= toUnallocate;
412 
413  updateAvailable();
414  }
415 
416  // The `SlaveInfo` that was passed to the allocator when the slave was added
417  // or updated. Currently only two fields are used: `hostname` for host
418  // whitelisting and in log messages, and `domain` for region-aware
419  // scheduling.
420  SlaveInfo info;
421 
423 
424  bool activated; // Whether to offer resources.
425 
426  // Represents a scheduled unavailability due to maintenance for a specific
427  // slave, and the responses from frameworks as to whether they will be able
428  // to gracefully handle this unavailability.
429  //
430  // NOTE: We currently implement maintenance in the allocator to be able to
431  // leverage state and features such as the FrameworkSorter and OfferFilter.
432  struct Maintenance
433  {
434  Maintenance(const Unavailability& _unavailability)
435  : unavailability(_unavailability) {}
436 
437  // The start time and optional duration of the event.
438  Unavailability unavailability;
439 
440  // A mapping of frameworks to the inverse offer status associated with
441  // this unavailability.
442  //
443  // NOTE: We currently lose this information during a master fail over
444  // since it is not persisted or replicated. This is ok as the new master's
445  // allocator will send out new inverse offers and re-collect the
446  // information. This is similar to all the outstanding offers from an old
447  // master being invalidated, and new offers being sent out.
449 
450  // Represents the "unit of accounting" for maintenance. When a
451  // `FrameworkID` is present in the hashset it means an inverse offer has
452  // been sent out. When it is not present it means no offer is currently
453  // outstanding.
455  };
456 
457  // When the `maintenance` is set the slave is scheduled to be unavailable at
458  // a given point in time, for an optional duration. This information is used
459  // to send out `InverseOffers`.
461 
462  private:
463  void updateAvailable() {
464  // In order to subtract from the total,
465  // we strip the allocation information.
466  Resources allocated_ = allocated;
467  allocated_.unallocate();
468 
469  // Calling `nonShared()` currently copies the underlying resources
470  // and is therefore rather expensive. We avoid it in the common
471  // case that there are no shared resources.
472  //
473  // TODO(mzhu): Ideally there would be a single logical path here.
474  // One solution is to have `Resources` be copy-on-write such that
475  // `nonShared()` performs no copying and instead points to a
476  // subset of the original `Resource` objects.
477  if (shared.empty()) {
478  available = total - allocated_;
479  } else {
480  // Since shared resources are offerable even when they are in use, we
481  // always include them as part of available resources.
482  available = (total.nonShared() - allocated_.nonShared()) + shared;
483  }
484  }
485 
486  // Total amount of regular *and* oversubscribed resources.
487  Resources total;
488 
489  // Regular *and* oversubscribed resources that are allocated.
490  //
491  // NOTE: We maintain multiple copies of each shared resource allocated
492  // to a slave, where the number of copies represents the number of times
493  // this shared resource has been allocated to (and has not been recovered
494  // from) a specific framework.
495  //
496  // NOTE: We keep track of the slave's allocated resources despite
497  // having that information in sorters. This is because the
498  // information in sorters is not accurate if some framework
499  // hasn't reregistered. See MESOS-2919 for details.
500  Resources allocated;
501 
502  // We track the total and allocated resources on the slave to
503  // avoid calculating it in place every time.
504  //
505  // Note that `available` always contains all the shared resources on the
506  // agent regardless whether they have ever been allocated or not.
507  // NOTE, however, we currently only offer a shared resource only if it has
508  // not been offered in an allocation cycle to a framework. We do this mainly
509  // to preserve the normal offer behavior. This may change in the future
510  // depending on use cases.
511  //
512  // Note that it's possible for the slave to be over-allocated!
513  // In this case, allocated > total.
514  Resources available;
515 
516  // We keep a copy of the shared resources to avoid unnecessary copying.
517  Resources shared;
518  };
519 
521 
522  // A set of agents that are kept as allocation candidates. Events
523  // may add or remove candidates to the set. When an allocation is
524  // processed, the set of candidates is cleared.
526 
527  // Future for the dispatched allocation that becomes
528  // ready after the allocation run is complete.
530 
531  // We track information about roles that we're aware of in the system.
532  // Specifically, we keep track of the roles when a framework subscribes to
533  // the role, and/or when there are resources allocated to the role
534  // (e.g. some tasks and/or executors are consuming resources under the role).
536 
537  // Configured quota for each role, if any. If a role does not have
538  // an entry here it has the default quota of (no guarantee, no limit).
540 
541  // Aggregated resource reservations on all agents tied to a
542  // particular role, if any. These are stripped scalar quantities
543  // that contain no meta-data.
544  //
545  // Only roles with non-empty reservations will be stored in the map.
547 
548  // Slaves to send offers for.
550 
551  // Resources (by name) that will be excluded from a role's fair share.
553 
554  // Filter GPU resources based on the `GPU_RESOURCES` framework capability.
556 
557  // The master's domain, if any.
559 
560  // The minimum allocatable resources, if any.
562 
563  // There are two stages of allocation:
564  //
565  // Stage 1: Allocate to satisfy quota guarantees.
566  //
567  // Stage 2: Allocate above quota guarantees up to quota limits.
568  // Note that we need to hold back enough "headroom"
569  // to ensure that any unsatisfied quota can be
570  // satisfied later.
571  //
572  // Each stage comprises two levels of sorting, hence "hierarchical".
573  // Level 1 sorts across roles:
574  // Currently, only the allocated portion of the reserved resources are
575  // accounted for fairness calculation.
576  //
577  // TODO(mpark): Reserved resources should be accounted for fairness
578  // calculation whether they are allocated or not, since they model a long or
579  // forever running task. That is, the effect of reserving resources is
580  // equivalent to launching a task in that the resources that make up the
581  // reservation are not available to other roles as non-revocable.
582  //
583  // Level 2 sorts across frameworks within a particular role:
584  // Reserved resources at this level are, and should be accounted for
585  // fairness calculation only if they are allocated. This is because
586  // reserved resources are fairly shared across the frameworks in the role.
587  //
588  // The allocator relies on `Sorter`s to employ a particular sorting
589  // algorithm. Each level has its own sorter and hence may have different
590  // fairness calculations.
591  //
592  // NOTE: The hierarchical allocator considers revocable resources as
593  // regular resources when doing fairness calculations.
594  //
595  // TODO(vinod): Consider using a different fairness algorithm for
596  // revocable resources.
597 
598  // A sorter for active roles. This sorter determines the order in which
599  // roles are allocated resources during Level 1 of the second stage.
600  // The total cluster resources are used as the resource pool.
602 
603  // TODO(bmahler): Remove this in favor of either using the same sorting
604  // between satisfying guarantees and bursting above guarantees up to
605  // limits, or have a different sorting technique specifically for
606  // satisfying guarantees (e.g. MESOS-8026). This is tech debt from
607  // when a "quota role" was considered different from a "non-quota"
608  // role. However, they are the same, one just has a default quota.
609  //
610  // A dedicated sorter for roles that have a non-default quota.
611  // This sorter determines the order in which guarantees are allocated
612  // during Level 1 of the first stage. Since only non-revocable
613  // resources are available for quota, the total cluster non-revocable
614  // resources are used as the resource pool.
615  //
616  // NOTE: A role appears in `quotaRoleSorter` if it has a non-default
617  // quota (even if no frameworks are currently registered in that role).
618  // In contrast, `roleSorter` only contains entries for roles with one
619  // or more registered frameworks.
621 
622  // A collection of sorters, one per active role. Each sorter determines
623  // the order in which frameworks that belong to the same role are allocated
624  // resources inside the role's share. These sorters are used during Level 2
625  // for both the first and the second stages. Since frameworks are sharing
626  // the resources allocated to a role, the role's allocation is used as
627  // the resource pool for each role specific framework sorter.
629 
630  // Factory function for framework sorters.
631  const std::function<Sorter*()> frameworkSorterFactory;
632 
633 private:
634  bool isFrameworkTrackedUnderRole(
635  const FrameworkID& frameworkId,
636  const std::string& role) const;
637 
638  void trackFrameworkUnderRole(
639  const FrameworkID& frameworkId,
640  const std::string& role);
641 
642  void untrackFrameworkUnderRole(
643  const FrameworkID& frameworkId,
644  const std::string& role);
645 
646  // `trackReservations` and `untrackReservations` are helpers
647  // to track role resource reservations. We need to keep
648  // track of reservations to enforce role quota limit
649  // in the presence of unallocated reservations. See MESOS-4527.
650  //
651  // TODO(mzhu): Ideally, we want these helpers to instead track the
652  // reservations as *allocated* in the sorters even when the
653  // reservations have not been allocated yet. This will help to:
654  //
655  // (1) Solve the fairness issue when roles with unallocated
656  // reservations may game the allocator (See MESOS-8299).
657  //
658  // (2) Simplify the quota enforcement logic -- the allocator
659  // would no longer need to track reservations separately.
660  void trackReservations(
661  const hashmap<std::string, Resources>& reservations);
662 
663  void untrackReservations(
664  const hashmap<std::string, Resources>& reservations);
665 
666  // Helper to update the agent's total resources maintained in the allocator
667  // and the role and quota sorters (whose total resources match the agent's
668  // total resources). Returns true iff the stored agent total was changed.
669  bool updateSlaveTotal(const SlaveID& slaveId, const Resources& total);
670 
671  // Helper that returns true if the given agent is located in a
672  // different region than the master. This can only be the case if
673  // the agent and the master are both configured with a fault domain.
674  bool isRemoteSlave(const Slave& slave) const;
675 
676  // Helper function that checks if a framework is capable of
677  // receiving resources on the agent based on the framework capability.
678  //
679  // TODO(mzhu): Make this a `Framework` member function once we pull
680  // `struct Framework` out from being nested.
681  bool isCapableOfReceivingAgent(
682  const protobuf::framework::Capabilities& frameworkCapabilities,
683  const Slave& slave) const;
684 
685  // Helper function that removes any resources that the framework is not
686  // capable of receiving based on the given framework capability.
687  //
688  // TODO(mzhu): Make this a `Framework` member function once we pull
689  // `struct Framework` out from being nested.
690  Resources stripIncapableResources(
691  const Resources& resources,
692  const protobuf::framework::Capabilities& frameworkCapabilities) const;
693 
694  // Helper to track allocated resources on an agent.
695  void trackAllocatedResources(
696  const SlaveID& slaveId,
697  const FrameworkID& frameworkId,
698  const Resources& allocated);
699 
700  // Helper to untrack resources that are no longer allocated on an agent.
701  void untrackAllocatedResources(
702  const SlaveID& slaveId,
703  const FrameworkID& frameworkId,
704  const Resources& allocated);
705 
706  // Helper that removes all existing offer filters for the given slave
707  // id.
708  void removeFilters(const SlaveID& slaveId);
709 };
710 
711 
712 } // namespace internal {
713 
714 
715 // We map the templatized version of the `HierarchicalAllocatorProcess` to one
716 // that relies on sorter factories in the internal namespace. This allows us
717 // to keep the implementation of the allocator in the implementation file.
718 template <
719  typename RoleSorter,
720  typename FrameworkSorter,
721  typename QuotaRoleSorter>
724 {
725 public:
727  : ProcessBase(process::ID::generate("hierarchical-allocator")),
729  [this]() -> Sorter* {
730  return new RoleSorter(this->self(), "allocator/mesos/roles/");
731  },
732  []() -> Sorter* { return new FrameworkSorter(); },
733  []() -> Sorter* { return new QuotaRoleSorter(); }) {}
734 };
735 
736 } // namespace allocator {
737 } // namespace master {
738 } // namespace internal {
739 } // namespace mesos {
740 
741 #endif // __MASTER_ALLOCATOR_MESOS_HIERARCHICAL_HPP__
Option< process::Future< Nothing > > allocation
Definition: hierarchical.hpp:529
void addResourceProvider(const SlaveID &slave, const Resources &total, const hashmap< FrameworkID, Resources > &used) override
HierarchicalAllocatorProcess< DRFSorter, DRFSorter, DRFSorter > HierarchicalDRFAllocatorProcess
Definition: hierarchical.hpp:57
std::string generate(const std::string &prefix="")
Returns &#39;prefix(N)&#39; where N represents the number of instances where the same prefix (wrt...
void unallocate(const Resources &toUnallocate)
Definition: hierarchical.hpp:409
Definition: nothing.hpp:16
void updateUnavailability(const SlaveID &slaveId, const Option< Unavailability > &unavailability) override
Definition: option.hpp:28
void updateInverseOffer(const SlaveID &slaveId, const FrameworkID &frameworkId, const Option< UnavailableResources > &unavailableResources, const Option< mesos::allocator::InverseOfferStatus > &status, const Option< Filters > &filters) override
void addSlave(const SlaveID &slaveId, const SlaveInfo &slaveInfo, const std::vector< SlaveInfo::Capability > &capabilities, const Option< Unavailability > &unavailability, const Resources &total, const hashmap< FrameworkID, Resources > &used) override
hashmap< std::string, hashmap< SlaveID, hashset< OfferFilter * > > > offerFilters
Definition: hierarchical.hpp:337
ProcessBase(const std::string &id="")
void _expire(const FrameworkID &frameworkId, const std::string &role, const SlaveID &slaveId, OfferFilter *offerFilter)
Definition: master.hpp:27
void updateWeights(const std::vector< WeightInfo > &weightInfos) override
hashmap< std::string, process::Owned< Sorter > > frameworkSorters
Definition: hierarchical.hpp:628
BoundedHashMap< FrameworkID, process::Owned< FrameworkMetrics > > completedFrameworkMetrics
Definition: hierarchical.hpp:366
Definition: protobuf_utils.hpp:261
hashmap< SlaveID, hashset< InverseOfferFilter * > > inverseOfferFilters
Definition: hierarchical.hpp:338
HierarchicalAllocatorProcess< RandomSorter, RandomSorter, RandomSorter > HierarchicalRandomAllocatorProcess
Definition: hierarchical.hpp:66
protobuf::slave::Capabilities capabilities
Definition: hierarchical.hpp:422
Result< ProcessStatus > status(pid_t pid)
Definition: proc.hpp:166
Option< int > expectedAgentCount
Definition: hierarchical.hpp:302
Definition: resources.hpp:81
void updateFramework(const FrameworkID &frameworkId, const FrameworkInfo &frameworkInfo, const std::set< std::string > &suppressedRoles) override
void activateFramework(const FrameworkID &frameworkId) override
~HierarchicalAllocatorProcess() override
Definition: hierarchical.hpp:96
hashmap< SlaveID, Slave > slaves
Definition: hierarchical.hpp:520
MesosAllocator< HierarchicalRandomAllocatorProcess > HierarchicalRandomAllocator
Definition: hierarchical.hpp:69
process::Owned< FrameworkMetrics > metrics
Definition: hierarchical.hpp:342
Definition: duration.hpp:32
bool isFiltered(const FrameworkID &frameworkId, const std::string &role, const SlaveID &slaveId, const Resources &resources) const
process::Owned< Sorter > quotaRoleSorter
Definition: hierarchical.hpp:620
const Resources & getAllocated() const
Definition: hierarchical.hpp:391
MesosAllocator< HierarchicalDRFAllocatorProcess > HierarchicalDRFAllocator
Definition: hierarchical.hpp:63
void updateWhitelist(const Option< hashset< std::string >> &whitelist) override
const std::function< Sorter *()> frameworkSorterFactory
Definition: hierarchical.hpp:631
Definition: hashmap.hpp:38
Option< Maintenance > maintenance
Definition: hierarchical.hpp:460
Definition: quota.hpp:25
lambda::function< void(const FrameworkID &, const hashmap< std::string, hashmap< SlaveID, Resources >> &)> offerCallback
Definition: hierarchical.hpp:309
void addFramework(const FrameworkID &frameworkId, const FrameworkInfo &frameworkInfo, const hashmap< SlaveID, Resources > &used, bool active, const std::set< std::string > &suppressedRoles) override
Try< Nothing > unavailability(const Unavailability &unavailability)
process::Owned< Sorter > roleSorter
Definition: hierarchical.hpp:601
Try< Bytes > used(const std::string &path="/")
Definition: fs.hpp:43
void expire(const FrameworkID &frameworkId, const std::string &role, const SlaveID &slaveId, OfferFilter *offerFilter)
Result< std::vector< Filter< Classifier > > > filters(const std::string &_link, const Handle &parent)
Definition: internal.hpp:769
hashmap< FrameworkID, mesos::allocator::InverseOfferStatus > statuses
Definition: hierarchical.hpp:448
void reviveOffers(const FrameworkID &frameworkId, const std::set< std::string > &roles) override
virtual void initialize()
Invoked when a process gets spawned.
Definition: process.hpp:100
Definition: protobuf_utils.hpp:455
void requestResources(const FrameworkID &frameworkId, const std::vector< Request > &requests) override
Definition: spec.hpp:26
Framework(const FrameworkInfo &frameworkInfo, const std::set< std::string > &suppressedRoles, bool active)
hashmap< FrameworkID, Framework > frameworks
Definition: hierarchical.hpp:363
HierarchicalAllocatorProcess(const std::function< Sorter *()> &roleSorterFactory, const std::function< Sorter *()> &_frameworkSorterFactory, const std::function< Sorter *()> &quotaRoleSorterFactory)
Definition: hierarchical.hpp:84
std::set< std::string > suppressedRoles
Definition: hierarchical.hpp:330
void suppressOffers(const FrameworkID &frameworkId, const std::set< std::string > &roles) override
Option< std::set< std::string > > fairnessExcludeResourceNames
Definition: hierarchical.hpp:552
Option< hashset< std::string > > whitelist
Definition: hierarchical.hpp:549
void updateTotal(const Resources &newTotal)
Definition: hierarchical.hpp:395
hashmap< std::string, hashset< FrameworkID > > roles
Definition: hierarchical.hpp:535
Option< DomainInfo > domain
Definition: hierarchical.hpp:558
hashset< SlaveID > allocationCandidates
Definition: hierarchical.hpp:525
Definition: boundedhashmap.hpp:27
void updateSlave(const SlaveID &slave, const SlaveInfo &slaveInfo, const Option< Resources > &total=None(), const Option< std::vector< SlaveInfo::Capability >> &capabilities=None()) override
A "process identifier" used to uniquely identify a process when dispatching messages.
Definition: pid.hpp:279
Resources shared() const
process::Future< Nothing > updateAvailable(const SlaveID &slaveId, const std::vector< Offer::Operation > &operations) override
Definition: none.hpp:27
Definition: attributes.hpp:24
Resources nonShared() const
Definition: executor.hpp:48
void setQuota(const std::string &role, const Quota &quota) override
double _quota_allocated(const std::string &role, const std::string &resource)
const Resources & getTotal() const
Definition: hierarchical.hpp:389
HierarchicalAllocatorProcess This
Definition: hierarchical.hpp:239
void updateAllocation(const FrameworkID &frameworkId, const SlaveID &slaveId, const Resources &offeredResources, const std::vector< ResourceConversion > &conversions) override
process::Future< hashmap< SlaveID, hashmap< FrameworkID, mesos::allocator::InverseOfferStatus > > > getInverseOfferStatuses() override
void removeFramework(const FrameworkID &frameworkId) override
HierarchicalAllocatorProcess Self
Definition: hierarchical.hpp:238
protobuf::framework::Capabilities capabilities
Definition: hierarchical.hpp:332
Definition: owned.hpp:36
hashmap< std::string, Quota > quotas
Definition: hierarchical.hpp:539
const Resources & getAvailable() const
Definition: hierarchical.hpp:393
void allocate(const Resources &toAllocate)
Definition: hierarchical.hpp:402
Slave(const SlaveInfo &_info, const protobuf::slave::Capabilities &_capabilities, bool _activated, const Resources &_total, const Resources &_allocated)
Definition: hierarchical.hpp:373
Maintenance(const Unavailability &_unavailability)
Definition: hierarchical.hpp:434
void recover(const int _expectedAgentCount, const hashmap< std::string, Quota > &quotas) override
void recoverResources(const FrameworkID &frameworkId, const SlaveID &slaveId, const Resources &resources, const Option< Filters > &filters) override
void deactivateFramework(const FrameworkID &frameworkId) override
hashmap< std::string, Resources > reservationScalarQuantities
Definition: hierarchical.hpp:546
lambda::function< void(const FrameworkID &, const hashmap< SlaveID, UnavailableResources > &)> inverseOfferCallback
Definition: hierarchical.hpp:314
Option< std::vector< Resources > > minAllocatableResources
Definition: hierarchical.hpp:561