Skip to content

Commit

Permalink
Added remove-executor hook for slave.
Browse files Browse the repository at this point in the history
  • Loading branch information
karya0 authored and Niklas Q. Nielsen committed Jan 14, 2015
1 parent f6bcb08 commit 0773763
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/hook/hook.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,16 @@ class Hook
{
return None();
}

// This hook is called from within slave when an executor is being
// removed. A typical module implementing the hook will perform
// some cleanup as required.
virtual Try<Nothing> slaveRemoveExecutorHook(
const FrameworkInfo& frameworkInfo,
const ExecutorInfo& executorInfo)
{
return Nothing();
}
};

} // namespace internal {
Expand Down
15 changes: 15 additions & 0 deletions src/hook/manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,5 +132,20 @@ Environment HookManager::slaveLaunchExecutorEnvironmentDecorator(
return environment;
}


void HookManager::slaveRemoveExecutorHook(
const FrameworkInfo& frameworkInfo,
const ExecutorInfo& executorInfo)
{
foreachpair (const string& name, Hook* hook, availableHooks) {
const Try<Nothing>& result =
hook->slaveRemoveExecutorHook(frameworkInfo, executorInfo);
if (result.isError()) {
LOG(WARNING) << "Slave remove executor hook failed for module '"
<< name << "': " << result.error();
}
}
}

} // namespace internal {
} // namespace mesos {
4 changes: 4 additions & 0 deletions src/hook/manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ class HookManager
static Environment slaveLaunchExecutorEnvironmentDecorator(
const ExecutorInfo& executorInfo,
const TaskInfo& taskInfo);

static void slaveRemoveExecutorHook(
const FrameworkInfo& frameworkInfo,
const ExecutorInfo& executorInfo);
};

} // namespace internal {
Expand Down
2 changes: 2 additions & 0 deletions src/slave/slave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3123,6 +3123,8 @@ void Slave::removeExecutor(Framework* framework, Executor* executor)
}
}

HookManager::slaveRemoveExecutorHook(framework->info, executor->info);

framework->destroyExecutor(executor->id);
}

Expand Down

0 comments on commit 0773763

Please sign in to comment.