An Akka based Mesos actor for creating Mesos frameworks.
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Build Status codecov

Actor library for Apache Mesos.

A lightweight meta-framework for assembling Apache Mesos Frameworks (schedulers). Based on:


See SampleFramework.scala for an example framework that:

  • initiates the Apache Mesos Client subscription
  • submits some tasks for execution
  • kills the tasks after some time
  • shuts down the Apache Mesos Client on application termination


To use in your own application:

  • add dependencies to your app


    //for mesos-actor
    compile "com.adobe.api.platform.runtime:mesos-actor:0.0.1"
  • implement a custom task matcher, if desired

This trait is used to match pending tasks with received offers.

Implement the com.adobe.api.platform.runtime.mesos.TaskMatcher trait Default is com.adobe.api.platform.runtime.mesos.DefaultTaskMatcher

  • implement a custom task builder, if desired

This trait is used to build TaskInfo objects for Offers that have been matched.

Implement the com.adobe.api.platform.runtime.mesos.TaskBuilder trait Default is com.adobe.api.platform.runtime.mesos.DefaultTaskBuilder

  • init the client:
    val mesosClientActor = system.actorOf(MesosClient.props(
        "sample-" + UUID.randomUUID(), //start with a new id (TODO: persist this id so restart will fail over to new instance)
        "", //your mesos master ip
        "sample-role", //role for this framework
        30.seconds, //failover timeout      
        yourTaskMatcher, //optional
        yourTaskBuilder  //optional

    //use ask pattern to wait for Subscribe to complete:
    mesosClientActor.ask(Subscribe)(subscribeTimeout).mapTo[SubscribeComplete].onComplete(complete => {"subscribe completed successfully...")


You will need a mesos master and one or more mesos agents running.

  • run a mesos master+agent using docker-compose (tested with docker-machine; specify the IP of your docker-machine VM):
DOCKER_IP= docker-compose up
  • run your application


For a highly available framework, multiple instances of the framework must be deployed:

  • Only one of those instances should be the leader
  • Only the leader should subscribe to Mesos
  • When the leader instance dies, another instance should take the leadership role
  • The new leader should create a new subscription to Mesos master using the same framework id
  • The new leader should reconcile exising tasks, and resume managing the tasks started previously

See SampleHAFramework.scala for an example.

Running an HA example

Build the project

$ make all

This command builds the sample and a docker image that can be deployed in Apache Mesos via Marathon.

Start an Apache Mesos Cluster

$ DOCKER_IP= docker-compose up 

NOTE: the command above assumes that docker-machine's IP is:

Browse to:

Deploy the framework via Marathon:

$ curl --data @./marathon-config/marathon-app-local.json -H "Content-type: application/json"

After a short while the Apache Mesos UI should display a few tasks running, and a new framework should be registered.

Testing HA

Restart the Marathon app:

$ curl -X POST

Marathon should start new instances, wait until they become healthy, and then destroy the previous ones. When the previous leader is destroyed, the framework should show as inactive in Apache Mesos. Once a new leader is selected, the framework should then show back as active.