You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by nn...@apache.org on 2015/02/10 19:22:43 UTC

[9/9] mesos git commit: Out of tree build 9: Exposed Hook headers.

Out of tree build 9: Exposed Hook headers.

Moved hook/hook.hpp to include/mesos/ and module/hook.hpp to
include/mesos/module.

Review: https://reviews.apache.org/r/30052


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/c6361c55
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/c6361c55
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/c6361c55

Branch: refs/heads/master
Commit: c6361c556d1be54c7e320d65320aae20336c0f16
Parents: dd3870c
Author: Kapil Arya <ka...@mesosphere.io>
Authored: Tue Feb 10 09:56:36 2015 -0800
Committer: Niklas Q. Nielsen <ni...@mesosphere.io>
Committed: Tue Feb 10 09:56:36 2015 -0800

----------------------------------------------------------------------
 include/mesos/hook.hpp            | 73 +++++++++++++++++++++++++++++++++
 include/mesos/module/hook.hpp     | 64 +++++++++++++++++++++++++++++
 src/Makefile.am                   |  4 +-
 src/examples/test_hook_module.cpp |  8 ++--
 src/hook/hook.hpp                 | 74 ----------------------------------
 src/hook/manager.cpp              |  6 ++-
 src/hook/manager.hpp              |  5 +--
 src/module/hook.hpp               | 65 -----------------------------
 8 files changed, 148 insertions(+), 151 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/c6361c55/include/mesos/hook.hpp
----------------------------------------------------------------------
diff --git a/include/mesos/hook.hpp b/include/mesos/hook.hpp
new file mode 100644
index 0000000..d83ace5
--- /dev/null
+++ b/include/mesos/hook.hpp
@@ -0,0 +1,73 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __MESOS_HOOK_HPP__
+#define __MESOS_HOOK_HPP__
+
+#include <mesos/mesos.hpp>
+
+#include <stout/none.hpp>
+#include <stout/nothing.hpp>
+#include <stout/result.hpp>
+#include <stout/try.hpp>
+
+namespace mesos {
+
+class Hook
+{
+public:
+  virtual ~Hook() {};
+
+  // This label decorator hook is called from within master during
+  // the launchTask routine.  A module implementing the hook creates
+  // and returns a set of labels.  These labels are then merged with
+  // the task labels and passed on to the slave/executor.
+  virtual Result<Labels> masterLaunchTaskLabelDecorator(
+      const TaskInfo& taskInfo,
+      const FrameworkInfo& frameworkInfo,
+      const SlaveInfo& slaveInfo)
+  {
+    return None();
+  }
+
+  // This environment decorator hook is called from within slave
+  // when launching a new executor.  A module implementing the hook
+  // creates and returns a set of environment variables.  These
+  // environment variables are then merged into the executorInfo
+  // and become part of the executor's environment.
+  virtual Result<Environment> slaveLaunchExecutorEnvironmentDecorator(
+      const ExecutorInfo& executorInfo,
+      const TaskInfo& taskInfo)
+  {
+    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 mesos {
+
+#endif // __MESOS_HOOK_HPP__

http://git-wip-us.apache.org/repos/asf/mesos/blob/c6361c55/include/mesos/module/hook.hpp
----------------------------------------------------------------------
diff --git a/include/mesos/module/hook.hpp b/include/mesos/module/hook.hpp
new file mode 100644
index 0000000..a474e2b
--- /dev/null
+++ b/include/mesos/module/hook.hpp
@@ -0,0 +1,64 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __MESOS_MODULE_HOOK_HPP__
+#define __MESOS_MODULE_HOOK_HPP__
+
+#include <mesos/hook.hpp>
+#include <mesos/mesos.hpp>
+#include <mesos/module.hpp>
+
+namespace mesos {
+namespace modules {
+
+template<>
+inline const char* kind<mesos::Hook>()
+{
+  return "Hook";
+}
+
+
+template <>
+struct Module<mesos::Hook> : ModuleBase
+{
+  Module(
+      const char* _moduleApiVersion,
+      const char* _mesosVersion,
+      const char* _authorName,
+      const char* _authorEmail,
+      const char* _description,
+      bool (*_compatible)(),
+      mesos::Hook* (*_create)(const Parameters& parameters))
+    : ModuleBase(
+        _moduleApiVersion,
+        _mesosVersion,
+        mesos::modules::kind<mesos::Hook>(),
+        _authorName,
+        _authorEmail,
+        _description,
+        _compatible),
+      create(_create)
+  { }
+
+  mesos::Hook* (*create)(const Parameters& parameters);
+};
+
+} // namespace modules {
+} // namespace mesos {
+
+#endif // __MESOS_MODULE_HOOK_HPP__

http://git-wip-us.apache.org/repos/asf/mesos/blob/c6361c55/src/Makefile.am
----------------------------------------------------------------------
diff --git a/src/Makefile.am b/src/Makefile.am
index 7e40388..fae36ac 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -355,6 +355,7 @@ libmesos_no_3rdparty_la_SOURCES =					\
 
 pkginclude_HEADERS =							\
   $(top_srcdir)/include/mesos/executor.hpp				\
+  $(top_srcdir)/include/mesos/hook.hpp					\
   $(top_srcdir)/include/mesos/mesos.hpp					\
   $(top_srcdir)/include/mesos/module.hpp				\
   $(top_srcdir)/include/mesos/resources.hpp				\
@@ -398,6 +399,7 @@ moduledir = $(pkgincludedir)/module
 module_HEADERS =							\
   $(top_srcdir)/include/mesos/module/authenticatee.hpp			\
   $(top_srcdir)/include/mesos/module/authenticator.hpp			\
+  $(top_srcdir)/include/mesos/module/hook.hpp				\
   $(top_srcdir)/include/mesos/module/isolator.hpp			\
   $(top_srcdir)/include/mesos/module/module.hpp				\
   $(top_srcdir)/include/mesos/module/module.proto
@@ -488,7 +490,6 @@ libmesos_no_3rdparty_la_SOURCES +=					\
 	examples/test_module.hpp					\
 	files/files.hpp							\
 	hdfs/hdfs.hpp							\
-	hook/hook.hpp							\
 	hook/manager.hpp						\
 	linux/cgroups.hpp						\
 	linux/fs.hpp							\
@@ -512,7 +513,6 @@ libmesos_no_3rdparty_la_SOURCES +=					\
 	master/sorter.hpp						\
 	master/validation.hpp						\
 	messages/messages.hpp						\
-	module/hook.hpp							\
 	module/manager.hpp						\
 	sched/constants.hpp						\
 	sched/flags.hpp							\

http://git-wip-us.apache.org/repos/asf/mesos/blob/c6361c55/src/examples/test_hook_module.cpp
----------------------------------------------------------------------
diff --git a/src/examples/test_hook_module.cpp b/src/examples/test_hook_module.cpp
index 573ccb3..8faf685 100644
--- a/src/examples/test_hook_module.cpp
+++ b/src/examples/test_hook_module.cpp
@@ -18,18 +18,16 @@
 
 #include <string>
 
+#include <mesos/hook.hpp>
 #include <mesos/mesos.hpp>
 #include <mesos/module.hpp>
 
+#include <mesos/module/hook.hpp>
+
 #include <stout/foreach.hpp>
 #include <stout/os.hpp>
 #include <stout/try.hpp>
 
-#include "hook/hook.hpp"
-#include "master/master.hpp"
-#include "module/hook.hpp"
-#include "slave/slave.hpp"
-
 using std::string;
 
 using namespace mesos;

http://git-wip-us.apache.org/repos/asf/mesos/blob/c6361c55/src/hook/hook.hpp
----------------------------------------------------------------------
diff --git a/src/hook/hook.hpp b/src/hook/hook.hpp
deleted file mode 100644
index e31b7c9..0000000
--- a/src/hook/hook.hpp
+++ /dev/null
@@ -1,74 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __HOOK_HOOK_HPP__
-#define __HOOK_HOOK_HPP__
-
-#include <mesos/mesos.hpp>
-
-#include <stout/none.hpp>
-#include <stout/result.hpp>
-
-#include "master/master.hpp"
-#include "slave/slave.hpp"
-
-namespace mesos {
-
-class Hook
-{
-public:
-  virtual ~Hook() {};
-
-  // This label decorator hook is called from within master during
-  // the launchTask routine.  A module implementing the hook creates
-  // and returns a set of labels.  These labels are then merged with
-  // the task labels and passed on to the slave/executor.
-  virtual Result<Labels> masterLaunchTaskLabelDecorator(
-      const TaskInfo& taskInfo,
-      const FrameworkInfo& frameworkInfo,
-      const SlaveInfo& slaveInfo)
-  {
-    return None();
-  }
-
-  // This environment decorator hook is called from within slave
-  // when launching a new executor.  A module implementing the hook
-  // creates and returns a set of environment variables.  These
-  // environment variables are then merged into the executorInfo
-  // and become part of the executor's environment.
-  virtual Result<Environment> slaveLaunchExecutorEnvironmentDecorator(
-      const ExecutorInfo& executorInfo,
-      const TaskInfo& taskInfo)
-  {
-    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 mesos {
-
-#endif // __HOOK_HOOK_HPP__

http://git-wip-us.apache.org/repos/asf/mesos/blob/c6361c55/src/hook/manager.cpp
----------------------------------------------------------------------
diff --git a/src/hook/manager.cpp b/src/hook/manager.cpp
index c14dcca..a6938d0 100644
--- a/src/hook/manager.cpp
+++ b/src/hook/manager.cpp
@@ -21,6 +21,10 @@
 #include <string>
 #include <vector>
 
+#include <mesos/hook.hpp>
+
+#include <mesos/module/hook.hpp>
+
 #include <stout/check.hpp>
 #include <stout/foreach.hpp>
 #include <stout/nothing.hpp>
@@ -28,9 +32,7 @@
 #include <stout/try.hpp>
 
 #include "common/lock.hpp"
-#include "hook/hook.hpp"
 #include "hook/manager.hpp"
-#include "module/hook.hpp"
 #include "module/manager.hpp"
 
 using std::string;

http://git-wip-us.apache.org/repos/asf/mesos/blob/c6361c55/src/hook/manager.hpp
----------------------------------------------------------------------
diff --git a/src/hook/manager.hpp b/src/hook/manager.hpp
index 2de59b7..a6594c1 100644
--- a/src/hook/manager.hpp
+++ b/src/hook/manager.hpp
@@ -22,10 +22,9 @@
 #include <string>
 
 #include <mesos/mesos.hpp>
+#include <mesos/hook.hpp>
 
-#include "hook/hook.hpp"
-#include "master/master.hpp"
-#include "messages/messages.hpp"
+#include <stout/try.hpp>
 
 namespace mesos {
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/c6361c55/src/module/hook.hpp
----------------------------------------------------------------------
diff --git a/src/module/hook.hpp b/src/module/hook.hpp
deleted file mode 100644
index c7edfba..0000000
--- a/src/module/hook.hpp
+++ /dev/null
@@ -1,65 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __MODULE_HOOK_HPP__
-#define __MODULE_HOOK_HPP__
-
-#include <mesos/mesos.hpp>
-#include <mesos/module.hpp>
-
-#include "hook/hook.hpp"
-
-namespace mesos {
-namespace modules {
-
-template<>
-inline const char* kind<mesos::Hook>()
-{
-  return "Hook";
-}
-
-
-template <>
-struct Module<mesos::Hook> : ModuleBase
-{
-  Module(
-      const char* _moduleApiVersion,
-      const char* _mesosVersion,
-      const char* _authorName,
-      const char* _authorEmail,
-      const char* _description,
-      bool (*_compatible)(),
-      mesos::Hook* (*_create)(const Parameters& parameters))
-    : ModuleBase(
-        _moduleApiVersion,
-        _mesosVersion,
-        mesos::modules::kind<mesos::Hook>(),
-        _authorName,
-        _authorEmail,
-        _description,
-        _compatible),
-      create(_create)
-  { }
-
-  mesos::Hook* (*create)(const Parameters& parameters);
-};
-
-} // namespace modules {
-} // namespace mesos {
-
-#endif // __MODULE_HOOK_HPP__