Apache Mesos
Public Member Functions | Static Public Member Functions | List of all members
mesos::internal::master::allocator::MesosAllocator< AllocatorProcess > Class Template Reference

#include <allocator.hpp>

Inheritance diagram for mesos::internal::master::allocator::MesosAllocator< AllocatorProcess >:
mesos::allocator::Allocator

Public Member Functions

 ~MesosAllocator () override
 
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. More...
 
void recover (const int expectedAgentCount, const hashmap< std::string, Quota > &quotas) override
 Informs the allocator of the recovered state from the master. More...
 
void addFramework (const FrameworkID &frameworkId, const FrameworkInfo &frameworkInfo, const hashmap< SlaveID, Resources > &used, bool active,::mesos::allocator::FrameworkOptions &&options) override
 
void removeFramework (const FrameworkID &frameworkId) override
 Removes a framework from the Mesos cluster. More...
 
void activateFramework (const FrameworkID &frameworkId) override
 Activates a framework in the Mesos cluster. More...
 
void deactivateFramework (const FrameworkID &frameworkId) override
 Deactivates a framework in the Mesos cluster. More...
 
void updateFramework (const FrameworkID &frameworkId, const FrameworkInfo &frameworkInfo,::mesos::allocator::FrameworkOptions &&options) 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
 Adds or re-adds an agent to the Mesos cluster. More...
 
void removeSlave (const SlaveID &slaveId) override
 Removes an agent from the Mesos cluster. More...
 
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. More...
 
void addResourceProvider (const SlaveID &slave, const Resources &total, const hashmap< FrameworkID, Resources > &used) override
 Add resources from a local resource provider to an agent. More...
 
void activateSlave (const SlaveID &slaveId) override
 Activates an agent. More...
 
void deactivateSlave (const SlaveID &slaveId) override
 Deactivates an agent. More...
 
void updateWhitelist (const Option< hashset< std::string >> &whitelist) override
 Updates the list of trusted agents. More...
 
void requestResources (const FrameworkID &frameworkId, const std::vector< Request > &requests) override
 Requests resources for a framework. More...
 
void updateAllocation (const FrameworkID &frameworkId, const SlaveID &slaveId, const Resources &offeredResources, const std::vector< ResourceConversion > &conversions) override
 Updates allocation by applying offer operations. More...
 
process::Future< NothingupdateAvailable (const SlaveID &slaveId, const std::vector< Offer::Operation > &operations) override
 Updates available resources on an agent based on a sequence of offer operations. More...
 
void updateUnavailability (const SlaveID &slaveId, const Option< Unavailability > &unavailability) override
 Updates unavailability for an agent. More...
 
void updateInverseOffer (const SlaveID &slaveId, const FrameworkID &frameworkId, const Option< UnavailableResources > &unavailableResources, const Option< mesos::allocator::InverseOfferStatus > &status, const Option< Filters > &filters) override
 
process::Future< hashmap< SlaveID, hashmap< FrameworkID, mesos::allocator::InverseOfferStatus > > > getInverseOfferStatuses () override
 Retrieves the status of all inverse offers maintained by the allocator. More...
 
void transitionOfferedToAllocated (const SlaveID &slaveId, const Resources &resources) override
 This method should be invoked when the offered resources has become actually allocated. More...
 
void recoverResources (const FrameworkID &frameworkId, const SlaveID &slaveId, const Resources &resources, const Option< Filters > &filters, bool isAllocated) override
 Recovers resources. More...
 
void suppressOffers (const FrameworkID &frameworkId, const std::set< std::string > &roles) override
 Suppresses offers. More...
 
void reviveOffers (const FrameworkID &frameworkId, const std::set< std::string > &roles) override
 Revives offers to this framework for the specified roles. More...
 
void updateQuota (const std::string &role, const Quota &quota) override
 Informs the allocator to update quota for the given role. More...
 
void updateWeights (const std::vector< WeightInfo > &weightInfos) override
 Updates the weight associated with one or more roles. More...
 
void pause () override
 Idempotent helper to pause allocations. More...
 
void resume () override
 Idempotent helper to resume allocations. More...
 
- Public Member Functions inherited from mesos::allocator::Allocator
 Allocator ()
 
virtual ~Allocator ()
 
virtual void addFramework (const FrameworkID &frameworkId, const FrameworkInfo &frameworkInfo, const hashmap< SlaveID, Resources > &used, bool active, FrameworkOptions &&options)=0
 Adds a framework to the Mesos cluster. More...
 
virtual void updateFramework (const FrameworkID &frameworkId, const FrameworkInfo &frameworkInfo, FrameworkOptions &&options)=0
 Updates FrameworkInfo and FrameworkOptions. More...
 
virtual void updateInverseOffer (const SlaveID &slaveId, const FrameworkID &frameworkId, const Option< UnavailableResources > &unavailableResources, const Option< InverseOfferStatus > &status, const Option< Filters > &filters=None())=0
 Updates inverse offer. More...
 

Static Public Member Functions

static Try< mesos::allocator::Allocator * > create ()
 
- Static Public Member Functions inherited from mesos::allocator::Allocator
static Try< Allocator * > create (const std::string &name, const std::string &roleSorter, const std::string &frameworkSorter)
 Attempts either to create a built-in DRF allocator or to load an allocator instance from a module using the given name. More...
 

Constructor & Destructor Documentation

template<typename AllocatorProcess >
mesos::internal::master::allocator::MesosAllocator< AllocatorProcess >::~MesosAllocator ( )
override

Member Function Documentation

template<typename AllocatorProcess >
void mesos::internal::master::allocator::MesosAllocator< AllocatorProcess >::activateFramework ( const FrameworkID &  frameworkId)
inlineoverridevirtual

Activates a framework in the Mesos cluster.

Offers are only sent to active frameworks.

Implements mesos::allocator::Allocator.

template<typename AllocatorProcess >
void mesos::internal::master::allocator::MesosAllocator< AllocatorProcess >::activateSlave ( const SlaveID &  slaveId)
inlineoverridevirtual

Activates an agent.

This is invoked when an agent reregisters. Offers are only sent for activated agents.

Implements mesos::allocator::Allocator.

template<typename AllocatorProcess >
void mesos::internal::master::allocator::MesosAllocator< AllocatorProcess >::addFramework ( const FrameworkID &  frameworkId,
const FrameworkInfo &  frameworkInfo,
const hashmap< SlaveID, Resources > &  used,
bool  active,
::mesos::allocator::FrameworkOptions &&  options 
)
inlineoverride
template<typename AllocatorProcess >
void mesos::internal::master::allocator::MesosAllocator< AllocatorProcess >::addResourceProvider ( const SlaveID &  slave,
const Resources total,
const hashmap< FrameworkID, Resources > &  used 
)
overridevirtual

Add resources from a local resource provider to an agent.

Parameters
slaveId of the agent to modify.
totalThe resources to add to the agent's total resources.
usedThe resources to add to the resources tracked as used for this agent.

Implements mesos::allocator::Allocator.

template<typename AllocatorProcess >
void mesos::internal::master::allocator::MesosAllocator< AllocatorProcess >::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 
)
inlineoverridevirtual

Adds or re-adds an agent to the Mesos cluster.

It is invoked when a new agent joins the cluster or in case of agent recovery.

Parameters
slaveIdID of the agent to be added or re-added.
slaveInfoDetailed info of the agent. The slaveInfo resources correspond directly to the static –resources flag value on the agent.
capabilitiesCapabilities of the agent.
totalThe total resources are passed explicitly because it includes resources that are dynamically "checkpointed" on the agent (e.g. persistent volumes, dynamic reservations, etc).
usedResources that are allocated on the current agent. The allocator should avoid double accounting when yet unknown frameworks are added later in addFramework().

TODO(asekretenko): Ideally, to get rig of an intermediate allocator state when some resources are used by nonexistent frameworks, we should change the interface so that per-agent per-framework used resources and the not yet known frameworks that are using them are added atomically.

Implements mesos::allocator::Allocator.

template<typename AllocatorProcess >
Try< mesos::allocator::Allocator * > mesos::internal::master::allocator::MesosAllocator< AllocatorProcess >::create ( )
static
template<typename AllocatorProcess >
void mesos::internal::master::allocator::MesosAllocator< AllocatorProcess >::deactivateFramework ( const FrameworkID &  frameworkId)
inlineoverridevirtual

Deactivates a framework in the Mesos cluster.

Resource offers are not sent to deactivated frameworks.

Implements mesos::allocator::Allocator.

template<typename AllocatorProcess >
void mesos::internal::master::allocator::MesosAllocator< AllocatorProcess >::deactivateSlave ( const SlaveID &  slaveId)
inlineoverridevirtual

Deactivates an agent.

This is triggered if an agent disconnects from the master. The allocator should treat all offers from the deactivated agent as rescinded. (There is no separate call to the allocator to handle this). Resources aren't "recovered" when an agent deactivates because the resources are lost.

Implements mesos::allocator::Allocator.

template<typename AllocatorProcess >
process::Future< hashmap< SlaveID, hashmap< FrameworkID, mesos::allocator::InverseOfferStatus > > > mesos::internal::master::allocator::MesosAllocator< AllocatorProcess >::getInverseOfferStatuses ( )
inlineoverridevirtual

Retrieves the status of all inverse offers maintained by the allocator.

Implements mesos::allocator::Allocator.

template<typename AllocatorProcess >
void mesos::internal::master::allocator::MesosAllocator< AllocatorProcess >::initialize ( const mesos::allocator::Options options)
inlineoverridevirtual

Initializes the allocator when the master starts up.

Any errors in initialization should fail fast and result in an ABORT. The master expects the allocator to be successfully initialized if this call returns.

Parameters
allocationIntervalThe allocate interval for the allocator, it determines how often the allocator should perform the batch allocation. An allocator may also perform allocation based on events (a framework is added and so on), this depends on the implementation.
offerCallbackA callback the allocator uses to send allocations to the frameworks.
inverseOfferCallbackA callback the allocator uses to send reclaim allocations from the frameworks.

Implements mesos::allocator::Allocator.

template<typename AllocatorProcess >
void mesos::internal::master::allocator::MesosAllocator< AllocatorProcess >::pause ( )
inlineoverridevirtual

Idempotent helper to pause allocations.

Implements mesos::allocator::Allocator.

template<typename AllocatorProcess >
void mesos::internal::master::allocator::MesosAllocator< AllocatorProcess >::recover ( const int  expectedAgentCount,
const hashmap< std::string, Quota > &  quotas 
)
inlineoverridevirtual

Informs the allocator of the recovered state from the master.

Because it is hard to define recovery for a running allocator, this method should be called after initialize(), but before actual allocation starts (i.e. addSlave() is called).

TODO(alexr): Consider extending the signature with expected frameworks count once it is available upon the master failover.

Parameters
quotasA (possibly empty) collection of quotas, keyed by their role, known to the master.

Implements mesos::allocator::Allocator.

template<typename AllocatorProcess >
void mesos::internal::master::allocator::MesosAllocator< AllocatorProcess >::recoverResources ( const FrameworkID &  frameworkId,
const SlaveID &  slaveId,
const Resources resources,
const Option< Filters > &  filters,
bool  isAllocated 
)
inlineoverridevirtual

Recovers resources.

Used to update the set of available resources for a specific agent. This method is invoked to inform the allocator about offered resources that have been refused or allocated (i.e. used for launching tasks) resources that are no longer in use. The resources will have an allocation_info.role assigned and callers are expected to only call this with resources allocated to a single role.

TODO(bmahler): We could allow resources allocated to multiple roles within a single call here, but filtering them in the same way does not seem desirable.

Implements mesos::allocator::Allocator.

template<typename AllocatorProcess >
void mesos::internal::master::allocator::MesosAllocator< AllocatorProcess >::removeFramework ( const FrameworkID &  frameworkId)
inlineoverridevirtual

Removes a framework from the Mesos cluster.

It is up to an allocator to decide what to do with framework's resources. For example, they may be released and added back to the shared pool of resources.

Implements mesos::allocator::Allocator.

template<typename AllocatorProcess >
void mesos::internal::master::allocator::MesosAllocator< AllocatorProcess >::removeSlave ( const SlaveID &  slaveId)
inlineoverridevirtual

Removes an agent from the Mesos cluster.

All resources belonging to this agent should be released by the allocator.

Implements mesos::allocator::Allocator.

template<typename AllocatorProcess >
void mesos::internal::master::allocator::MesosAllocator< AllocatorProcess >::requestResources ( const FrameworkID &  frameworkId,
const std::vector< Request > &  requests 
)
inlineoverridevirtual

Requests resources for a framework.

A framework may request resources via this call. It is up to the allocator how to react to this request. For example, a request may be ignored, or may influence internal priorities the allocator may keep for frameworks.

Implements mesos::allocator::Allocator.

template<typename AllocatorProcess >
void mesos::internal::master::allocator::MesosAllocator< AllocatorProcess >::resume ( )
inlineoverridevirtual

Idempotent helper to resume allocations.

Implements mesos::allocator::Allocator.

template<typename AllocatorProcess >
void mesos::internal::master::allocator::MesosAllocator< AllocatorProcess >::reviveOffers ( const FrameworkID &  frameworkId,
const std::set< std::string > &  roles 
)
inlineoverridevirtual

Revives offers to this framework for the specified roles.

This is invoked by a framework when it wishes to receive filtered resources immediately or get itself out of a suppressed state. If roles is an empty set, it is treated as being set to all of the framework's subscribed roles.

Implements mesos::allocator::Allocator.

template<typename AllocatorProcess >
void mesos::internal::master::allocator::MesosAllocator< AllocatorProcess >::suppressOffers ( const FrameworkID &  frameworkId,
const std::set< std::string > &  roles 
)
inlineoverridevirtual

Suppresses offers.

Informs the allocator to stop sending offers to this framework for the specified roles. If roles is an empty set, we will stop sending offers to this framework for all of the framework's subscribed roles.

Implements mesos::allocator::Allocator.

template<typename AllocatorProcess >
void mesos::internal::master::allocator::MesosAllocator< AllocatorProcess >::transitionOfferedToAllocated ( const SlaveID &  slaveId,
const Resources resources 
)
inlineoverridevirtual

This method should be invoked when the offered resources has become actually allocated.

Implements mesos::allocator::Allocator.

template<typename AllocatorProcess >
void mesos::internal::master::allocator::MesosAllocator< AllocatorProcess >::updateAllocation ( const FrameworkID &  frameworkId,
const SlaveID &  slaveId,
const Resources offeredResources,
const std::vector< ResourceConversion > &  conversions 
)
inlineoverridevirtual

Updates allocation by applying offer operations.

This call is mainly intended to support persistence-related features (dynamic reservation and persistent volumes). The allocator may react differently for certain offer operations. The allocator should use this call to update bookkeeping information related to the framework. The offeredResources are the resources that the operations are applied to and must be allocated to a single role.

Implements mesos::allocator::Allocator.

template<typename AllocatorProcess >
process::Future< Nothing > mesos::internal::master::allocator::MesosAllocator< AllocatorProcess >::updateAvailable ( const SlaveID &  slaveId,
const std::vector< Offer::Operation > &  operations 
)
inlineoverridevirtual

Updates available resources on an agent based on a sequence of offer operations.

Operations may include reserve, unreserve, create or destroy.

Parameters
slaveIdID of the agent.
operationsThe offer operations to apply to this agent's resources.

Implements mesos::allocator::Allocator.

template<typename AllocatorProcess >
void mesos::internal::master::allocator::MesosAllocator< AllocatorProcess >::updateFramework ( const FrameworkID &  frameworkId,
const FrameworkInfo &  frameworkInfo,
::mesos::allocator::FrameworkOptions &&  options 
)
inlineoverride
template<typename AllocatorProcess >
void mesos::internal::master::allocator::MesosAllocator< AllocatorProcess >::updateInverseOffer ( const SlaveID &  slaveId,
const FrameworkID &  frameworkId,
const Option< UnavailableResources > &  unavailableResources,
const Option< mesos::allocator::InverseOfferStatus > &  status,
const Option< Filters > &  filters 
)
inlineoverride
template<typename AllocatorProcess >
void mesos::internal::master::allocator::MesosAllocator< AllocatorProcess >::updateQuota ( const std::string &  role,
const Quota quota 
)
inlineoverridevirtual

Informs the allocator to update quota for the given role.

It is up to the allocator implementation how to satisfy quota. An implementation may employ different strategies for roles with or without quota. All roles have a default quota defined as DEFAULT_QUOTA. Currently, it is no guarantees and no limits. Thus to "remove" a quota, one should simply update the quota to be DEFAULT_QUOTA.

Implements mesos::allocator::Allocator.

template<typename AllocatorProcess >
void mesos::internal::master::allocator::MesosAllocator< AllocatorProcess >::updateSlave ( const SlaveID &  slave,
const SlaveInfo &  slaveInfo,
const Option< Resources > &  total = None(),
const Option< std::vector< SlaveInfo::Capability >> &  capabilities = None() 
)
inlineoverridevirtual

Updates an agent.

TODO(bevers): Make total and capabilities non-optional.

Parameters
slaveInfoThe current slave info of the agent.
totalThe new total resources on the agent.
capabilitiesThe new capabilities of the agent.

Implements mesos::allocator::Allocator.

template<typename AllocatorProcess >
void mesos::internal::master::allocator::MesosAllocator< AllocatorProcess >::updateUnavailability ( const SlaveID &  slaveId,
const Option< Unavailability > &  unavailability 
)
inlineoverridevirtual

Updates unavailability for an agent.

We currently support storing the next unavailability, if there is one, per agent. If unavailability is not set then there is no known upcoming unavailability. This might require the implementation of the function to remove any inverse offers that are outstanding.

Implements mesos::allocator::Allocator.

template<typename AllocatorProcess >
void mesos::internal::master::allocator::MesosAllocator< AllocatorProcess >::updateWeights ( const std::vector< WeightInfo > &  weightInfos)
inlineoverridevirtual

Updates the weight associated with one or more roles.

If a role was previously configured to have a weight and that role is omitted from this list, it keeps its old weight.

Implements mesos::allocator::Allocator.

template<typename AllocatorProcess >
void mesos::internal::master::allocator::MesosAllocator< AllocatorProcess >::updateWhitelist ( const Option< hashset< std::string >> &  whitelist)
inlineoverridevirtual

Updates the list of trusted agents.

This is invoked when the master starts up with the –whitelist flag.

Parameters
whitelistA set of agents that are allowed to contribute their resources to the resource pool.

Implements mesos::allocator::Allocator.


The documentation for this class was generated from the following file: