You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mesos.apache.org by Dariia Zhyrova <dz...@cogniance.com> on 2015/05/25 13:18:40 UTC

Custom Mesos Allocation module

Hello,

I need to write custom Allocation module, but I don't see a possibility to
load it dynamically using --modules command line argument.
This is the allocation module creation in master/main:

allocator::Allocator* allocator = new allocator::HierarchicalDRFAllocator();

(so it is just hardcoded)
Other modules are loaded dynamically like this:

if (flags.modules.isSome()) {
    Try<Nothing> result = ModuleManager::load(flags.modules.get());
    if (result.isError()) {
      EXIT(1) << "Error loading modules: " << result.error();
    }
  }
...
// Create anonymous modules.
  foreach (const string& name, ModuleManager::find<Anonymous>()) {
    Try<Anonymous*> create = ModuleManager::create<Anonymous>(name);
    if (create.isError()) {
      EXIT(1) << "Failed to create anonymous module named '" << name << "'";
    }
...
Authenticator* authenticator;
  // TODO(tillt): Allow multiple authenticators to be loaded and enable
  // the authenticatee to select the appropriate one. See MESOS-1939.
  if (authenticatorNames[0] == DEFAULT_AUTHENTICATOR) {
    LOG(INFO) << "Using default CRAM-MD5 authenticator";
    authenticator = new cram_md5::CRAMMD5Authenticator();
  } else {
    Try<Authenticator*> module =
      modules::ModuleManager::create<Authenticator>(authenticatorNames[0]);
    if (module.isError()) {
      EXIT(1) << "Could not create authenticator module '"
              << authenticatorNames[0] << "': " << module.error();
    }
...
if (ModuleManager::contains<Isolator>(type)) {
      Try<Isolator*> isolator = ModuleManager::create<Isolator>(type);
      if (isolator.isError()) {
        return Error(
            "Could not create isolator " + type + ": " + isolator.error());
      }

This is a list of supported modules which can be loaded dynamically:
 kindToVersion["Anonymous"] = MESOS_VERSION;
  kindToVersion["Authenticatee"] = MESOS_VERSION;
  kindToVersion["Authenticator"] = MESOS_VERSION;
  kindToVersion["Hook"] = MESOS_VERSION;
  kindToVersion["Isolator"] = MESOS_VERSION;
  kindToVersion["TestModule"] = MESOS_VERSION;

If allocation module is absent here, it will not pass such check:

Try<Nothing> ModuleManager::verifyModule(
    const string& moduleName,
    const ModuleBase* moduleBase)
{
...
if (!kindToVersion.contains(moduleBase->kind)) {
    return Error("Unknown module kind: " + stringify(moduleBase->kind));
  }
...
}

Mesos documentation also does not mention Allocation module as dynamically
loadable:  http://mesos.apache.org/documentation/latest/modules/

Could you please help me, is there a possibility to use custom allocation
module with Mesos?

Best regards,
Dariia

Re: Custom Mesos Allocation module

Posted by Alex Rukletsov <al...@mesosphere.com>.
The MesosAllocator class is just a wrapper for any actor-based allocator. I
think you actually want to subclass HierarchicalAllocatorProcess and pass
it as template parameter to MesosAllocator. But consider preferring
composition over inheritance
<https://en.wikipedia.org/wiki/Composition_over_inheritance> : ).

If you opt for having the default allocator that takes over in case your
primary one is unreachable, you have to make sure that the state (slaves,
resources, frameworks) is consistent between two allocators and
synchronized when appropriate.



On Tue, Jun 9, 2015 at 1:56 PM, Dariia Zhyrova <dz...@cogniance.com>
wrote:

> Hi Alex,
>
> Right, I can add Mesos sources to include path... But I cannot inherit from
> MesosAllocator since it has private constructor. I will think about this,
> maybe I really can reuse existing allocator implementation w/o subclassing.
> I plan to send all protobufs which come with specific event to server. For
> example, for addSlave event
> inline void KafkaProducerAllocator::addSlave(
>   const SlaveID& slaveId,
>   const SlaveInfo& slaveInfo,
>   const Resources& total,
>   const hashmap<FrameworkID, Resources>& used)
> {
>
> I will send all the protobufs: slaveId, slaveInfo, each Resource from total
> collection and each pair FrameworkID, Resources from used collection.
> Yes, you're right, if server becomes unavailable, allocation process will
> also stop... Maybe it should proceed in default way, with unchanged
> protobufs on some time-out. I'll need to clarify the desired behaviour.
>
> Best regards,
> Dariia
>
> On Mon, Jun 8, 2015 at 6:39 PM, Alex Rukletsov <al...@mesosphere.com>
> wrote:
>
> > Hi Dariia,
> >
> > interesting! I think you can actually subclass the Hierarchical
> allocator,
> > but you need access to Mesos sources (quick check of your code hints you
> > need it nevertheless since you build unbundled Mesos).
> >
> > What protobufs do you plan to send to your Go server? Allocator
> maintains a
> > list of available resources and registered frameworks and periodically
> > makes offers. Also, in your design it looks like if the Go server becomes
> > unavailable, there will be no offers made.
> >
> > On Fri, May 29, 2015 at 3:20 PM, Dariia Zhyrova <dz...@cogniance.com>
> > wrote:
> >
> > > Hi Alex,
> > >
> > > My task was to create allocator which produces information about all
> > > protobufs it receives to Kafka (prior to actual resources allocation).
> > Here
> > > is the implementation: https://github.com/stealthly/alligator. I had
> to
> > > copy-paste Hierarchical allocator from Mesos sources since
> unfortunately
> > > there is no possibility to inherit from it (or use in other way)
> outside
> > > Mesos.
> > > Further I will need to implement a custom allocator which sends all
> > > protobufs to Go server and then receives them back (changed in some
> way).
> > > In this way it is expected to customize allocation process using Go,
> not
> > > C++.
> > >
> > > Best regards,
> > > Dariia
> > >
> > > On Thu, May 28, 2015 at 2:54 PM, Alex Rukletsov <al...@mesosphere.com>
> > > wrote:
> > >
> > > > Dariia,
> > > >
> > > > I'm excited to see people hacking on allocation algorithms in Mesos!
> > May
> > > I
> > > > ask you to share some information about what custom allocation policy
> > do
> > > > you use? What is the motivation?
> > > >
> > > > Thanks,
> > > > Alex
> > > >
> > > > On Wed, May 27, 2015 at 8:32 PM, Dariia Zhyrova <
> > dzhyrova@cogniance.com>
> > > > wrote:
> > > >
> > > > > Thank you very much! I used an old Mesos version indeed. Using
> custom
> > > > > allocator module works just fine.
> > > > > Best reagrds,
> > > > > Dariia
> > > > >
> > > > > On Tue, May 26, 2015 at 6:39 PM, Alex Rukletsov <
> alex@mesosphere.com
> > >
> > > > > wrote:
> > > > >
> > > > > > Dariia,
> > > > > >
> > > > > > what Mesos version are you using? The ability to write and and
> use
> > > > custom
> > > > > > allocator modules without hacking on Mesos source code has just
> > > landed
> > > > in
> > > > > > Mesos (means will be available in 0.23 release) with docs being
> > > updated
> > > > > > right now (here <https://reviews.apache.org/r/34545/> is the RR
> > > > request
> > > > > if
> > > > > > you really want to be on the bleeding edge).
> > > > > >
> > > > > > However, if you're on an older version of Mesos, you can still
> > write
> > > > your
> > > > > > own module and replace / adjust the line you refer to in
> > > > master/main.cpp
> > > > > to
> > > > > > support your custom allocator.
> > > > > >
> > > > > > On Mon, May 25, 2015 at 1:18 PM, Dariia Zhyrova <
> > > > dzhyrova@cogniance.com>
> > > > > > wrote:
> > > > > >
> > > > > > > Hello,
> > > > > > >
> > > > > > > I need to write custom Allocation module, but I don't see a
> > > > possibility
> > > > > > to
> > > > > > > load it dynamically using --modules command line argument.
> > > > > > > This is the allocation module creation in master/main:
> > > > > > >
> > > > > > > allocator::Allocator* allocator = new
> > > > > > > allocator::HierarchicalDRFAllocator();
> > > > > > >
> > > > > > > (so it is just hardcoded)
> > > > > > > Other modules are loaded dynamically like this:
> > > > > > >
> > > > > > > if (flags.modules.isSome()) {
> > > > > > >     Try<Nothing> result =
> > ModuleManager::load(flags.modules.get());
> > > > > > >     if (result.isError()) {
> > > > > > >       EXIT(1) << "Error loading modules: " << result.error();
> > > > > > >     }
> > > > > > >   }
> > > > > > > ...
> > > > > > > // Create anonymous modules.
> > > > > > >   foreach (const string& name,
> ModuleManager::find<Anonymous>())
> > {
> > > > > > >     Try<Anonymous*> create =
> > > ModuleManager::create<Anonymous>(name);
> > > > > > >     if (create.isError()) {
> > > > > > >       EXIT(1) << "Failed to create anonymous module named '" <<
> > > name
> > > > <<
> > > > > > > "'";
> > > > > > >     }
> > > > > > > ...
> > > > > > > Authenticator* authenticator;
> > > > > > >   // TODO(tillt): Allow multiple authenticators to be loaded
> and
> > > > enable
> > > > > > >   // the authenticatee to select the appropriate one. See
> > > MESOS-1939.
> > > > > > >   if (authenticatorNames[0] == DEFAULT_AUTHENTICATOR) {
> > > > > > >     LOG(INFO) << "Using default CRAM-MD5 authenticator";
> > > > > > >     authenticator = new cram_md5::CRAMMD5Authenticator();
> > > > > > >   } else {
> > > > > > >     Try<Authenticator*> module =
> > > > > > >
> > > > > >
> > > modules::ModuleManager::create<Authenticator>(authenticatorNames[0]);
> > > > > > >     if (module.isError()) {
> > > > > > >       EXIT(1) << "Could not create authenticator module '"
> > > > > > >               << authenticatorNames[0] << "': " <<
> > module.error();
> > > > > > >     }
> > > > > > > ...
> > > > > > > if (ModuleManager::contains<Isolator>(type)) {
> > > > > > >       Try<Isolator*> isolator =
> > > > ModuleManager::create<Isolator>(type);
> > > > > > >       if (isolator.isError()) {
> > > > > > >         return Error(
> > > > > > >             "Could not create isolator " + type + ": " +
> > > > > > isolator.error());
> > > > > > >       }
> > > > > > >
> > > > > > > This is a list of supported modules which can be loaded
> > > dynamically:
> > > > > > >  kindToVersion["Anonymous"] = MESOS_VERSION;
> > > > > > >   kindToVersion["Authenticatee"] = MESOS_VERSION;
> > > > > > >   kindToVersion["Authenticator"] = MESOS_VERSION;
> > > > > > >   kindToVersion["Hook"] = MESOS_VERSION;
> > > > > > >   kindToVersion["Isolator"] = MESOS_VERSION;
> > > > > > >   kindToVersion["TestModule"] = MESOS_VERSION;
> > > > > > >
> > > > > > > If allocation module is absent here, it will not pass such
> check:
> > > > > > >
> > > > > > > Try<Nothing> ModuleManager::verifyModule(
> > > > > > >     const string& moduleName,
> > > > > > >     const ModuleBase* moduleBase)
> > > > > > > {
> > > > > > > ...
> > > > > > > if (!kindToVersion.contains(moduleBase->kind)) {
> > > > > > >     return Error("Unknown module kind: " +
> > > > > stringify(moduleBase->kind));
> > > > > > >   }
> > > > > > > ...
> > > > > > > }
> > > > > > >
> > > > > > > Mesos documentation also does not mention Allocation module as
> > > > > > dynamically
> > > > > > > loadable:
> http://mesos.apache.org/documentation/latest/modules/
> > > > > > >
> > > > > > > Could you please help me, is there a possibility to use custom
> > > > > allocation
> > > > > > > module with Mesos?
> > > > > > >
> > > > > > > Best regards,
> > > > > > > Dariia
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>

Re: Custom Mesos Allocation module

Posted by Dariia Zhyrova <dz...@cogniance.com>.
Hi Alex,

Right, I can add Mesos sources to include path... But I cannot inherit from
MesosAllocator since it has private constructor. I will think about this,
maybe I really can reuse existing allocator implementation w/o subclassing.
I plan to send all protobufs which come with specific event to server. For
example, for addSlave event
inline void KafkaProducerAllocator::addSlave(
  const SlaveID& slaveId,
  const SlaveInfo& slaveInfo,
  const Resources& total,
  const hashmap<FrameworkID, Resources>& used)
{

I will send all the protobufs: slaveId, slaveInfo, each Resource from total
collection and each pair FrameworkID, Resources from used collection.
Yes, you're right, if server becomes unavailable, allocation process will
also stop... Maybe it should proceed in default way, with unchanged
protobufs on some time-out. I'll need to clarify the desired behaviour.

Best regards,
Dariia

On Mon, Jun 8, 2015 at 6:39 PM, Alex Rukletsov <al...@mesosphere.com> wrote:

> Hi Dariia,
>
> interesting! I think you can actually subclass the Hierarchical allocator,
> but you need access to Mesos sources (quick check of your code hints you
> need it nevertheless since you build unbundled Mesos).
>
> What protobufs do you plan to send to your Go server? Allocator maintains a
> list of available resources and registered frameworks and periodically
> makes offers. Also, in your design it looks like if the Go server becomes
> unavailable, there will be no offers made.
>
> On Fri, May 29, 2015 at 3:20 PM, Dariia Zhyrova <dz...@cogniance.com>
> wrote:
>
> > Hi Alex,
> >
> > My task was to create allocator which produces information about all
> > protobufs it receives to Kafka (prior to actual resources allocation).
> Here
> > is the implementation: https://github.com/stealthly/alligator. I had to
> > copy-paste Hierarchical allocator from Mesos sources since unfortunately
> > there is no possibility to inherit from it (or use in other way) outside
> > Mesos.
> > Further I will need to implement a custom allocator which sends all
> > protobufs to Go server and then receives them back (changed in some way).
> > In this way it is expected to customize allocation process using Go, not
> > C++.
> >
> > Best regards,
> > Dariia
> >
> > On Thu, May 28, 2015 at 2:54 PM, Alex Rukletsov <al...@mesosphere.com>
> > wrote:
> >
> > > Dariia,
> > >
> > > I'm excited to see people hacking on allocation algorithms in Mesos!
> May
> > I
> > > ask you to share some information about what custom allocation policy
> do
> > > you use? What is the motivation?
> > >
> > > Thanks,
> > > Alex
> > >
> > > On Wed, May 27, 2015 at 8:32 PM, Dariia Zhyrova <
> dzhyrova@cogniance.com>
> > > wrote:
> > >
> > > > Thank you very much! I used an old Mesos version indeed. Using custom
> > > > allocator module works just fine.
> > > > Best reagrds,
> > > > Dariia
> > > >
> > > > On Tue, May 26, 2015 at 6:39 PM, Alex Rukletsov <alex@mesosphere.com
> >
> > > > wrote:
> > > >
> > > > > Dariia,
> > > > >
> > > > > what Mesos version are you using? The ability to write and and use
> > > custom
> > > > > allocator modules without hacking on Mesos source code has just
> > landed
> > > in
> > > > > Mesos (means will be available in 0.23 release) with docs being
> > updated
> > > > > right now (here <https://reviews.apache.org/r/34545/> is the RR
> > > request
> > > > if
> > > > > you really want to be on the bleeding edge).
> > > > >
> > > > > However, if you're on an older version of Mesos, you can still
> write
> > > your
> > > > > own module and replace / adjust the line you refer to in
> > > master/main.cpp
> > > > to
> > > > > support your custom allocator.
> > > > >
> > > > > On Mon, May 25, 2015 at 1:18 PM, Dariia Zhyrova <
> > > dzhyrova@cogniance.com>
> > > > > wrote:
> > > > >
> > > > > > Hello,
> > > > > >
> > > > > > I need to write custom Allocation module, but I don't see a
> > > possibility
> > > > > to
> > > > > > load it dynamically using --modules command line argument.
> > > > > > This is the allocation module creation in master/main:
> > > > > >
> > > > > > allocator::Allocator* allocator = new
> > > > > > allocator::HierarchicalDRFAllocator();
> > > > > >
> > > > > > (so it is just hardcoded)
> > > > > > Other modules are loaded dynamically like this:
> > > > > >
> > > > > > if (flags.modules.isSome()) {
> > > > > >     Try<Nothing> result =
> ModuleManager::load(flags.modules.get());
> > > > > >     if (result.isError()) {
> > > > > >       EXIT(1) << "Error loading modules: " << result.error();
> > > > > >     }
> > > > > >   }
> > > > > > ...
> > > > > > // Create anonymous modules.
> > > > > >   foreach (const string& name, ModuleManager::find<Anonymous>())
> {
> > > > > >     Try<Anonymous*> create =
> > ModuleManager::create<Anonymous>(name);
> > > > > >     if (create.isError()) {
> > > > > >       EXIT(1) << "Failed to create anonymous module named '" <<
> > name
> > > <<
> > > > > > "'";
> > > > > >     }
> > > > > > ...
> > > > > > Authenticator* authenticator;
> > > > > >   // TODO(tillt): Allow multiple authenticators to be loaded and
> > > enable
> > > > > >   // the authenticatee to select the appropriate one. See
> > MESOS-1939.
> > > > > >   if (authenticatorNames[0] == DEFAULT_AUTHENTICATOR) {
> > > > > >     LOG(INFO) << "Using default CRAM-MD5 authenticator";
> > > > > >     authenticator = new cram_md5::CRAMMD5Authenticator();
> > > > > >   } else {
> > > > > >     Try<Authenticator*> module =
> > > > > >
> > > > >
> > modules::ModuleManager::create<Authenticator>(authenticatorNames[0]);
> > > > > >     if (module.isError()) {
> > > > > >       EXIT(1) << "Could not create authenticator module '"
> > > > > >               << authenticatorNames[0] << "': " <<
> module.error();
> > > > > >     }
> > > > > > ...
> > > > > > if (ModuleManager::contains<Isolator>(type)) {
> > > > > >       Try<Isolator*> isolator =
> > > ModuleManager::create<Isolator>(type);
> > > > > >       if (isolator.isError()) {
> > > > > >         return Error(
> > > > > >             "Could not create isolator " + type + ": " +
> > > > > isolator.error());
> > > > > >       }
> > > > > >
> > > > > > This is a list of supported modules which can be loaded
> > dynamically:
> > > > > >  kindToVersion["Anonymous"] = MESOS_VERSION;
> > > > > >   kindToVersion["Authenticatee"] = MESOS_VERSION;
> > > > > >   kindToVersion["Authenticator"] = MESOS_VERSION;
> > > > > >   kindToVersion["Hook"] = MESOS_VERSION;
> > > > > >   kindToVersion["Isolator"] = MESOS_VERSION;
> > > > > >   kindToVersion["TestModule"] = MESOS_VERSION;
> > > > > >
> > > > > > If allocation module is absent here, it will not pass such check:
> > > > > >
> > > > > > Try<Nothing> ModuleManager::verifyModule(
> > > > > >     const string& moduleName,
> > > > > >     const ModuleBase* moduleBase)
> > > > > > {
> > > > > > ...
> > > > > > if (!kindToVersion.contains(moduleBase->kind)) {
> > > > > >     return Error("Unknown module kind: " +
> > > > stringify(moduleBase->kind));
> > > > > >   }
> > > > > > ...
> > > > > > }
> > > > > >
> > > > > > Mesos documentation also does not mention Allocation module as
> > > > > dynamically
> > > > > > loadable:  http://mesos.apache.org/documentation/latest/modules/
> > > > > >
> > > > > > Could you please help me, is there a possibility to use custom
> > > > allocation
> > > > > > module with Mesos?
> > > > > >
> > > > > > Best regards,
> > > > > > Dariia
> > > > > >
> > > > >
> > > >
> > >
> >
>

Re: Custom Mesos Allocation module

Posted by Alex Rukletsov <al...@mesosphere.com>.
Hi Dariia,

interesting! I think you can actually subclass the Hierarchical allocator,
but you need access to Mesos sources (quick check of your code hints you
need it nevertheless since you build unbundled Mesos).

What protobufs do you plan to send to your Go server? Allocator maintains a
list of available resources and registered frameworks and periodically
makes offers. Also, in your design it looks like if the Go server becomes
unavailable, there will be no offers made.

On Fri, May 29, 2015 at 3:20 PM, Dariia Zhyrova <dz...@cogniance.com>
wrote:

> Hi Alex,
>
> My task was to create allocator which produces information about all
> protobufs it receives to Kafka (prior to actual resources allocation). Here
> is the implementation: https://github.com/stealthly/alligator. I had to
> copy-paste Hierarchical allocator from Mesos sources since unfortunately
> there is no possibility to inherit from it (or use in other way) outside
> Mesos.
> Further I will need to implement a custom allocator which sends all
> protobufs to Go server and then receives them back (changed in some way).
> In this way it is expected to customize allocation process using Go, not
> C++.
>
> Best regards,
> Dariia
>
> On Thu, May 28, 2015 at 2:54 PM, Alex Rukletsov <al...@mesosphere.com>
> wrote:
>
> > Dariia,
> >
> > I'm excited to see people hacking on allocation algorithms in Mesos! May
> I
> > ask you to share some information about what custom allocation policy do
> > you use? What is the motivation?
> >
> > Thanks,
> > Alex
> >
> > On Wed, May 27, 2015 at 8:32 PM, Dariia Zhyrova <dz...@cogniance.com>
> > wrote:
> >
> > > Thank you very much! I used an old Mesos version indeed. Using custom
> > > allocator module works just fine.
> > > Best reagrds,
> > > Dariia
> > >
> > > On Tue, May 26, 2015 at 6:39 PM, Alex Rukletsov <al...@mesosphere.com>
> > > wrote:
> > >
> > > > Dariia,
> > > >
> > > > what Mesos version are you using? The ability to write and and use
> > custom
> > > > allocator modules without hacking on Mesos source code has just
> landed
> > in
> > > > Mesos (means will be available in 0.23 release) with docs being
> updated
> > > > right now (here <https://reviews.apache.org/r/34545/> is the RR
> > request
> > > if
> > > > you really want to be on the bleeding edge).
> > > >
> > > > However, if you're on an older version of Mesos, you can still write
> > your
> > > > own module and replace / adjust the line you refer to in
> > master/main.cpp
> > > to
> > > > support your custom allocator.
> > > >
> > > > On Mon, May 25, 2015 at 1:18 PM, Dariia Zhyrova <
> > dzhyrova@cogniance.com>
> > > > wrote:
> > > >
> > > > > Hello,
> > > > >
> > > > > I need to write custom Allocation module, but I don't see a
> > possibility
> > > > to
> > > > > load it dynamically using --modules command line argument.
> > > > > This is the allocation module creation in master/main:
> > > > >
> > > > > allocator::Allocator* allocator = new
> > > > > allocator::HierarchicalDRFAllocator();
> > > > >
> > > > > (so it is just hardcoded)
> > > > > Other modules are loaded dynamically like this:
> > > > >
> > > > > if (flags.modules.isSome()) {
> > > > >     Try<Nothing> result = ModuleManager::load(flags.modules.get());
> > > > >     if (result.isError()) {
> > > > >       EXIT(1) << "Error loading modules: " << result.error();
> > > > >     }
> > > > >   }
> > > > > ...
> > > > > // Create anonymous modules.
> > > > >   foreach (const string& name, ModuleManager::find<Anonymous>()) {
> > > > >     Try<Anonymous*> create =
> ModuleManager::create<Anonymous>(name);
> > > > >     if (create.isError()) {
> > > > >       EXIT(1) << "Failed to create anonymous module named '" <<
> name
> > <<
> > > > > "'";
> > > > >     }
> > > > > ...
> > > > > Authenticator* authenticator;
> > > > >   // TODO(tillt): Allow multiple authenticators to be loaded and
> > enable
> > > > >   // the authenticatee to select the appropriate one. See
> MESOS-1939.
> > > > >   if (authenticatorNames[0] == DEFAULT_AUTHENTICATOR) {
> > > > >     LOG(INFO) << "Using default CRAM-MD5 authenticator";
> > > > >     authenticator = new cram_md5::CRAMMD5Authenticator();
> > > > >   } else {
> > > > >     Try<Authenticator*> module =
> > > > >
> > > >
> modules::ModuleManager::create<Authenticator>(authenticatorNames[0]);
> > > > >     if (module.isError()) {
> > > > >       EXIT(1) << "Could not create authenticator module '"
> > > > >               << authenticatorNames[0] << "': " << module.error();
> > > > >     }
> > > > > ...
> > > > > if (ModuleManager::contains<Isolator>(type)) {
> > > > >       Try<Isolator*> isolator =
> > ModuleManager::create<Isolator>(type);
> > > > >       if (isolator.isError()) {
> > > > >         return Error(
> > > > >             "Could not create isolator " + type + ": " +
> > > > isolator.error());
> > > > >       }
> > > > >
> > > > > This is a list of supported modules which can be loaded
> dynamically:
> > > > >  kindToVersion["Anonymous"] = MESOS_VERSION;
> > > > >   kindToVersion["Authenticatee"] = MESOS_VERSION;
> > > > >   kindToVersion["Authenticator"] = MESOS_VERSION;
> > > > >   kindToVersion["Hook"] = MESOS_VERSION;
> > > > >   kindToVersion["Isolator"] = MESOS_VERSION;
> > > > >   kindToVersion["TestModule"] = MESOS_VERSION;
> > > > >
> > > > > If allocation module is absent here, it will not pass such check:
> > > > >
> > > > > Try<Nothing> ModuleManager::verifyModule(
> > > > >     const string& moduleName,
> > > > >     const ModuleBase* moduleBase)
> > > > > {
> > > > > ...
> > > > > if (!kindToVersion.contains(moduleBase->kind)) {
> > > > >     return Error("Unknown module kind: " +
> > > stringify(moduleBase->kind));
> > > > >   }
> > > > > ...
> > > > > }
> > > > >
> > > > > Mesos documentation also does not mention Allocation module as
> > > > dynamically
> > > > > loadable:  http://mesos.apache.org/documentation/latest/modules/
> > > > >
> > > > > Could you please help me, is there a possibility to use custom
> > > allocation
> > > > > module with Mesos?
> > > > >
> > > > > Best regards,
> > > > > Dariia
> > > > >
> > > >
> > >
> >
>

Re: Custom Mesos Allocation module

Posted by Dariia Zhyrova <dz...@cogniance.com>.
Hi Alex,

My task was to create allocator which produces information about all
protobufs it receives to Kafka (prior to actual resources allocation). Here
is the implementation: https://github.com/stealthly/alligator. I had to
copy-paste Hierarchical allocator from Mesos sources since unfortunately
there is no possibility to inherit from it (or use in other way) outside
Mesos.
Further I will need to implement a custom allocator which sends all
protobufs to Go server and then receives them back (changed in some way).
In this way it is expected to customize allocation process using Go, not
C++.

Best regards,
Dariia

On Thu, May 28, 2015 at 2:54 PM, Alex Rukletsov <al...@mesosphere.com> wrote:

> Dariia,
>
> I'm excited to see people hacking on allocation algorithms in Mesos! May I
> ask you to share some information about what custom allocation policy do
> you use? What is the motivation?
>
> Thanks,
> Alex
>
> On Wed, May 27, 2015 at 8:32 PM, Dariia Zhyrova <dz...@cogniance.com>
> wrote:
>
> > Thank you very much! I used an old Mesos version indeed. Using custom
> > allocator module works just fine.
> > Best reagrds,
> > Dariia
> >
> > On Tue, May 26, 2015 at 6:39 PM, Alex Rukletsov <al...@mesosphere.com>
> > wrote:
> >
> > > Dariia,
> > >
> > > what Mesos version are you using? The ability to write and and use
> custom
> > > allocator modules without hacking on Mesos source code has just landed
> in
> > > Mesos (means will be available in 0.23 release) with docs being updated
> > > right now (here <https://reviews.apache.org/r/34545/> is the RR
> request
> > if
> > > you really want to be on the bleeding edge).
> > >
> > > However, if you're on an older version of Mesos, you can still write
> your
> > > own module and replace / adjust the line you refer to in
> master/main.cpp
> > to
> > > support your custom allocator.
> > >
> > > On Mon, May 25, 2015 at 1:18 PM, Dariia Zhyrova <
> dzhyrova@cogniance.com>
> > > wrote:
> > >
> > > > Hello,
> > > >
> > > > I need to write custom Allocation module, but I don't see a
> possibility
> > > to
> > > > load it dynamically using --modules command line argument.
> > > > This is the allocation module creation in master/main:
> > > >
> > > > allocator::Allocator* allocator = new
> > > > allocator::HierarchicalDRFAllocator();
> > > >
> > > > (so it is just hardcoded)
> > > > Other modules are loaded dynamically like this:
> > > >
> > > > if (flags.modules.isSome()) {
> > > >     Try<Nothing> result = ModuleManager::load(flags.modules.get());
> > > >     if (result.isError()) {
> > > >       EXIT(1) << "Error loading modules: " << result.error();
> > > >     }
> > > >   }
> > > > ...
> > > > // Create anonymous modules.
> > > >   foreach (const string& name, ModuleManager::find<Anonymous>()) {
> > > >     Try<Anonymous*> create = ModuleManager::create<Anonymous>(name);
> > > >     if (create.isError()) {
> > > >       EXIT(1) << "Failed to create anonymous module named '" << name
> <<
> > > > "'";
> > > >     }
> > > > ...
> > > > Authenticator* authenticator;
> > > >   // TODO(tillt): Allow multiple authenticators to be loaded and
> enable
> > > >   // the authenticatee to select the appropriate one. See MESOS-1939.
> > > >   if (authenticatorNames[0] == DEFAULT_AUTHENTICATOR) {
> > > >     LOG(INFO) << "Using default CRAM-MD5 authenticator";
> > > >     authenticator = new cram_md5::CRAMMD5Authenticator();
> > > >   } else {
> > > >     Try<Authenticator*> module =
> > > >
> > >  modules::ModuleManager::create<Authenticator>(authenticatorNames[0]);
> > > >     if (module.isError()) {
> > > >       EXIT(1) << "Could not create authenticator module '"
> > > >               << authenticatorNames[0] << "': " << module.error();
> > > >     }
> > > > ...
> > > > if (ModuleManager::contains<Isolator>(type)) {
> > > >       Try<Isolator*> isolator =
> ModuleManager::create<Isolator>(type);
> > > >       if (isolator.isError()) {
> > > >         return Error(
> > > >             "Could not create isolator " + type + ": " +
> > > isolator.error());
> > > >       }
> > > >
> > > > This is a list of supported modules which can be loaded dynamically:
> > > >  kindToVersion["Anonymous"] = MESOS_VERSION;
> > > >   kindToVersion["Authenticatee"] = MESOS_VERSION;
> > > >   kindToVersion["Authenticator"] = MESOS_VERSION;
> > > >   kindToVersion["Hook"] = MESOS_VERSION;
> > > >   kindToVersion["Isolator"] = MESOS_VERSION;
> > > >   kindToVersion["TestModule"] = MESOS_VERSION;
> > > >
> > > > If allocation module is absent here, it will not pass such check:
> > > >
> > > > Try<Nothing> ModuleManager::verifyModule(
> > > >     const string& moduleName,
> > > >     const ModuleBase* moduleBase)
> > > > {
> > > > ...
> > > > if (!kindToVersion.contains(moduleBase->kind)) {
> > > >     return Error("Unknown module kind: " +
> > stringify(moduleBase->kind));
> > > >   }
> > > > ...
> > > > }
> > > >
> > > > Mesos documentation also does not mention Allocation module as
> > > dynamically
> > > > loadable:  http://mesos.apache.org/documentation/latest/modules/
> > > >
> > > > Could you please help me, is there a possibility to use custom
> > allocation
> > > > module with Mesos?
> > > >
> > > > Best regards,
> > > > Dariia
> > > >
> > >
> >
>

Re: Custom Mesos Allocation module

Posted by Alex Rukletsov <al...@mesosphere.com>.
Dariia,

I'm excited to see people hacking on allocation algorithms in Mesos! May I
ask you to share some information about what custom allocation policy do
you use? What is the motivation?

Thanks,
Alex

On Wed, May 27, 2015 at 8:32 PM, Dariia Zhyrova <dz...@cogniance.com>
wrote:

> Thank you very much! I used an old Mesos version indeed. Using custom
> allocator module works just fine.
> Best reagrds,
> Dariia
>
> On Tue, May 26, 2015 at 6:39 PM, Alex Rukletsov <al...@mesosphere.com>
> wrote:
>
> > Dariia,
> >
> > what Mesos version are you using? The ability to write and and use custom
> > allocator modules without hacking on Mesos source code has just landed in
> > Mesos (means will be available in 0.23 release) with docs being updated
> > right now (here <https://reviews.apache.org/r/34545/> is the RR request
> if
> > you really want to be on the bleeding edge).
> >
> > However, if you're on an older version of Mesos, you can still write your
> > own module and replace / adjust the line you refer to in master/main.cpp
> to
> > support your custom allocator.
> >
> > On Mon, May 25, 2015 at 1:18 PM, Dariia Zhyrova <dz...@cogniance.com>
> > wrote:
> >
> > > Hello,
> > >
> > > I need to write custom Allocation module, but I don't see a possibility
> > to
> > > load it dynamically using --modules command line argument.
> > > This is the allocation module creation in master/main:
> > >
> > > allocator::Allocator* allocator = new
> > > allocator::HierarchicalDRFAllocator();
> > >
> > > (so it is just hardcoded)
> > > Other modules are loaded dynamically like this:
> > >
> > > if (flags.modules.isSome()) {
> > >     Try<Nothing> result = ModuleManager::load(flags.modules.get());
> > >     if (result.isError()) {
> > >       EXIT(1) << "Error loading modules: " << result.error();
> > >     }
> > >   }
> > > ...
> > > // Create anonymous modules.
> > >   foreach (const string& name, ModuleManager::find<Anonymous>()) {
> > >     Try<Anonymous*> create = ModuleManager::create<Anonymous>(name);
> > >     if (create.isError()) {
> > >       EXIT(1) << "Failed to create anonymous module named '" << name <<
> > > "'";
> > >     }
> > > ...
> > > Authenticator* authenticator;
> > >   // TODO(tillt): Allow multiple authenticators to be loaded and enable
> > >   // the authenticatee to select the appropriate one. See MESOS-1939.
> > >   if (authenticatorNames[0] == DEFAULT_AUTHENTICATOR) {
> > >     LOG(INFO) << "Using default CRAM-MD5 authenticator";
> > >     authenticator = new cram_md5::CRAMMD5Authenticator();
> > >   } else {
> > >     Try<Authenticator*> module =
> > >
> >  modules::ModuleManager::create<Authenticator>(authenticatorNames[0]);
> > >     if (module.isError()) {
> > >       EXIT(1) << "Could not create authenticator module '"
> > >               << authenticatorNames[0] << "': " << module.error();
> > >     }
> > > ...
> > > if (ModuleManager::contains<Isolator>(type)) {
> > >       Try<Isolator*> isolator = ModuleManager::create<Isolator>(type);
> > >       if (isolator.isError()) {
> > >         return Error(
> > >             "Could not create isolator " + type + ": " +
> > isolator.error());
> > >       }
> > >
> > > This is a list of supported modules which can be loaded dynamically:
> > >  kindToVersion["Anonymous"] = MESOS_VERSION;
> > >   kindToVersion["Authenticatee"] = MESOS_VERSION;
> > >   kindToVersion["Authenticator"] = MESOS_VERSION;
> > >   kindToVersion["Hook"] = MESOS_VERSION;
> > >   kindToVersion["Isolator"] = MESOS_VERSION;
> > >   kindToVersion["TestModule"] = MESOS_VERSION;
> > >
> > > If allocation module is absent here, it will not pass such check:
> > >
> > > Try<Nothing> ModuleManager::verifyModule(
> > >     const string& moduleName,
> > >     const ModuleBase* moduleBase)
> > > {
> > > ...
> > > if (!kindToVersion.contains(moduleBase->kind)) {
> > >     return Error("Unknown module kind: " +
> stringify(moduleBase->kind));
> > >   }
> > > ...
> > > }
> > >
> > > Mesos documentation also does not mention Allocation module as
> > dynamically
> > > loadable:  http://mesos.apache.org/documentation/latest/modules/
> > >
> > > Could you please help me, is there a possibility to use custom
> allocation
> > > module with Mesos?
> > >
> > > Best regards,
> > > Dariia
> > >
> >
>

Re: Custom Mesos Allocation module

Posted by Dariia Zhyrova <dz...@cogniance.com>.
Thank you very much! I used an old Mesos version indeed. Using custom
allocator module works just fine.
Best reagrds,
Dariia

On Tue, May 26, 2015 at 6:39 PM, Alex Rukletsov <al...@mesosphere.com> wrote:

> Dariia,
>
> what Mesos version are you using? The ability to write and and use custom
> allocator modules without hacking on Mesos source code has just landed in
> Mesos (means will be available in 0.23 release) with docs being updated
> right now (here <https://reviews.apache.org/r/34545/> is the RR request if
> you really want to be on the bleeding edge).
>
> However, if you're on an older version of Mesos, you can still write your
> own module and replace / adjust the line you refer to in master/main.cpp to
> support your custom allocator.
>
> On Mon, May 25, 2015 at 1:18 PM, Dariia Zhyrova <dz...@cogniance.com>
> wrote:
>
> > Hello,
> >
> > I need to write custom Allocation module, but I don't see a possibility
> to
> > load it dynamically using --modules command line argument.
> > This is the allocation module creation in master/main:
> >
> > allocator::Allocator* allocator = new
> > allocator::HierarchicalDRFAllocator();
> >
> > (so it is just hardcoded)
> > Other modules are loaded dynamically like this:
> >
> > if (flags.modules.isSome()) {
> >     Try<Nothing> result = ModuleManager::load(flags.modules.get());
> >     if (result.isError()) {
> >       EXIT(1) << "Error loading modules: " << result.error();
> >     }
> >   }
> > ...
> > // Create anonymous modules.
> >   foreach (const string& name, ModuleManager::find<Anonymous>()) {
> >     Try<Anonymous*> create = ModuleManager::create<Anonymous>(name);
> >     if (create.isError()) {
> >       EXIT(1) << "Failed to create anonymous module named '" << name <<
> > "'";
> >     }
> > ...
> > Authenticator* authenticator;
> >   // TODO(tillt): Allow multiple authenticators to be loaded and enable
> >   // the authenticatee to select the appropriate one. See MESOS-1939.
> >   if (authenticatorNames[0] == DEFAULT_AUTHENTICATOR) {
> >     LOG(INFO) << "Using default CRAM-MD5 authenticator";
> >     authenticator = new cram_md5::CRAMMD5Authenticator();
> >   } else {
> >     Try<Authenticator*> module =
> >
>  modules::ModuleManager::create<Authenticator>(authenticatorNames[0]);
> >     if (module.isError()) {
> >       EXIT(1) << "Could not create authenticator module '"
> >               << authenticatorNames[0] << "': " << module.error();
> >     }
> > ...
> > if (ModuleManager::contains<Isolator>(type)) {
> >       Try<Isolator*> isolator = ModuleManager::create<Isolator>(type);
> >       if (isolator.isError()) {
> >         return Error(
> >             "Could not create isolator " + type + ": " +
> isolator.error());
> >       }
> >
> > This is a list of supported modules which can be loaded dynamically:
> >  kindToVersion["Anonymous"] = MESOS_VERSION;
> >   kindToVersion["Authenticatee"] = MESOS_VERSION;
> >   kindToVersion["Authenticator"] = MESOS_VERSION;
> >   kindToVersion["Hook"] = MESOS_VERSION;
> >   kindToVersion["Isolator"] = MESOS_VERSION;
> >   kindToVersion["TestModule"] = MESOS_VERSION;
> >
> > If allocation module is absent here, it will not pass such check:
> >
> > Try<Nothing> ModuleManager::verifyModule(
> >     const string& moduleName,
> >     const ModuleBase* moduleBase)
> > {
> > ...
> > if (!kindToVersion.contains(moduleBase->kind)) {
> >     return Error("Unknown module kind: " + stringify(moduleBase->kind));
> >   }
> > ...
> > }
> >
> > Mesos documentation also does not mention Allocation module as
> dynamically
> > loadable:  http://mesos.apache.org/documentation/latest/modules/
> >
> > Could you please help me, is there a possibility to use custom allocation
> > module with Mesos?
> >
> > Best regards,
> > Dariia
> >
>

Re: Custom Mesos Allocation module

Posted by Alex Rukletsov <al...@mesosphere.com>.
Dariia,

what Mesos version are you using? The ability to write and and use custom
allocator modules without hacking on Mesos source code has just landed in
Mesos (means will be available in 0.23 release) with docs being updated
right now (here <https://reviews.apache.org/r/34545/> is the RR request if
you really want to be on the bleeding edge).

However, if you're on an older version of Mesos, you can still write your
own module and replace / adjust the line you refer to in master/main.cpp to
support your custom allocator.

On Mon, May 25, 2015 at 1:18 PM, Dariia Zhyrova <dz...@cogniance.com>
wrote:

> Hello,
>
> I need to write custom Allocation module, but I don't see a possibility to
> load it dynamically using --modules command line argument.
> This is the allocation module creation in master/main:
>
> allocator::Allocator* allocator = new
> allocator::HierarchicalDRFAllocator();
>
> (so it is just hardcoded)
> Other modules are loaded dynamically like this:
>
> if (flags.modules.isSome()) {
>     Try<Nothing> result = ModuleManager::load(flags.modules.get());
>     if (result.isError()) {
>       EXIT(1) << "Error loading modules: " << result.error();
>     }
>   }
> ...
> // Create anonymous modules.
>   foreach (const string& name, ModuleManager::find<Anonymous>()) {
>     Try<Anonymous*> create = ModuleManager::create<Anonymous>(name);
>     if (create.isError()) {
>       EXIT(1) << "Failed to create anonymous module named '" << name <<
> "'";
>     }
> ...
> Authenticator* authenticator;
>   // TODO(tillt): Allow multiple authenticators to be loaded and enable
>   // the authenticatee to select the appropriate one. See MESOS-1939.
>   if (authenticatorNames[0] == DEFAULT_AUTHENTICATOR) {
>     LOG(INFO) << "Using default CRAM-MD5 authenticator";
>     authenticator = new cram_md5::CRAMMD5Authenticator();
>   } else {
>     Try<Authenticator*> module =
>       modules::ModuleManager::create<Authenticator>(authenticatorNames[0]);
>     if (module.isError()) {
>       EXIT(1) << "Could not create authenticator module '"
>               << authenticatorNames[0] << "': " << module.error();
>     }
> ...
> if (ModuleManager::contains<Isolator>(type)) {
>       Try<Isolator*> isolator = ModuleManager::create<Isolator>(type);
>       if (isolator.isError()) {
>         return Error(
>             "Could not create isolator " + type + ": " + isolator.error());
>       }
>
> This is a list of supported modules which can be loaded dynamically:
>  kindToVersion["Anonymous"] = MESOS_VERSION;
>   kindToVersion["Authenticatee"] = MESOS_VERSION;
>   kindToVersion["Authenticator"] = MESOS_VERSION;
>   kindToVersion["Hook"] = MESOS_VERSION;
>   kindToVersion["Isolator"] = MESOS_VERSION;
>   kindToVersion["TestModule"] = MESOS_VERSION;
>
> If allocation module is absent here, it will not pass such check:
>
> Try<Nothing> ModuleManager::verifyModule(
>     const string& moduleName,
>     const ModuleBase* moduleBase)
> {
> ...
> if (!kindToVersion.contains(moduleBase->kind)) {
>     return Error("Unknown module kind: " + stringify(moduleBase->kind));
>   }
> ...
> }
>
> Mesos documentation also does not mention Allocation module as dynamically
> loadable:  http://mesos.apache.org/documentation/latest/modules/
>
> Could you please help me, is there a possibility to use custom allocation
> module with Mesos?
>
> Best regards,
> Dariia
>

Re: Custom Mesos Allocation module

Posted by Niklas Nielsen <ni...@mesosphere.io>.
Hi Dariia,

Allocator modules was first added to the master May 14th (git sha
614efe18cf3c7b02a2f3c8269c8eb76cbbe4ddd4), which version of the source are
you looking into?

You should be able to configure your allocator module as usual (
https://github.com/apache/mesos/blob/master/docs/modules.md) and select it
through the new --allocator flag.

Let us know if it still doesn't work/make sense.

Cheers,
Niklas

On 25 May 2015 at 04:18, Dariia Zhyrova <dz...@cogniance.com> wrote:

> Hello,
>
> I need to write custom Allocation module, but I don't see a possibility to
> load it dynamically using --modules command line argument.
> This is the allocation module creation in master/main:
>
> allocator::Allocator* allocator = new
> allocator::HierarchicalDRFAllocator();
>
> (so it is just hardcoded)
> Other modules are loaded dynamically like this:
>
> if (flags.modules.isSome()) {
>     Try<Nothing> result = ModuleManager::load(flags.modules.get());
>     if (result.isError()) {
>       EXIT(1) << "Error loading modules: " << result.error();
>     }
>   }
> ...
> // Create anonymous modules.
>   foreach (const string& name, ModuleManager::find<Anonymous>()) {
>     Try<Anonymous*> create = ModuleManager::create<Anonymous>(name);
>     if (create.isError()) {
>       EXIT(1) << "Failed to create anonymous module named '" << name <<
> "'";
>     }
> ...
> Authenticator* authenticator;
>   // TODO(tillt): Allow multiple authenticators to be loaded and enable
>   // the authenticatee to select the appropriate one. See MESOS-1939.
>   if (authenticatorNames[0] == DEFAULT_AUTHENTICATOR) {
>     LOG(INFO) << "Using default CRAM-MD5 authenticator";
>     authenticator = new cram_md5::CRAMMD5Authenticator();
>   } else {
>     Try<Authenticator*> module =
>       modules::ModuleManager::create<Authenticator>(authenticatorNames[0]);
>     if (module.isError()) {
>       EXIT(1) << "Could not create authenticator module '"
>               << authenticatorNames[0] << "': " << module.error();
>     }
> ...
> if (ModuleManager::contains<Isolator>(type)) {
>       Try<Isolator*> isolator = ModuleManager::create<Isolator>(type);
>       if (isolator.isError()) {
>         return Error(
>             "Could not create isolator " + type + ": " + isolator.error());
>       }
>
> This is a list of supported modules which can be loaded dynamically:
>  kindToVersion["Anonymous"] = MESOS_VERSION;
>   kindToVersion["Authenticatee"] = MESOS_VERSION;
>   kindToVersion["Authenticator"] = MESOS_VERSION;
>   kindToVersion["Hook"] = MESOS_VERSION;
>   kindToVersion["Isolator"] = MESOS_VERSION;
>   kindToVersion["TestModule"] = MESOS_VERSION;
>
> If allocation module is absent here, it will not pass such check:
>
> Try<Nothing> ModuleManager::verifyModule(
>     const string& moduleName,
>     const ModuleBase* moduleBase)
> {
> ...
> if (!kindToVersion.contains(moduleBase->kind)) {
>     return Error("Unknown module kind: " + stringify(moduleBase->kind));
>   }
> ...
> }
>
> Mesos documentation also does not mention Allocation module as dynamically
> loadable:  http://mesos.apache.org/documentation/latest/modules/
>
> Could you please help me, is there a possibility to use custom allocation
> module with Mesos?
>
> Best regards,
> Dariia
>