You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ji...@apache.org on 2016/11/04 07:00:57 UTC

[6/6] mesos git commit: Added optional 'Type' to createExecutorInfo().

Added optional 'Type' to createExecutorInfo().

This patch made 2 changes to the helper because of the changes from
supporting nested containers:
1. Added an optional 'Type' in ExecutorInfo.
2. Make the parameter 'command' as optional since the CommandInfo
   became optional in 'ExecutorInfo' protobuf.

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


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

Branch: refs/heads/master
Commit: 184f8898ae34fd53e18cdf8e8e7c223985e9ffb4
Parents: dcc2e41
Author: Gilbert Song <so...@gmail.com>
Authored: Thu Nov 3 22:04:27 2016 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Fri Nov 4 00:00:46 2016 -0700

----------------------------------------------------------------------
 src/tests/mesos.hpp | 45 ++++++++++++++++++++++++++-------------------
 1 file changed, 26 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/184f8898/src/tests/mesos.hpp
----------------------------------------------------------------------
diff --git a/src/tests/mesos.hpp b/src/tests/mesos.hpp
index 09c23e2..3354dce 100644
--- a/src/tests/mesos.hpp
+++ b/src/tests/mesos.hpp
@@ -453,44 +453,48 @@ namespace common {
 template <typename TExecutorInfo, typename TResources, typename TCommandInfo>
 inline TExecutorInfo createExecutorInfo(
     const std::string& executorId,
-    const TCommandInfo& command,
-    const Option<std::string>& resources = None())
+    const Option<TCommandInfo>& command = None(),
+    const Option<std::string>& resources = None(),
+    const Option<typename TExecutorInfo::Type>& type = None())
 {
   TExecutorInfo executor;
   executor.mutable_executor_id()->set_value(executorId);
-  executor.mutable_command()->CopyFrom(command);
+  if (command.isSome()) {
+    executor.mutable_command()->CopyFrom(command.get());
+  }
   if (resources.isSome()) {
     executor.mutable_resources()->CopyFrom(
         TResources::parse(resources.get()).get());
   }
+  if (type.isSome()) {
+    executor.set_type(type.get());
+  }
   return executor;
 }
 
 
-template <typename TExecutorInfo, typename TResources>
+template <typename TExecutorInfo, typename TResources, typename TCommandInfo>
 inline TExecutorInfo createExecutorInfo(
     const std::string& executorId,
     const std::string& command,
-    const Option<std::string>& resources = None())
+    const Option<std::string>& resources = None(),
+    const Option<typename TExecutorInfo::Type>& type = None())
 {
-  TExecutorInfo executor;
-  executor.mutable_executor_id()->set_value(executorId);
-  executor.mutable_command()->set_value(command);
-  if (resources.isSome()) {
-    executor.mutable_resources()->CopyFrom(
-        TResources::parse(resources.get()).get());
-  }
-  return executor;
+  TCommandInfo commandInfo;
+  commandInfo.set_value(command);
+  return createExecutorInfo<TExecutorInfo, TResources, TCommandInfo>(
+      executorId, commandInfo, resources, type);
 }
 
 
-template <typename TExecutorInfo, typename TResources>
+template <typename TExecutorInfo, typename TResources, typename TCommandInfo>
 inline TExecutorInfo createExecutorInfo(
     const std::string& executorId,
     const char* command,
-    const Option<std::string>& resources = None())
+    const Option<std::string>& resources = None(),
+    const Option<typename TExecutorInfo::Type>& type = None())
 {
-  return createExecutorInfo<TExecutorInfo, TResources>(
+  return createExecutorInfo<TExecutorInfo, TResources, TCommandInfo>(
       executorId,
       std::string(command),
       resources);
@@ -1031,8 +1035,10 @@ inline namespace internal {
 template <typename... Args>
 inline ExecutorInfo createExecutorInfo(Args&&... args)
 {
-  return common::createExecutorInfo<ExecutorInfo, Resources>(
-      std::forward<Args>(args)...);
+  return common::createExecutorInfo<
+      ExecutorInfo,
+      Resources,
+      CommandInfo>(std::forward<Args>(args)...);
 }
 
 
@@ -1225,7 +1231,8 @@ inline mesos::v1::ExecutorInfo createExecutorInfo(Args&&... args)
 {
   return common::createExecutorInfo<
       mesos::v1::ExecutorInfo,
-      mesos::v1::Resources>(std::forward<Args>(args)...);
+      mesos::v1::Resources,
+      mesos::v1::CommandInfo>(std::forward<Args>(args)...);
 }