h1. Overview

The logic that the Mesos master uses to determine which frameworks to make offer resource offers to is encapsulated in the Master's _allocation module_.  The allocation module is a pluggable component that organizations can use to implement their own sharing policy, e.g. fair-sharing, Dominant Resource Fairness (see "the DRF paper":http://www.eecs.berkeley.edu/Pubs/TechRpts/2010/EECS-2010-55.pdf), priority, etc.

h1. Allocation Module API

Mesos is implemented in C++, so allocation modules are implemented in C++, and inherit the @Allocator@ class defined in @MESOS_HOME/src/master/allocator.hpp@. As of the time of this writing (11/12/10), the API for allocation modules is as follows:

```c++
  virtual ~Allocator() {}

  virtual void frameworkAdded(Framework *framework) {}

  virtual void frameworkRemoved(Framework *framework) {}

  virtual void slaveAdded(Slave *slave) {}

  virtual void slaveRemoved(Slave *slave) {}

  virtual void taskAdded(Task *task) {}

  virtual void taskRemoved(Task *task, TaskRemovalReason reason) {}

  virtual void offerReturned(SlotOffer* offer,
                             OfferReturnReason reason,
                             const std::vector<SlaveResources>& resourcesLeft) {}

  virtual void offersRevived(Framework *framework) {}

  virtual void timerTick() {}};
```

The default allocation module is the SimpleAllocator, which can be found in @MESOS_HOME/src/master/simple_allocator.cpp@ and @...hpp@. You an reference these as a starting place if you choose to write your own allocation module.
