17 #ifndef __MASTER_ALLOCATOR_MESOS_ALLOCATOR_HPP__
18 #define __MASTER_ALLOCATOR_MESOS_ALLOCATOR_HPP__
40 template <
typename AllocatorProcess>
51 const lambda::function<
52 void(
const FrameworkID&,
55 const lambda::function<
56 void(
const FrameworkID&,
59 const Option<std::set<std::string>>&
60 fairnessExcludeResourceNames =
None(),
61 bool filterGpuResources =
true,
65 const int expectedAgentCount,
69 const FrameworkID& frameworkId,
70 const FrameworkInfo& frameworkInfo,
73 const std::set<std::string>& suppressedRoles);
76 const FrameworkID& frameworkId);
79 const FrameworkID& frameworkId);
82 const FrameworkID& frameworkId);
85 const FrameworkID& frameworkId,
86 const FrameworkInfo& frameworkInfo,
87 const std::set<std::string>& suppressedRoles);
90 const SlaveID& slaveId,
91 const SlaveInfo& slaveInfo,
92 const std::vector<SlaveInfo::Capability>& capabilities,
98 const SlaveID& slaveId);
101 const SlaveID& slave,
102 const SlaveInfo& slaveInfo,
104 const Option<std::vector<SlaveInfo::Capability>>& capabilities =
None());
107 const SlaveID& slave,
112 const SlaveID& slaveId);
115 const SlaveID& slaveId);
121 const FrameworkID& frameworkId,
122 const std::vector<Request>& requests);
125 const FrameworkID& frameworkId,
126 const SlaveID& slaveId,
128 const std::vector<ResourceConversion>& conversions);
131 const SlaveID& slaveId,
132 const std::vector<Offer::Operation>& operations);
135 const SlaveID& slaveId,
139 const SlaveID& slaveId,
140 const FrameworkID& frameworkId,
151 const FrameworkID& frameworkId,
152 const SlaveID& slaveId,
157 const FrameworkID& frameworkId,
158 const std::set<std::string>& roles);
161 const FrameworkID& frameworkId,
162 const std::set<std::string>& roles);
165 const std::string& role,
169 const std::string& role);
172 const std::vector<WeightInfo>& weightInfos);
197 const lambda::function<
198 void(
const FrameworkID&,
201 const lambda::function<
202 void(
const FrameworkID&,
204 inverseOfferCallback,
205 const Option<std::set<std::string>>&
206 fairnessExcludeResourceNames =
None(),
207 bool filterGpuResources =
true,
211 const int expectedAgentCount,
215 const FrameworkID& frameworkId,
216 const FrameworkInfo& frameworkInfo,
219 const std::set<std::string>& suppressedRoles) = 0;
222 const FrameworkID& frameworkId) = 0;
225 const FrameworkID& frameworkId) = 0;
228 const FrameworkID& frameworkId) = 0;
231 const FrameworkID& frameworkId,
232 const FrameworkInfo& frameworkInfo,
233 const std::set<std::string>& suppressedRoles) = 0;
236 const SlaveID& slaveId,
237 const SlaveInfo& slaveInfo,
238 const std::vector<SlaveInfo::Capability>& capabilities,
244 const SlaveID& slaveId) = 0;
247 const SlaveID& slave,
248 const SlaveInfo& slaveInfo,
250 const Option<std::vector<SlaveInfo::Capability>>&
251 capabilities =
None()) = 0;
254 const SlaveID& slave,
259 const SlaveID& slaveId) = 0;
262 const SlaveID& slaveId) = 0;
268 const FrameworkID& frameworkId,
269 const std::vector<Request>& requests) = 0;
272 const FrameworkID& frameworkId,
273 const SlaveID& slaveId,
275 const std::vector<ResourceConversion>& conversions) = 0;
278 const SlaveID& slaveId,
279 const std::vector<Offer::Operation>& operations) = 0;
282 const SlaveID& slaveId,
286 const SlaveID& slaveId,
287 const FrameworkID& frameworkId,
298 const FrameworkID& frameworkId,
299 const SlaveID& slaveId,
304 const FrameworkID& frameworkId,
305 const std::set<std::string>& roles) = 0;
308 const FrameworkID& frameworkId,
309 const std::set<std::string>& roles) = 0;
312 const std::string& role,
313 const Quota& quota) = 0;
316 const std::string& role) = 0;
319 const std::vector<WeightInfo>& weightInfos) = 0;
323 template <
typename AllocatorProcess>
329 return CHECK_NOTNULL(allocator);
333 template <
typename AllocatorProcess>
336 process =
new AllocatorProcess();
341 template <
typename AllocatorProcess>
350 template <
typename AllocatorProcess>
353 const lambda::function<
354 void(
const FrameworkID&,
357 const lambda::function<
358 void(
const FrameworkID&,
360 inverseOfferCallback,
361 const Option<std::set<std::string>>& fairnessExcludeResourceNames,
362 bool filterGpuResources,
370 inverseOfferCallback,
371 fairnessExcludeResourceNames,
377 template <
typename AllocatorProcess>
379 const int expectedAgentCount,
390 template <
typename AllocatorProcess>
392 const FrameworkID& frameworkId,
393 const FrameworkInfo& frameworkInfo,
396 const std::set<std::string>& suppressedRoles)
409 template <
typename AllocatorProcess>
411 const FrameworkID& frameworkId)
420 template <
typename AllocatorProcess>
422 const FrameworkID& frameworkId)
431 template <
typename AllocatorProcess>
433 const FrameworkID& frameworkId)
442 template <
typename AllocatorProcess>
444 const FrameworkID& frameworkId,
445 const FrameworkInfo& frameworkInfo,
446 const std::set<std::string>& suppressedRoles)
457 template <
typename AllocatorProcess>
459 const SlaveID& slaveId,
460 const SlaveInfo& slaveInfo,
461 const std::vector<SlaveInfo::Capability>& capabilities,
478 template <
typename AllocatorProcess>
480 const SlaveID& slaveId)
489 template <
typename AllocatorProcess>
491 const SlaveID& slaveId,
492 const SlaveInfo& slaveInfo,
494 const Option<std::vector<SlaveInfo::Capability>>& capabilities)
505 template <
typename AllocatorProcess>
507 const SlaveID& slave,
520 template <
typename AllocatorProcess>
522 const SlaveID& slaveId)
531 template <
typename AllocatorProcess>
533 const SlaveID& slaveId)
542 template <
typename AllocatorProcess>
553 template <
typename AllocatorProcess>
555 const FrameworkID& frameworkId,
556 const std::vector<Request>& requests)
566 template <
typename AllocatorProcess>
568 const FrameworkID& frameworkId,
569 const SlaveID& slaveId,
571 const std::vector<ResourceConversion>& conversions)
583 template <
typename AllocatorProcess>
586 const SlaveID& slaveId,
587 const std::vector<Offer::Operation>& operations)
597 template <
typename AllocatorProcess>
599 const SlaveID& slaveId,
610 template <
typename AllocatorProcess>
612 const SlaveID& slaveId,
613 const FrameworkID& frameworkId,
623 unavailableResources,
629 template <
typename AllocatorProcess>
641 template <
typename AllocatorProcess>
643 const FrameworkID& frameworkId,
644 const SlaveID& slaveId,
658 template <
typename AllocatorProcess>
660 const FrameworkID& frameworkId,
661 const std::set<std::string>& roles)
671 template <
typename AllocatorProcess>
673 const FrameworkID& frameworkId,
674 const std::set<std::string>& roles)
684 template <
typename AllocatorProcess>
686 const std::string& role,
697 template <
typename AllocatorProcess>
699 const std::string& role)
708 template <
typename AllocatorProcess>
710 const std::vector<WeightInfo>& weightInfos)
723 #endif // __MASTER_ALLOCATOR_MESOS_ALLOCATOR_HPP__
virtual void deactivateSlave(const SlaveID &slaveId)=0
void activateFramework(const FrameworkID &frameworkId)
Activates a framework in the Mesos cluster.
Definition: allocator.hpp:421
virtual ~MesosAllocatorProcess()
Definition: allocator.hpp:189
virtual void requestResources(const FrameworkID &frameworkId, const std::vector< Request > &requests)=0
void setQuota(const std::string &role, const Quota "a)
Informs the allocator to set quota for the given role.
Definition: allocator.hpp:685
virtual void updateInverseOffer(const SlaveID &slaveId, const FrameworkID &frameworkId, const Option< UnavailableResources > &unavailableResources, const Option< mesos::allocator::InverseOfferStatus > &status, const Option< Filters > &filters=None())=0
Definition: option.hpp:28
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)
Adds or re-adds an agent to the Mesos cluster.
Definition: allocator.hpp:458
void removeFramework(const FrameworkID &frameworkId)
Removes a framework from the Mesos cluster.
Definition: allocator.hpp:410
virtual void addResourceProvider(const SlaveID &slave, const Resources &total, const hashmap< FrameworkID, Resources > &used)=0
virtual void recover(const int expectedAgentCount, const hashmap< std::string, Quota > "as)=0
virtual void deactivateFramework(const FrameworkID &frameworkId)=0
void updateAllocation(const FrameworkID &frameworkId, const SlaveID &slaveId, const Resources &offeredResources, const std::vector< ResourceConversion > &conversions)
Updates allocation by applying offer operations.
Definition: allocator.hpp:567
MesosAllocatorProcess()
Definition: allocator.hpp:187
void updateInverseOffer(const SlaveID &slaveId, const FrameworkID &frameworkId, const Option< UnavailableResources > &unavailableResources, const Option< mesos::allocator::InverseOfferStatus > &status, const Option< Filters > &filters)
Definition: allocator.hpp:611
void requestResources(const FrameworkID &frameworkId, const std::vector< Request > &requests)
Requests resources for a framework.
Definition: allocator.hpp:554
Result< ProcessStatus > status(pid_t pid)
Definition: proc.hpp:166
void addFramework(const FrameworkID &frameworkId, const FrameworkInfo &frameworkInfo, const hashmap< SlaveID, Resources > &used, bool active, const std::set< std::string > &suppressedRoles)
Adds a framework to the Mesos cluster.
Definition: allocator.hpp:391
virtual void setQuota(const std::string &role, const Quota "a)=0
Definition: resources.hpp:79
void updateFramework(const FrameworkID &frameworkId, const FrameworkInfo &frameworkInfo, const std::set< std::string > &suppressedRoles)
Updates capabilities of a framework in the Mesos cluster.
Definition: allocator.hpp:443
virtual 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)=0
virtual void activateFramework(const FrameworkID &frameworkId)=0
static Try< mesos::allocator::Allocator * > create()
Definition: allocator.hpp:325
UPID spawn(ProcessBase *process, bool manage=false)
Spawn a new process.
void updateWeights(const std::vector< WeightInfo > &weightInfos)
Updates the weight associated with one or more roles.
Definition: allocator.hpp:709
Definition: duration.hpp:32
Definition: allocator.hpp:41
void updateWhitelist(const Option< hashset< std::string >> &whitelist)
Updates the list of trusted agents.
Definition: allocator.hpp:543
void terminate(const UPID &pid, bool inject=true)
Sends a TerminateEvent to the given process.
void suppressOffers(const FrameworkID &frameworkId, const std::set< std::string > &roles)
Suppresses offers.
Definition: allocator.hpp:659
void deactivateSlave(const SlaveID &slaveId)
Deactivates an agent.
Definition: allocator.hpp:532
void reviveOffers(const FrameworkID &frameworkId, const std::set< std::string > &roles)
Revives offers to this framework for the specified roles.
Definition: allocator.hpp:672
Definition: hashmap.hpp:38
void dispatch(const PID< T > &pid, void(T::*method)())
Definition: dispatch.hpp:174
virtual void suppressOffers(const FrameworkID &frameworkId, const std::set< std::string > &roles)=0
virtual process::Future< hashmap< SlaveID, hashmap< FrameworkID, mesos::allocator::InverseOfferStatus > > > getInverseOfferStatuses()=0
Try< Nothing > unavailability(const Unavailability &unavailability)
Result< std::vector< Filter< Classifier > > > filters(const std::string &_link, const Handle &parent)
Definition: internal.hpp:776
virtual void activateSlave(const SlaveID &slaveId)=0
virtual void removeSlave(const SlaveID &slaveId)=0
virtual void initialize()
Invoked when a process gets spawned.
Definition: process.hpp:100
Definition: allocator.hpp:184
~MesosAllocator()
Definition: allocator.hpp:342
virtual void updateUnavailability(const SlaveID &slaveId, const Option< Unavailability > &unavailability)=0
virtual process::Future< Nothing > updateAvailable(const SlaveID &slaveId, const std::vector< Offer::Operation > &operations)=0
void recoverResources(const FrameworkID &frameworkId, const SlaveID &slaveId, const Resources &resources, const Option< Filters > &filters)
Recovers resources.
Definition: allocator.hpp:642
void updateUnavailability(const SlaveID &slaveId, const Option< Unavailability > &unavailability)
Updates unavailability for an agent.
Definition: allocator.hpp:598
virtual void reviveOffers(const FrameworkID &frameworkId, const std::set< std::string > &roles)=0
void addResourceProvider(const SlaveID &slave, const Resources &total, const hashmap< FrameworkID, Resources > &used)
Add resources from a local resource provider to an agent.
Definition: allocator.hpp:506
virtual void updateWeights(const std::vector< WeightInfo > &weightInfos)=0
virtual void updateFramework(const FrameworkID &frameworkId, const FrameworkInfo &frameworkInfo, const std::set< std::string > &suppressedRoles)=0
bool wait(const UPID &pid, const Duration &duration=Seconds(-1))
Wait for the process to exit for no more than the specified seconds.
virtual void updateWhitelist(const Option< hashset< std::string >> &whitelist)=0
void removeQuota(const std::string &role)
Informs the allocator to remove quota for the given role.
Definition: allocator.hpp:698
Basic model of an allocator: resources are allocated to a framework in the form of offers...
Definition: allocator.hpp:55
void removeSlave(const SlaveID &slaveId)
Removes an agent from the Mesos cluster.
Definition: allocator.hpp:479
Result< Process > process(pid_t pid)
Definition: freebsd.hpp:30
virtual void removeFramework(const FrameworkID &frameworkId)=0
void activateSlave(const SlaveID &slaveId)
Activates an agent.
Definition: allocator.hpp:521
virtual void updateSlave(const SlaveID &slave, const SlaveInfo &slaveInfo, const Option< Resources > &total=None(), const Option< std::vector< SlaveInfo::Capability >> &capabilities=None())=0
virtual void removeQuota(const std::string &role)=0
void initialize(const Duration &allocationInterval, const lambda::function< void(const FrameworkID &, const hashmap< std::string, hashmap< SlaveID, Resources >> &)> &offerCallback, const lambda::function< void(const FrameworkID &, const hashmap< SlaveID, UnavailableResources > &)> &inverseOfferCallback, const Option< std::set< std::string >> &fairnessExcludeResourceNames=None(), bool filterGpuResources=true, const Option< DomainInfo > &domain=None())
Initializes the allocator when the master starts up.
Definition: allocator.hpp:351
virtual void recoverResources(const FrameworkID &frameworkId, const SlaveID &slaveId, const Resources &resources, const Option< Filters > &filters)=0
void recover(const int expectedAgentCount, const hashmap< std::string, Quota > "as)
Informs the allocator of the recovered state from the master.
Definition: allocator.hpp:378
void deactivateFramework(const FrameworkID &frameworkId)
Deactivates a framework in the Mesos cluster.
Definition: allocator.hpp:432
virtual void addFramework(const FrameworkID &frameworkId, const FrameworkInfo &frameworkInfo, const hashmap< SlaveID, Resources > &used, bool active, const std::set< std::string > &suppressedRoles)=0
virtual void updateAllocation(const FrameworkID &frameworkId, const SlaveID &slaveId, const Resources &offeredResources, const std::vector< ResourceConversion > &conversions)=0
Definition: process.hpp:493
void updateSlave(const SlaveID &slave, const SlaveInfo &slaveInfo, const Option< Resources > &total=None(), const Option< std::vector< SlaveInfo::Capability >> &capabilities=None())
Updates an agent.
Definition: allocator.hpp:490
process::Future< Nothing > updateAvailable(const SlaveID &slaveId, const std::vector< Offer::Operation > &operations)
Updates available resources on an agent based on a sequence of offer operations.
Definition: allocator.hpp:585
process::Future< hashmap< SlaveID, hashmap< FrameworkID, mesos::allocator::InverseOfferStatus > > > getInverseOfferStatuses()
Retrieves the status of all inverse offers maintained by the allocator.
Definition: allocator.hpp:633