17 #ifndef __MASTER_ALLOCATOR_SORTER_DRF_SORTER_HPP__
18 #define __MASTER_ALLOCATOR_SORTER_DRF_SORTER_HPP__
50 const std::string& metricsPrefix);
55 const Option<std::set<std::string>>& fairnessExcludeResourceNames);
57 virtual void add(
const std::string& clientPath);
59 virtual void remove(
const std::string& clientPath);
61 virtual void activate(
const std::string& clientPath);
63 virtual void deactivate(
const std::string& clientPath);
65 virtual void updateWeight(
const std::string& path,
double weight);
68 const std::string& clientPath,
69 const SlaveID& slaveId,
73 const std::string& clientPath,
74 const SlaveID& slaveId,
79 const std::string& clientPath,
80 const SlaveID& slaveId,
84 const std::string& clientPath)
const;
87 const std::string& clientPath)
const;
90 const SlaveID& slaveId)
const;
93 const std::string& clientPath,
94 const SlaveID& slaveId)
const;
98 virtual void add(
const SlaveID& slaveId,
const Resources& resources);
100 virtual void remove(
const SlaveID& slaveId,
const Resources& resources);
102 virtual std::vector<std::string>
sort();
104 virtual bool contains(
const std::string& clientPath)
const;
106 virtual size_t count()
const;
113 double calculateShare(
const Node* node)
const;
118 double findWeight(
const Node* node)
const;
123 Node*
find(
const std::string& clientPath)
const;
277 return CHECK_NOTNULL(
parent)->path;
329 .
filter([
this, slaveId](
const Resource& resource) {
330 return !
resources[slaveId].contains(resource);
334 (toAdd.
nonShared() + sharedToAdd).createStrippedScalarQuantity();
339 foreach (
const Resource& resource, quantitiesToAdd) {
340 totals[resource.name()] += resource.scalar();
349 CHECK(
resources.at(slaveId).contains(toRemove))
350 <<
"Resources " <<
resources.at(slaveId) <<
" at agent " << slaveId
351 <<
" does not contain " << toRemove;
358 .
filter([
this, slaveId](
const Resource& resource) {
359 return !
resources[slaveId].contains(resource);
363 (toRemove.nonShared() + sharedToRemove).createStrippedScalarQuantity();
365 foreach (
const Resource& resource, quantitiesToRemove) {
366 totals[resource.name()] -= resource.scalar();
380 const SlaveID& slaveId,
391 <<
"Resources " <<
resources[slaveId] <<
" at agent " << slaveId
392 <<
" does not contain " << oldAllocation;
398 resources[slaveId] += newAllocation;
403 foreach (
const Resource& resource, oldAllocationQuantity) {
404 totals[resource.name()] -= resource.scalar();
407 foreach (
const Resource& resource, newAllocationQuantity) {
408 totals[resource.name()] += resource.scalar();
462 #endif // __MASTER_ALLOCATOR_SORTER_DRF_SORTER_HPP__
Node(const std::string &_name, Kind _kind, Node *_parent)
Definition: sorter.hpp:209
Definition: option.hpp:28
bool isLeaf() const
Definition: sorter.hpp:283
double share
Definition: sorter.hpp:244
std::stringstream & join(std::stringstream &stream, const std::string &separator, T &&...args)
Definition: strings.hpp:306
std::string clientPath() const
Definition: sorter.hpp:273
std::vector< Node * > children
Definition: sorter.hpp:262
void add(const SlaveID &slaveId, const Resources &toAdd)
Definition: sorter.hpp:324
std::string path
Definition: sorter.hpp:242
Resources scalarQuantities
Definition: sorter.hpp:430
Resources filter(const lambda::function< bool(const Resource &)> &predicate) const
Definition: resources.hpp:79
virtual std::vector< std::string > sort()
uint64_t count
Definition: sorter.hpp:419
Allocation()
Definition: sorter.hpp:322
Definition: sorter.hpp:320
std::string name
Definition: sorter.hpp:238
virtual void update(const std::string &clientPath, const SlaveID &slaveId, const Resources &oldAllocation, const Resources &newAllocation)
virtual void deactivate(const std::string &clientPath)
Definition: hashmap.hpp:38
Kind
Definition: sorter.hpp:202
Definition: metrics.hpp:35
hashmap< SlaveID, Resources > resources
Definition: sorter.hpp:425
struct mesos::internal::master::allocator::DRFSorter::Node::Allocation allocation
An "untyped" PID, used to encapsulate the process ID for lower-layer abstractions (eg...
Definition: pid.hpp:39
void subtract(const SlaveID &slaveId, const Resources &toRemove)
Definition: sorter.hpp:346
void removeChild(const Node *child)
Definition: sorter.hpp:293
virtual const Resources & totalScalarQuantities() const
Resources createStrippedScalarQuantity() const
Node * parent
Definition: sorter.hpp:248
Definition: sorter.hpp:204
virtual const Resources & allocationScalarQuantities(const std::string &clientPath) const
Definition: sorter.hpp:196
virtual void unallocated(const std::string &clientPath, const SlaveID &slaveId, const Resources &resources)
hashmap< std::string, Value::Scalar > totals
Definition: sorter.hpp:439
Definition: sorter.hpp:206
static bool compareDRF(const Node *left, const Node *right)
Definition: sorter.hpp:443
Definition: sorter.hpp:43
virtual void allocated(const std::string &clientPath, const SlaveID &slaveId, const Resources &resources)
virtual void add(const std::string &clientPath)
Definition: sorter.hpp:205
Resources nonShared() const
Definition: sorter.hpp:41
virtual size_t count() const
virtual bool contains(const std::string &clientPath) const
Kind kind
Definition: sorter.hpp:246
virtual void initialize(const Option< std::set< std::string >> &fairnessExcludeResourceNames)
virtual const hashmap< SlaveID, Resources > & allocation(const std::string &clientPath) const
bool contains(const Resources &that) const
void addChild(Node *child)
Definition: sorter.hpp:302
void update(const SlaveID &slaveId, const Resources &oldAllocation, const Resources &newAllocation)
Definition: sorter.hpp:379
Try< std::list< std::string > > find(const std::string &directory, const std::string &pattern)
Definition: find.hpp:37
virtual void activate(const std::string &clientPath)
~Node()
Definition: sorter.hpp:226
virtual void updateWeight(const std::string &path, double weight)