Code Monkey home page Code Monkey logo

mesos-actor's Introduction

Actor library for Apache Mesos.

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

Example

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

Usage

To use in your own application:

  • add dependencies to your app

Gradle:

    //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)
        "sample-framework",
        "http://192.168.99.100:5050", //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 => {
        log.info("subscribe completed successfully...")
    })

Running

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=192.168.99.100 docker-compose up
  • run your application

HA

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=192.168.99.100 docker-compose up 

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

Browse to:

Deploy the framework via Marathon:

$ curl http://192.168.99.100:8080/v2/apps/ --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 http://192.168.99.100:8080/v2/apps/akka-cluster/restart

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.

mesos-actor's People

Contributors

tysonnorris avatar ddragosd avatar mcdan avatar

Watchers

 avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.