You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@mesos.apache.org by "Kapil Arya (JIRA)" <ji...@apache.org> on 2014/11/24 20:43:12 UTC

[jira] [Commented] (MESOS-2060) Add support for 'hooks' in task launch sequence

    [ https://issues.apache.org/jira/browse/MESOS-2060?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14223392#comment-14223392 ] 

Kapil Arya commented on MESOS-2060:
-----------------------------------

Taking a few hints from the discussion on the mailing list, we have updated the design slightly. Here are the updates:

1. Create hooks for entry points only.  Due to the future-promise nature of events, having exit/post hooks doesn't make much sense.  If need arises later, we can revisit and improve the design.

2. Hooks should return a tuple<> of updated incoming arguments so that we can update those arguments at the call site.


{code}
namespace master {

class MasterHooks
{
public:
  virtual std::tuple<TaskInfo, Framework*, Slave*> launchTask(
      const TaskInfo& taskInfo,
      Framework* framework,
      Slave* slave)
  {
    return std::make_tuple(taskInfo, framework, slave);
  }
};

} // namespace master {
{code}

LaunchTaskHook for Master:

{code}
Resources Master::launchTask(
    const TaskInfo& task_,
    Framework* framework_,
    Slave* slave_)
{
  LaunchTaskHook hook(task_, framework_, slave_);
  const TaskInfo& task = hook.updatedTaskInfo();
  Framework* framework = hook.updatedFramework();
  Slave* slave = hook.updatedSlave();
  ...
}
{code}

Calling all installed hooks:
{code}
LaunchTaskHook::LaunchTaskHook(
    const TaskInfo& taskInfo_,
    Framework* framework_,
    Slave* slave_)
{
  tuple<TaskInfo, Framework*, Slave*> result(taskInfo_, framework_, slave_);
  for (vector<Hook*>::iterator it = availableHooks.begin();
      it != availableHooks.end();
      it++) {
    Hook *hook = *it;
    if (hook->masterHooks != NULL) {
      result = hook->masterHooks->launchTask(
          std::get<0>(result),
          std::get<1>(result),
          std::get<2>(result));
    }
  }
  taskInfo = std::get<0>(result);
  framework = std::get<1>(result);
  slave = std::get<2>(result);
}
{code}

> Add support for 'hooks' in task launch sequence
> -----------------------------------------------
>
>                 Key: MESOS-2060
>                 URL: https://issues.apache.org/jira/browse/MESOS-2060
>             Project: Mesos
>          Issue Type: Task
>          Components: modules
>            Reporter: Niklas Quarfot Nielsen
>            Assignee: Kapil Arya
>
> Similar to Apache Modules, hooks allows module writers to tie into internal components which may not be suitable to be abstracted entirely behind modules but rather let's them define actions on so-called hooks (http://httpd.apache.org/docs/2.2/developer/hooks.html).
> In Apache Web Server, this lets people tie into the request processing cycle, in Mesos one place interesting place to start could be pre and post actions for master and slave task launch sequence.
> Examples could be external statistics/metrics gathering, security infrastructure etc. 
> The main idea is to enable modules to register themselves as hook providers and select them through a new flag: --hooks=”module_name1, module_name2, ...”. This will require a new module type called 'HookModule'.
> A new ‘HookManager’ will query each module and get an object back of type ‘Hooks’ which has virtual member functions which points to the desired callbacks in the module.
> For example,
> {code}
> class Hooks {
> public:
>   virtual TaskInfo preMasterLaunchTask(TaskInfo task) = 0;
>   virtual TaskInfo postMasterLaunchTask(TaskInfo task) = 0;
>   virtual TaskInfo preSlaveLaunchTask(TaskInfo task) = 0;
>   virtual TaskInfo postSlaveLaunchTask(TaskInfo task) = 0;
>   // ...
> };
> {code}
> An example of the call site in Mesos could be:
> {code}
> Master::launchTask(..., TaskInfo task, ...)
> {
>   task = HookManager::preMasterLaunchTask(task);
>   ...
>   task = HookManager::postMasterLaunchTask(task);
> }
> {code}
> With regards to versioning, hooks gets run inline with internal mesos code - so we would suggest a conservative policy where hook modules need to be compiled against the current version of Mesos.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)