An Apache Mesos framework for Riak KV, a distributed NoSQL key-value data store that offers high availability, fault tolerance, operational simplicity, and scalability.
Note: This project is an early proof of concept. The code is a beta release and there may be bugs, incomplete features, incorrect documentation or other discrepancies.
Please refer to the documentation in riak-mesos-tools for information about installation and usage of the Riak Mesos Framework.
For build and testing information, visit docs/DEVELOPMENT.md.
The Riak Mesos Framework is typically deployed as a marathon app via a CLI tool such as riak-mesos or dcos riak. Once deployed, it can accept commands which result in the creation of Riak nodes as additional tasks on other Mesos agents.

The Riak Mesos Framework scheduler is currently written in Golang due to mesos-go's usage of HTTP API calls accessible in the Mesos Master. The alternative language bindings mostly rely on libmesos.so which is more difficult to debug and work with in general.
The scheduler will attempt to spread Riak nodes across as many different mesos agents as possible to increase fault tolerance. If there are more nodes requested than there are agents available, the scheduler will then start adding more Riak nodes to existing agents. Following is a flowchart describing the basic logic followed by the scheduler to reserve resources, create persistent volumes, launch Riak nodes, and handle status updates for those nodes:

The executor manages a few processes including the Riak process itself and an EPMD replacement, and the Riak node process itself. We chose to have the executor run natively on the host machine using the Mesos containerizer in order to avoid usage of Docker due to concerns about its stability in certain Mesos environments. This creates a slightly more complicated build process since Erlang packages need to be built per platform, but it increases the reliability of the Mesos tasks.
In normal environments, distributed erlang applications communicate with each other by attempting to connect on EPMD's default port, which then communicates the necessary connection information between the two applications. In a Mesos environment however, it is not always possible to assume that a port (such as EPMD's) will be available for binding, so we wrote a replacement called cEPMD to deal with this issue. cEPMD listens on a random port available on the Mesos agent, and coordinates which ports each node can talk on by storing that information in Zookeeper.
What happens when the Riak Mesos Scheduler fails?
In order to survive a scheduler failure without affecting a running set of tasks (Riak nodes in this case), the scheduler needs to implement a few things. The DCOS Service Specification is a great place to start when trying to find ways to make a scheduler more fault tolerant.
The Riak Mesos Scheduler does the following to deal with potential failures:
With the above features implemented, the workflow for the scheduler startup process looks like this (with or without a failure):
What happens when a Riak Mesos Executor or Riak node fails?
The executor also needs to employ some features for fault tolerance, much like the scheduler. The Riak Mesos Executor does the following:
RESERVE operation before launching tasks allows a task to be launched on the same Mesos agent again after a failure without the possibility of another framework taking those resources before a failover can take place.CREATE opertaion before launching tasks (and after a RESERVE operation) instructs Mesos agents to create a volume for stateful data (such as the Riak data directory) which exists outside of the tasks container (which is normally deleted with garbage collection if a task fails).Given those features, the following is what a node launch workflow looks like (from the point of view of the scheduler):
createNode operation from the API (user initiated).RESERVE operation to reserve the required resources on the Mesos agent.CREATE operation to create a persistent volume on the Mesos agent for the Riak data.LAUNCH operation to launch the Riak Mesos Executor / Riak node on the given Mesos agent.TASK_RUNNING update back to the scheduler through Mesos.The node failure workflow looks like the following:
TASK_ERROR, TASK_LOST, TASK_FAILED, or TASK_KILLED. LAUNCH operation on the same Mesos agent and the same persistence id by looking up metadata for that Riak node previously stored in Zookeeper.riak.conf and advanced.config templates which could have been updated via the scheduler's API.TASK_RUNNING upate to the scheduler through Mesos. The scheduler can then perform cluster logic operations as described above.Due to the nature of Apache Mesos and the potential for Riak nodes to come and go on a regular basis, client applications using a Mesos based cluster must be kept up to date on the cluster's current state. Instead of requiring this intelligence to be built into Riak client libraries, a smart proxy application named Director has been created which can run alongside client applications.

For more information related to the Riak Mesos Director, please read docs/DIRECTOR.md
$ claude mcp add riak-mesos-legacy \
-- python -m otcore.mcp_server <graph>