You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by bm...@apache.org on 2015/10/13 23:32:32 UTC

[2/2] mesos git commit: Added /flags endpoints on the master and agent.

Added /flags endpoints on the master and agent.

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


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

Branch: refs/heads/master
Commit: d756ff708b00df2512e3c89a228a824768369cf8
Parents: ffbc7d9
Author: haosdent huang <ha...@gmail.com>
Authored: Tue Oct 13 14:23:49 2015 -0700
Committer: Benjamin Mahler <be...@gmail.com>
Committed: Tue Oct 13 14:26:34 2015 -0700

----------------------------------------------------------------------
 src/master/http.cpp   | 25 +++++++++++++++++++++++++
 src/master/master.cpp |  6 ++++++
 src/master/master.hpp |  5 +++++
 src/slave/http.cpp    | 25 +++++++++++++++++++++++++
 src/slave/slave.cpp   |  7 +++++++
 src/slave/slave.hpp   |  5 +++++
 6 files changed, 73 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/d756ff70/src/master/http.cpp
----------------------------------------------------------------------
diff --git a/src/master/http.cpp b/src/master/http.cpp
index f68f3eb..19dedcf 100644
--- a/src/master/http.cpp
+++ b/src/master/http.cpp
@@ -523,6 +523,31 @@ Future<Response> Master::Http::scheduler(const Request& request) const
 }
 
 
+string Master::Http::FLAGS_HELP()
+{
+  return HELP(TLDR("Information about master flags."));
+}
+
+
+Future<Response> Master::Http::flags(const Request& request) const
+{
+  JSON::Object object;
+
+  {
+    JSON::Object flags;
+    foreachpair (const string& name, const flags::Flag& flag, master->flags) {
+      Option<string> value = flag.stringify(master->flags);
+      if (value.isSome()) {
+        flags.values[name] = value.get();
+      }
+    }
+    object.values["flags"] = std::move(flags);
+  }
+
+  return OK(object, request.url.query.get("jsonp"));
+}
+
+
 string Master::Http::HEALTH_HELP()
 {
   return HELP(

http://git-wip-us.apache.org/repos/asf/mesos/blob/d756ff70/src/master/master.cpp
----------------------------------------------------------------------
diff --git a/src/master/master.cpp b/src/master/master.cpp
index 2da7807..ba12a83 100644
--- a/src/master/master.cpp
+++ b/src/master/master.cpp
@@ -762,6 +762,12 @@ void Master::initialize()
           Http::log(request);
           return http.scheduler(request);
         });
+  route("/flags",
+        Http::FLAGS_HELP(),
+        [http](const process::http::Request& request) {
+          Http::log(request);
+          return http.flags(request);
+        });
   route("/health",
         Http::HEALTH_HELP(),
         [http](const process::http::Request& request) {

http://git-wip-us.apache.org/repos/asf/mesos/blob/d756ff70/src/master/master.hpp
----------------------------------------------------------------------
diff --git a/src/master/master.hpp b/src/master/master.hpp
index 3b1bc16..e7b16fd 100644
--- a/src/master/master.hpp
+++ b/src/master/master.hpp
@@ -851,6 +851,10 @@ private:
     process::Future<process::http::Response> scheduler(
         const process::http::Request& request) const;
 
+    // /master/flags
+    process::Future<process::http::Response> flags(
+        const process::http::Request& request) const;
+
     // /master/health
     process::Future<process::http::Response> health(
         const process::http::Request& request) const;
@@ -912,6 +916,7 @@ private:
         const process::http::Request& request) const;
 
     static std::string SCHEDULER_HELP();
+    static std::string FLAGS_HELP();
     static std::string HEALTH_HELP();
     static std::string OBSERVE_HELP();
     static std::string REDIRECT_HELP();

http://git-wip-us.apache.org/repos/asf/mesos/blob/d756ff70/src/slave/http.cpp
----------------------------------------------------------------------
diff --git a/src/slave/http.cpp b/src/slave/http.cpp
index ed369da..5002db1 100644
--- a/src/slave/http.cpp
+++ b/src/slave/http.cpp
@@ -321,6 +321,31 @@ Future<Response> Slave::Http::executor(const Request& request) const
 }
 
 
+string Slave::Http::FLAGS_HELP()
+{
+  return HELP(TLDR("Information about slave flags."));
+}
+
+
+Future<Response> Slave::Http::flags(const Request& request) const
+{
+  JSON::Object object;
+
+  {
+    JSON::Object flags;
+    foreachpair (const string& name, const flags::Flag& flag, slave->flags) {
+      Option<string> value = flag.stringify(slave->flags);
+      if (value.isSome()) {
+        flags.values[name] = value.get();
+      }
+    }
+    object.values["flags"] = std::move(flags);
+  }
+
+  return OK(object, request.url.query.get("jsonp"));
+}
+
+
 string Slave::Http::HEALTH_HELP()
 {
   return HELP(

http://git-wip-us.apache.org/repos/asf/mesos/blob/d756ff70/src/slave/slave.cpp
----------------------------------------------------------------------
diff --git a/src/slave/slave.cpp b/src/slave/slave.cpp
index 9949b0f..6526976 100644
--- a/src/slave/slave.cpp
+++ b/src/slave/slave.cpp
@@ -114,6 +114,7 @@ namespace slave {
 
 using namespace state;
 
+
 Slave::Slave(const slave::Flags& _flags,
              MasterDetector* _detector,
              Containerizer* _containerizer,
@@ -535,6 +536,12 @@ void Slave::initialize()
           Http::log(request);
           return http.state(request);
         });
+  route("/flags",
+        Http::FLAGS_HELP(),
+        [http](const process::http::Request& request) {
+          Http::log(request);
+          return http.flags(request);
+        });
   route("/health",
         Http::HEALTH_HELP(),
         [http](const process::http::Request& request) {

http://git-wip-us.apache.org/repos/asf/mesos/blob/d756ff70/src/slave/slave.hpp
----------------------------------------------------------------------
diff --git a/src/slave/slave.hpp b/src/slave/slave.hpp
index aeccc08..04a8646 100644
--- a/src/slave/slave.hpp
+++ b/src/slave/slave.hpp
@@ -407,6 +407,10 @@ private:
     process::Future<process::http::Response> executor(
         const process::http::Request& request) const;
 
+    // /slave/flags
+    process::Future<process::http::Response> flags(
+        const process::http::Request& request) const;
+
     // /slave/health
     process::Future<process::http::Response> health(
         const process::http::Request& request) const;
@@ -416,6 +420,7 @@ private:
         const process::http::Request& request) const;
 
     static std::string EXECUTOR_HELP();
+    static std::string FLAGS_HELP();
     static std::string HEALTH_HELP();
     static std::string STATE_HELP();