clojusc / mesomatic

A simple and idiomatic Clojure facade around the Mesos JAVA API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature: Add new Operation type

oubiwann opened this issue · comments

There is a new type in Mesos called "operation" which is used by the new "offers" functions in the driver API. We need to add this to Mesomatic.

In particular, Mesomatic will need to add a set of functions and a protocol for org.apache.mesos.Protos$Offer$Operation in types.clj.

Note that the javadocs generated by Mesos only have placeholders for the new PB additions and don't have the actual docs. However, one can view the source here:

  • src/java/generated/org/apache/mesos/Protos.java

In particular, this may be helpful:

$ grep Offer.Operation src/java/generated/org/apache/mesos/Protos.java |grep public

Specific tasks:

  • Update import section in types.clj
  • Create pb->data for operation types (Protos$Offer$Operation$Type/LAUNCH, RESERVE, UNRESERVE, CREATE, DESTROY)
  • Create record for Operation
  • Create method for pb->data Protos$Offer$Operation
  • Update Operation record and its data->pb method to support LAUNCH type
  • Update Operation record and its data->pb method to support RESERVE type
  • Update Operation record and its data->pb method to support UNRESERVE type
  • Update Operation record and its data->pb method to support CREATE type
  • Update Operation record and its data->pb method to support DESTROY type
  • Update ->pb with map conversions

Upon further consideration, I think a better approach that what I'd first planned is to work with maps something like the following:

  {:operation 
    {:type :launch
     :tasks [...]}}

   {:operation 
    {:type :reserve
     :resources [...]}}

   {:operation 
    {:type :unreserve
     :resources [...]}}

   {:operation 
    {:type :create
     :volumes [...]}}

   {:operation 
    {:type :destroy
     :volumes [...]}}

This maintains symmetry with the rest of Mesomatic's types. It also means a little more type boilerplate (but worth it).

The ->pb function will then work with this data structure analogously to how it works with the others, using something like Operation and iterating over tasks, resources, or volumes as the case may be.

The one bit that's not clear yet (and won't be until some more code is written) is if this will all be done in an Operation implementation (e.g., in a case or cond), or if I'll need to create Launch, Reserve, Unreserve, Create, and Destroy implementations.

Okay, I think I'm pretty close to a first draft.

Will switch over to ticket #12 and use that to test this one ...

PR #14 has been submitted for this work.

The work for this has been merged now 😄