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&,
58 inverseOfferCallback)
override;
61 const int expectedAgentCount,
65 const FrameworkID& frameworkId,
66 const FrameworkInfo& frameworkInfo,
72 const FrameworkID& frameworkId)
override;
75 const FrameworkID& frameworkId)
override;
78 const FrameworkID& frameworkId)
override;
81 const FrameworkID& frameworkId,
82 const FrameworkInfo& frameworkInfo,
86 const SlaveID& slaveId,
87 const SlaveInfo& slaveInfo,
88 const std::vector<SlaveInfo::Capability>& capabilities,
94 const SlaveID& slaveId)
override;
98 const SlaveInfo& slaveInfo,
100 const Option<std::vector<SlaveInfo::Capability>>& capabilities =
None())
104 const SlaveID& slave,
109 const SlaveID& slaveId)
override;
112 const SlaveID& slaveId)
override;
118 const FrameworkID& frameworkId,
119 const std::vector<Request>& requests)
override;
122 const FrameworkID& frameworkId,
123 const SlaveID& slaveId,
125 const std::vector<ResourceConversion>& conversions)
override;
128 const SlaveID& slaveId,
129 const std::vector<Offer::Operation>& operations)
override;
132 const SlaveID& slaveId,
136 const SlaveID& slaveId,
137 const FrameworkID& frameworkId,
148 const SlaveID& slaveId,
const Resources& resources)
override;
151 const FrameworkID& frameworkId,
152 const SlaveID& slaveId,
155 bool isAllocated)
override;
158 const FrameworkID& frameworkId,
159 const std::set<std::string>& roles)
override;
162 const FrameworkID& frameworkId,
163 const std::set<std::string>& roles)
override;
166 const std::string& role,
167 const Quota& quota)
override;
170 const std::vector<WeightInfo>& weightInfos)
override;
172 void pause()
override;
199 const lambda::function<
200 void(
const FrameworkID&,
203 const lambda::function<
204 void(
const FrameworkID&,
206 inverseOfferCallback) = 0;
209 const int expectedAgentCount,
213 const FrameworkID& frameworkId,
214 const FrameworkInfo& frameworkInfo,
220 const FrameworkID& frameworkId) = 0;
223 const FrameworkID& frameworkId) = 0;
226 const FrameworkID& frameworkId) = 0;
229 const FrameworkID& frameworkId,
230 const FrameworkInfo& frameworkInfo,
234 const SlaveID& slaveId,
235 const SlaveInfo& slaveInfo,
236 const std::vector<SlaveInfo::Capability>& capabilities,
242 const SlaveID& slaveId) = 0;
245 const SlaveID& slave,
246 const SlaveInfo& slaveInfo,
248 const Option<std::vector<SlaveInfo::Capability>>&
249 capabilities =
None()) = 0;
252 const SlaveID& slave,
257 const SlaveID& slaveId) = 0;
260 const SlaveID& slaveId) = 0;
266 const FrameworkID& frameworkId,
267 const std::vector<Request>& requests) = 0;
270 const FrameworkID& frameworkId,
271 const SlaveID& slaveId,
273 const std::vector<ResourceConversion>& conversions) = 0;
276 const SlaveID& slaveId,
277 const std::vector<Offer::Operation>& operations) = 0;
280 const SlaveID& slaveId,
284 const SlaveID& slaveId,
285 const FrameworkID& frameworkId,
296 const SlaveID& slaveId,
const Resources& resources) = 0;
299 const FrameworkID& frameworkId,
300 const SlaveID& slaveId,
303 bool isAllocated) = 0;
306 const FrameworkID& frameworkId,
307 const std::set<std::string>& roles) = 0;
310 const FrameworkID& frameworkId,
311 const std::set<std::string>& roles) = 0;
314 const std::string& role,
315 const Quota& quota) = 0;
318 const std::vector<WeightInfo>& weightInfos) = 0;
320 virtual void pause() = 0;
322 virtual void resume() = 0;
326 template <
typename AllocatorProcess>
332 return CHECK_NOTNULL(allocator);
336 template <
typename AllocatorProcess>
339 process =
new AllocatorProcess();
344 template <
typename AllocatorProcess>
353 template <
typename AllocatorProcess>
356 const lambda::function<
357 void(
const FrameworkID&,
360 const lambda::function<
361 void(
const FrameworkID&,
363 inverseOfferCallback)
370 inverseOfferCallback);
374 template <
typename AllocatorProcess>
376 const int expectedAgentCount,
387 template <
typename AllocatorProcess>
389 const FrameworkID& frameworkId,
390 const FrameworkInfo& frameworkInfo,
406 template <
typename AllocatorProcess>
408 const FrameworkID& frameworkId)
417 template <
typename AllocatorProcess>
419 const FrameworkID& frameworkId)
428 template <
typename AllocatorProcess>
430 const FrameworkID& frameworkId)
439 template <
typename AllocatorProcess>
441 const FrameworkID& frameworkId,
442 const FrameworkInfo& frameworkInfo,
454 template <
typename AllocatorProcess>
456 const SlaveID& slaveId,
457 const SlaveInfo& slaveInfo,
458 const std::vector<SlaveInfo::Capability>& capabilities,
475 template <
typename AllocatorProcess>
477 const SlaveID& slaveId)
486 template <
typename AllocatorProcess>
488 const SlaveID& slaveId,
489 const SlaveInfo& slaveInfo,
491 const Option<std::vector<SlaveInfo::Capability>>& capabilities)
502 template <
typename AllocatorProcess>
504 const SlaveID& slave,
517 template <
typename AllocatorProcess>
519 const SlaveID& slaveId)
528 template <
typename AllocatorProcess>
530 const SlaveID& slaveId)
539 template <
typename AllocatorProcess>
550 template <
typename AllocatorProcess>
552 const FrameworkID& frameworkId,
553 const std::vector<Request>& requests)
563 template <
typename AllocatorProcess>
565 const FrameworkID& frameworkId,
566 const SlaveID& slaveId,
568 const std::vector<ResourceConversion>& conversions)
580 template <
typename AllocatorProcess>
583 const SlaveID& slaveId,
584 const std::vector<Offer::Operation>& operations)
594 template <
typename AllocatorProcess>
596 const SlaveID& slaveId,
607 template <
typename AllocatorProcess>
609 const SlaveID& slaveId,
610 const FrameworkID& frameworkId,
620 unavailableResources,
626 template <
typename AllocatorProcess>
637 template <
typename AllocatorProcess>
639 const SlaveID& slaveId,
650 template <
typename AllocatorProcess>
652 const FrameworkID& frameworkId,
653 const SlaveID& slaveId,
669 template <
typename AllocatorProcess>
671 const FrameworkID& frameworkId,
672 const std::set<std::string>& roles)
682 template <
typename AllocatorProcess>
684 const FrameworkID& frameworkId,
685 const std::set<std::string>& roles)
695 template <
typename AllocatorProcess>
697 const std::string& role,
708 template <
typename AllocatorProcess>
710 const std::vector<WeightInfo>& weightInfos)
719 template <
typename AllocatorProcess>
726 template <
typename AllocatorProcess>
738 #endif // __MASTER_ALLOCATOR_MESOS_ALLOCATOR_HPP__ virtual void deactivateSlave(const SlaveID &slaveId)=0
virtual void requestResources(const FrameworkID &frameworkId, const std::vector< Request > &requests)=0
Per-framework allocator-specific options that are not part of FrameworkInfo.
Definition: allocator.hpp:147
void suppressOffers(const FrameworkID &frameworkId, const std::set< std::string > &roles) override
Suppresses offers.
Definition: allocator.hpp:670
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:29
void activateSlave(const SlaveID &slaveId) override
Activates an agent.
Definition: allocator.hpp:518
virtual void addResourceProvider(const SlaveID &slave, const Resources &total, const hashmap< FrameworkID, Resources > &used)=0
void addFramework(const FrameworkID &frameworkId, const FrameworkInfo &frameworkInfo, const hashmap< SlaveID, Resources > &used, bool active,::mesos::allocator::FrameworkOptions &&options) override
Definition: allocator.hpp:388
void updateWeights(const std::vector< WeightInfo > &weightInfos) override
Updates the weight associated with one or more roles.
Definition: allocator.hpp:709
Definition: master.hpp:27
void requestResources(const FrameworkID &frameworkId, const std::vector< Request > &requests) override
Requests resources for a framework.
Definition: allocator.hpp:551
void recoverResources(const FrameworkID &frameworkId, const SlaveID &slaveId, const Resources &resources, const Option< Filters > &filters, bool isAllocated) override
Recovers resources.
Definition: allocator.hpp:651
virtual void recover(const int expectedAgentCount, const hashmap< std::string, Quota > "as)=0
void recover(const int expectedAgentCount, const hashmap< std::string, Quota > "as) override
Informs the allocator of the recovered state from the master.
Definition: allocator.hpp:375
virtual void deactivateFramework(const FrameworkID &frameworkId)=0
void deactivateSlave(const SlaveID &slaveId) override
Deactivates an agent.
Definition: allocator.hpp:529
MesosAllocatorProcess()
Definition: allocator.hpp:189
Result< ProcessStatus > status(pid_t pid)
Definition: proc.hpp:166
Definition: resources.hpp:83
virtual void transitionOfferedToAllocated(const SlaveID &slaveId, const Resources &resources)=0
virtual void updateFramework(const FrameworkID &frameworkId, const FrameworkInfo &frameworkInfo,::mesos::allocator::FrameworkOptions &&options)=0
void updateQuota(const std::string &role, const Quota "a) override
Informs the allocator to update quota for the given role.
Definition: allocator.hpp:696
void transitionOfferedToAllocated(const SlaveID &slaveId, const Resources &resources) override
This method should be invoked when the offered resources has become actually allocated.
Definition: allocator.hpp:638
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
Pass in configuration to the allocator.
Definition: allocator.hpp:53
void removeFramework(const FrameworkID &frameworkId) override
Removes a framework from the Mesos cluster.
Definition: allocator.hpp:407
static Try< mesos::allocator::Allocator * > create()
Definition: allocator.hpp:328
UPID spawn(ProcessBase *process, bool manage=false)
Spawn a new process.
Definition: allocator.hpp:41
void terminate(const UPID &pid, bool inject=true)
Sends a TerminateEvent to the given process.
void removeSlave(const SlaveID &slaveId) override
Removes an agent from the Mesos cluster.
Definition: allocator.hpp:476
virtual void updateQuota(const std::string &role, const Quota "a)=0
void reviveOffers(const FrameworkID &frameworkId, const std::set< std::string > &roles) override
Revives offers to this framework for the specified roles.
Definition: allocator.hpp:683
Definition: hashmap.hpp:38
~MesosAllocatorProcess() override
Definition: allocator.hpp:191
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)
virtual void recoverResources(const FrameworkID &frameworkId, const SlaveID &slaveId, const Resources &resources, const Option< Filters > &filters, bool isAllocated)=0
void updateWhitelist(const Option< hashset< std::string >> &whitelist) override
Updates the list of trusted agents.
Definition: allocator.hpp:540
Try< Bytes > used(const std::string &path="/")
Definition: fs.hpp:43
Result< std::vector< Filter< Classifier > > > filters(const std::string &_link, const Handle &parent)
Definition: internal.hpp:769
void initialize(const mesos::allocator::Options &options, 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) override
Initializes the allocator when the master starts up.
Definition: allocator.hpp:354
virtual void activateSlave(const SlaveID &slaveId)=0
virtual void addFramework(const FrameworkID &frameworkId, const FrameworkInfo &frameworkInfo, const hashmap< SlaveID, Resources > &used, bool active,::mesos::allocator::FrameworkOptions &&options)=0
virtual void removeSlave(const SlaveID &slaveId)=0
virtual void initialize()
Invoked when a process gets spawned.
Definition: process.hpp:100
Definition: allocator.hpp:186
void updateFramework(const FrameworkID &frameworkId, const FrameworkInfo &frameworkInfo,::mesos::allocator::FrameworkOptions &&options) override
Definition: allocator.hpp:440
virtual void updateUnavailability(const SlaveID &slaveId, const Option< Unavailability > &unavailability)=0
~MesosAllocator() override
Definition: allocator.hpp:345
virtual process::Future< Nothing > updateAvailable(const SlaveID &slaveId, const std::vector< Offer::Operation > &operations)=0
void deactivateFramework(const FrameworkID &frameworkId) override
Deactivates a framework in the Mesos cluster.
Definition: allocator.hpp:429
virtual void reviveOffers(const FrameworkID &frameworkId, const std::set< std::string > &roles)=0
void updateAllocation(const FrameworkID &frameworkId, const SlaveID &slaveId, const Resources &offeredResources, const std::vector< ResourceConversion > &conversions) override
Updates allocation by applying offer operations.
Definition: allocator.hpp:564
virtual void updateWeights(const std::vector< WeightInfo > &weightInfos)=0
bool wait(const UPID &pid, const Duration &duration=Seconds(-1))
Wait for the process to exit for no more than the specified seconds.
void updateSlave(const SlaveID &slave, const SlaveInfo &slaveInfo, const Option< Resources > &total=None(), const Option< std::vector< SlaveInfo::Capability >> &capabilities=None()) override
Updates an agent.
Definition: allocator.hpp:487
void updateInverseOffer(const SlaveID &slaveId, const FrameworkID &frameworkId, const Option< UnavailableResources > &unavailableResources, const Option< mesos::allocator::InverseOfferStatus > &status, const Option< Filters > &filters) override
Definition: allocator.hpp:608
virtual void updateWhitelist(const Option< hashset< std::string >> &whitelist)=0
Basic model of an allocator: resources are allocated to a framework in the form of offers...
Definition: allocator.hpp:172
void activateFramework(const FrameworkID &frameworkId) override
Activates a framework in the Mesos cluster.
Definition: allocator.hpp:418
Definition: attributes.hpp:24
virtual void removeFramework(const FrameworkID &frameworkId)=0
process::Future< hashmap< SlaveID, hashmap< FrameworkID, mesos::allocator::InverseOfferStatus > > > getInverseOfferStatuses() override
Retrieves the status of all inverse offers maintained by the allocator.
Definition: allocator.hpp:630
void updateUnavailability(const SlaveID &slaveId, const Option< Unavailability > &unavailability) override
Updates unavailability for an agent.
Definition: allocator.hpp:595
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
Adds or re-adds an agent to the Mesos cluster.
Definition: allocator.hpp:455
virtual void updateSlave(const SlaveID &slave, const SlaveInfo &slaveInfo, const Option< Resources > &total=None(), const Option< std::vector< SlaveInfo::Capability >> &capabilities=None())=0
Definition: executor.hpp:48
process::Future< Nothing > updateAvailable(const SlaveID &slaveId, const std::vector< Offer::Operation > &operations) override
Updates available resources on an agent based on a sequence of offer operations.
Definition: allocator.hpp:582
void resume() override
Idempotent helper to resume allocations.
Definition: allocator.hpp:727
void addResourceProvider(const SlaveID &slave, const Resources &total, const hashmap< FrameworkID, Resources > &used) override
Add resources from a local resource provider to an agent.
Definition: allocator.hpp:503
virtual void updateAllocation(const FrameworkID &frameworkId, const SlaveID &slaveId, const Resources &offeredResources, const std::vector< ResourceConversion > &conversions)=0
Definition: process.hpp:505
void pause() override
Idempotent helper to pause allocations.
Definition: allocator.hpp:720