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

mesos git commit: Add a content type option to mesos-execute.

Repository: mesos
Updated Branches:
  refs/heads/master c75cb8cdd -> 40c2e5ffb


Add a content type option to mesos-execute.

Using the JSON content type in mesos-execute makes packet tracing
protocol interactions easier. Add a --content_type option that
switched between protobuf (the default) and JSON content types.

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


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

Branch: refs/heads/master
Commit: 40c2e5ffbe00c5f053e07ae1943bb2f7a84be46a
Parents: c75cb8c
Author: James Peach <jp...@apache.org>
Authored: Tue Nov 15 20:09:29 2016 -0800
Committer: Vinod Kone <vi...@gmail.com>
Committed: Tue Nov 15 20:09:29 2016 -0800

----------------------------------------------------------------------
 src/cli/execute.cpp | 25 ++++++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/40c2e5ff/src/cli/execute.cpp
----------------------------------------------------------------------
diff --git a/src/cli/execute.cpp b/src/cli/execute.cpp
index b47c427..74208e0 100644
--- a/src/cli/execute.cpp
+++ b/src/cli/execute.cpp
@@ -295,6 +295,12 @@ public:
         "    }\n"
         "  }\n"
         "]");
+
+    add(&Flags::content_type,
+        "content_type",
+        "The content type to use for scheduler protocol messages. 'json'\n"
+        "and 'protobuf' are valid choices.",
+        "json");
   }
 
   string master;
@@ -321,6 +327,7 @@ public:
   Option<string> networks;
   Option<string> principal;
   Option<string> secret;
+  string content_type;
 };
 
 
@@ -330,6 +337,7 @@ public:
   CommandScheduler(
       const FrameworkInfo& _frameworkInfo,
       const string& _master,
+      mesos::ContentType _contentType,
       const Option<Duration>& _killAfter,
       const Option<Credential>& _credential,
       const Option<TaskInfo>& _task,
@@ -338,6 +346,7 @@ public:
     : state(DISCONNECTED),
       frameworkInfo(_frameworkInfo),
       master(_master),
+      contentType(_contentType),
       killAfter(_killAfter),
       credential(_credential),
       task(_task),
@@ -355,7 +364,7 @@ protected:
     // after the process has spawned.
     mesos.reset(new Mesos(
       master,
-      mesos::ContentType::PROTOBUF,
+      contentType,
       process::defer(self(), &Self::connected),
       process::defer(self(), &Self::disconnected),
       process::defer(self(), &Self::received, lambda::_1),
@@ -668,6 +677,7 @@ private:
 
   FrameworkInfo frameworkInfo;
   const string master;
+  mesos::ContentType contentType;
   const Option<Duration> killAfter;
   const Option<Credential> credential;
   const Option<TaskInfo> task;
@@ -794,6 +804,7 @@ static Result<ContainerInfo> getContainerInfo(
 int main(int argc, char** argv)
 {
   Flags flags;
+  mesos::ContentType contentType = mesos::ContentType::PROTOBUF;
 
   // Load flags from command line only.
   Try<flags::Warnings> load = flags.load(None(), argc, argv);
@@ -843,6 +854,17 @@ int main(int argc, char** argv)
     }
   }
 
+  if (flags.content_type == "json" ||
+      flags.content_type == mesos::APPLICATION_JSON) {
+    contentType = mesos::ContentType::JSON;
+  } else if (flags.content_type == "protobuf" ||
+             flags.content_type == mesos::APPLICATION_PROTOBUF) {
+    contentType = mesos::ContentType::PROTOBUF;
+  } else {
+    cerr << "Invalid content type '" << flags.content_type << "'" << endl;
+    return EXIT_FAILURE;
+  }
+
   Result<string> user = os::user();
   if (!user.isSome()) {
     if (user.isError()) {
@@ -1070,6 +1092,7 @@ int main(int argc, char** argv)
       new CommandScheduler(
         frameworkInfo,
         flags.master,
+        contentType,
         flags.kill_after,
         credential,
         taskInfo,