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

[1/2] mesos git commit: Generated usage help information in libprocess.

Repository: mesos
Updated Branches:
  refs/heads/master de7fb43a0 -> 0bbeab258


Generated usage help information in libprocess.

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


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

Branch: refs/heads/master
Commit: ed1df9520826e55f67f915d251702cacff16db9b
Parents: de7fb43
Author: haosdent huang <ha...@gmail.com>
Authored: Thu Sep 10 01:21:26 2015 -0700
Committer: Michael Park <mp...@apache.org>
Committed: Thu Sep 10 02:21:04 2015 -0700

----------------------------------------------------------------------
 3rdparty/libprocess/include/process/help.hpp   | 28 +++++++++--------
 3rdparty/libprocess/include/process/system.hpp |  2 --
 3rdparty/libprocess/src/help.cpp               | 33 ++++++++++++---------
 3rdparty/libprocess/src/logging.cpp            |  4 +--
 3rdparty/libprocess/src/metrics/metrics.cpp    |  1 -
 3rdparty/libprocess/src/profiler.cpp           | 20 +++----------
 6 files changed, 39 insertions(+), 49 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/ed1df952/3rdparty/libprocess/include/process/help.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/help.hpp b/3rdparty/libprocess/include/process/help.hpp
index 441f6d1..e7dc670 100644
--- a/3rdparty/libprocess/include/process/help.hpp
+++ b/3rdparty/libprocess/include/process/help.hpp
@@ -33,32 +33,24 @@ namespace process {
 // Constructs a Markdown based help "page" for a route with the
 // following template:
 //
-//     ### TL;DR; ###
-//     tldr
-//
 //     ### USAGE ###
 //     usage
 //
+//     ### TL;DR; ###
+//     tldr
+//
 //     ### DESCRIPTION ###
 //     description
 //
 //     references
 //
-// See the 'TLDR', 'USAGE', 'DESCRIPTION', and 'REFERENCES' helpers
+// See the 'USAGE', 'TLDR', 'DESCRIPTION', and 'REFERENCES' helpers
 // below to more easily construct your help pages.
 std::string HELP(
     std::string tldr,
-    std::string usage,
     std::string description,
     const Option<std::string>& references = None());
 
-// Helper for single-line TL;DR; that adds a newline.
-inline std::string TLDR(const std::string& tldr)
-{
-  return tldr + "\n";
-}
-
-
 // Helper for single-line usage that puts it in a blockquote as code
 // and adds a newline.
 inline std::string USAGE(const std::string& usage)
@@ -67,6 +59,13 @@ inline std::string USAGE(const std::string& usage)
 }
 
 
+// Helper for single-line TL;DR; that adds a newline.
+inline std::string TLDR(const std::string& tldr)
+{
+  return tldr + "\n";
+}
+
+
 template <typename... T>
 inline std::string DESCRIPTION(T&&... args)
 {
@@ -118,7 +117,10 @@ private:
   // process.
   Future<http::Response> help(const http::Request& request);
 
-  std::map<std::string, std::map<std::string, std::string> > helps;
+  // Helper function to get usage path by process id and endpoint name.
+  std::string getUsagePath(const std::string& id, const std::string& name);
+
+  std::map<std::string, std::map<std::string, std::string>> helps;
 };
 
 } // namespace process {

http://git-wip-us.apache.org/repos/asf/mesos/blob/ed1df952/3rdparty/libprocess/include/process/system.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/system.hpp b/3rdparty/libprocess/include/process/system.hpp
index 7c8b49e..264d948 100644
--- a/3rdparty/libprocess/include/process/system.hpp
+++ b/3rdparty/libprocess/include/process/system.hpp
@@ -88,8 +88,6 @@ private:
     return HELP(
       TLDR(
           "Shows local system metrics."),
-      USAGE(
-          "/system/stats.json"),
       DESCRIPTION(
           ">        cpus_total          Total number of available CPUs",
           ">        load_1min           Average system load for last"

http://git-wip-us.apache.org/repos/asf/mesos/blob/ed1df952/3rdparty/libprocess/src/help.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/help.cpp b/3rdparty/libprocess/src/help.cpp
index e4e0bb6..d358b93 100644
--- a/3rdparty/libprocess/src/help.cpp
+++ b/3rdparty/libprocess/src/help.cpp
@@ -40,19 +40,14 @@ namespace process {
 
 string HELP(
     string tldr,
-    string usage,
     string description,
     const Option<string>& references)
 {
-  // Make sure 'tldr', 'usage', and 'description' end with a newline.
+  // Make sure 'tldr' and 'description' end with a newline.
   if (!strings::endsWith(tldr, "\n")) {
     tldr += "\n";
   }
 
-  if (!strings::endsWith(usage, "\n")) {
-    usage += "\n";
-  }
-
   if (!strings::endsWith(description, "\n")) {
     description += "\n";
   }
@@ -62,9 +57,6 @@ string HELP(
     "### TL;DR; ###\n" +
     tldr +
     "\n" +
-    "### USAGE ###\n" +
-    usage +
-    "\n" +
     "### DESCRIPTION ###\n" +
     description;
 
@@ -80,16 +72,29 @@ string HELP(
 Help::Help() : ProcessBase("help") {}
 
 
-void Help::add(const string& id,
+string Help::getUsagePath(const string& id, const string& name)
+{
+  return id + strings::remove(name, "/", strings::Mode::SUFFIX);
+}
+
+
+void Help::add(
+    const string& id,
     const string& name,
     const Option<string>& help)
 {
-  if (id != "help") { // TODO(benh): Enable help for help.
+  // TODO(benh): Enable help for help.
+  if (id != "help" && id != "__processes__") {
+    // Remove tail slash in usage information.
+    const string path = "/" + getUsagePath(id, name);
+
     if (help.isSome()) {
-      helps[id][name] = help.get();
+      string usage = "### USAGE ###\n" + USAGE(path) + "\n";
+      helps[id][name] = usage + help.get();
     } else {
-      helps[id][name] = "## No help page for `/" + id + name + "`\n";
+      helps[id][name] = "## No help page for `" + path + "`\n";
     }
+
     route("/" + id, "Help for " + id, &Help::help);
   }
 }
@@ -135,7 +140,7 @@ Future<http::Response> Help::help(const http::Request& request)
 
     document += "## `/" + id.get() + "` ##\n";
     foreachkey (const string& name, helps[id.get()]) {
-      const string path = id.get() + name;
+      const string path = getUsagePath(id.get(), name);
       document += "> [/" +  path + "][" + path + "]\n";
       references += "[" + path + "]: " + path + "\n";
     }

http://git-wip-us.apache.org/repos/asf/mesos/blob/ed1df952/3rdparty/libprocess/src/logging.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/logging.cpp b/3rdparty/libprocess/src/logging.cpp
index 3d855e9..db76abe 100644
--- a/3rdparty/libprocess/src/logging.cpp
+++ b/3rdparty/libprocess/src/logging.cpp
@@ -80,8 +80,6 @@ const std::string Logging::TOGGLE_HELP()
   return HELP(
     TLDR(
         "Sets the logging verbosity level for a specified duration."),
-    USAGE(
-        "/logging/toggle?level=VALUE&duration=VALUE"),
     DESCRIPTION(
         "The libprocess library uses [glog][glog] for logging. The library",
         "only uses verbose logging which means nothing will be output unless",
@@ -91,7 +89,7 @@ const std::string Logging::TOGGLE_HELP()
         "**NOTE:** If your application uses glog this will also affect",
         "your verbose logging.",
         "",
-        "Required query parameters:",
+        "Query parameters:",
         "",
         ">        level=VALUE          Verbosity level (e.g., 1, 2, 3)",
         ">        duration=VALUE       Duration to keep verbosity level",

http://git-wip-us.apache.org/repos/asf/mesos/blob/ed1df952/3rdparty/libprocess/src/metrics/metrics.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/metrics/metrics.cpp b/3rdparty/libprocess/src/metrics/metrics.cpp
index b961750..943ba63 100644
--- a/3rdparty/libprocess/src/metrics/metrics.cpp
+++ b/3rdparty/libprocess/src/metrics/metrics.cpp
@@ -68,7 +68,6 @@ string MetricsProcess::help()
 {
   return HELP(
       TLDR("Provides a snapshot of the current metrics."),
-      USAGE("/metrics/snapshot"),
       DESCRIPTION(
           "This endpoint provides information regarding the current metrics ",
           "tracked by the system.",

http://git-wip-us.apache.org/repos/asf/mesos/blob/ed1df952/3rdparty/libprocess/src/profiler.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/profiler.cpp b/3rdparty/libprocess/src/profiler.cpp
index 65a2e05..0c51556 100644
--- a/3rdparty/libprocess/src/profiler.cpp
+++ b/3rdparty/libprocess/src/profiler.cpp
@@ -41,15 +41,9 @@ const std::string Profiler::START_HELP()
 {
   return HELP(
     TLDR(
-        "Starts profiling ..."),
-    USAGE(
-        "/profiler/start..."),
+        "Start profiling."),
     DESCRIPTION(
-        "...",
-        "",
-        "Query parameters:",
-        "",
-        ">        param=VALUE          Some description here"));
+        "Start to use google perftools do profiling."));
 }
 
 
@@ -57,15 +51,9 @@ const std::string Profiler::STOP_HELP()
 {
   return HELP(
     TLDR(
-        "Stops profiling ..."),
-    USAGE(
-        "/profiler/stop..."),
+        "Stops profiling."),
     DESCRIPTION(
-        "...",
-        "",
-        "Query parameters:",
-        "",
-        ">        param=VALUE          Some description here"));
+        "Stop to use google perftools do profiling."));
 }
 
 


[2/2] mesos git commit: Removed unnecessary usage information.

Posted by mp...@apache.org.
Removed unnecessary usage information.

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


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

Branch: refs/heads/master
Commit: 0bbeab2580d671fefa8d3705e15392da069e9d00
Parents: ed1df95
Author: haosdent huang <ha...@gmail.com>
Authored: Thu Sep 10 01:22:01 2015 -0700
Committer: Michael Park <mp...@apache.org>
Committed: Thu Sep 10 02:21:18 2015 -0700

----------------------------------------------------------------------
 src/files/files.cpp      |  8 --------
 src/master/http.cpp      | 29 -----------------------------
 src/master/registrar.cpp |  2 --
 src/slave/http.cpp       |  4 ----
 src/slave/monitor.cpp    |  2 --
 5 files changed, 45 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/0bbeab25/src/files/files.cpp
----------------------------------------------------------------------
diff --git a/src/files/files.cpp b/src/files/files.cpp
index b2134aa..a8807b6 100644
--- a/src/files/files.cpp
+++ b/src/files/files.cpp
@@ -188,8 +188,6 @@ void FilesProcess::detach(const string& name)
 const string FilesProcess::BROWSE_HELP = HELP(
     TLDR(
         "Returns a file listing for a directory."),
-    USAGE(
-        "/files/browse.json"),
     DESCRIPTION(
         "Lists files and directories contained in the path as",
         "a JSON object.",
@@ -262,8 +260,6 @@ Future<Response> _read(int fd,
 const string FilesProcess::READ_HELP = HELP(
     TLDR(
         "Reads data from a file."),
-    USAGE(
-        "/files/read.json"),
     DESCRIPTION(
         "This endpoint reads data from a file at a given offset and for",
         "a given length."
@@ -392,8 +388,6 @@ Future<Response> FilesProcess::read(const Request& request)
 const string FilesProcess::DOWNLOAD_HELP = HELP(
     TLDR(
         "Returns the raw file contents for a given path."),
-    USAGE(
-        "/files/download.json"),
     DESCRIPTION(
         "This endpoint will return the raw file contents for the",
         "given path.",
@@ -449,8 +443,6 @@ Future<Response> FilesProcess::download(const Request& request)
 const string FilesProcess::DEBUG_HELP = HELP(
     TLDR(
         "Returns the internal virtual path mapping."),
-    USAGE(
-        "/files/debug.json"),
     DESCRIPTION(
         "This endpoint shows the internal virtual path map as a",
         "JSON object."));

http://git-wip-us.apache.org/repos/asf/mesos/blob/0bbeab25/src/master/http.cpp
----------------------------------------------------------------------
diff --git a/src/master/http.cpp b/src/master/http.cpp
index a052e55..73e8857 100644
--- a/src/master/http.cpp
+++ b/src/master/http.cpp
@@ -74,7 +74,6 @@ using process::DESCRIPTION;
 using process::Future;
 using process::HELP;
 using process::TLDR;
-using process::USAGE;
 
 using process::http::Accepted;
 using process::http::BadRequest;
@@ -347,8 +346,6 @@ void Master::Http::log(const Request& request)
 const string Master::Http::SCHEDULER_HELP = HELP(
     TLDR(
         "Endpoint for schedulers to make Calls against the master."),
-    USAGE(
-        "/api/v1/scheduler"),
     DESCRIPTION(
         "Returns 202 Accepted iff the request is accepted."));
 
@@ -519,8 +516,6 @@ Future<Response> Master::Http::scheduler(const Request& request) const
 const string Master::Http::HEALTH_HELP = HELP(
     TLDR(
         "Health check of the Master."),
-    USAGE(
-        "/master/health"),
     DESCRIPTION(
         "Returns 200 OK iff the Master is healthy.",
         "Delayed responses are also indicative of poor health."));
@@ -538,8 +533,6 @@ const static string MONITOR_KEY = "monitor";
 const string Master::Http::OBSERVE_HELP = HELP(
     TLDR(
         "Observe a monitor health state for host(s)."),
-    USAGE(
-        "/master/observe"),
     DESCRIPTION(
         "This endpoint receives information indicating host(s) ",
         "health."
@@ -630,8 +623,6 @@ Future<Response> Master::Http::observe(const Request& request) const
 const string Master::Http::REDIRECT_HELP = HELP(
     TLDR(
         "Redirects to the leading Master."),
-    USAGE(
-        "/master/redirect"),
     DESCRIPTION(
         "This returns a 307 Temporary Redirect to the leading Master.",
         "If no Master is leading (according to this Master), then the",
@@ -752,8 +743,6 @@ Future<Response> Master::Http::reserve(const Request& request) const
 const string Master::Http::SLAVES_HELP = HELP(
     TLDR(
         "Information about registered slaves."),
-    USAGE(
-        "/master/slaves"),
     DESCRIPTION(
         "This endpoint shows information about the slaves registered in",
         "this master formatted as a JSON object."));
@@ -782,8 +771,6 @@ Future<Response> Master::Http::slaves(const Request& request) const
 const string Master::Http::STATE_HELP = HELP(
     TLDR(
         "Information about state of master."),
-    USAGE(
-        "/master/state.json"),
     DESCRIPTION(
         "This endpoint shows information about the frameworks, tasks,",
         "executors and slaves running in the cluster as a JSON object."));
@@ -1076,8 +1063,6 @@ private:
 const string Master::Http::STATESUMMARY_HELP = HELP(
     TLDR(
         "Summary of state of all tasks and registered frameworks in cluster."),
-    USAGE(
-        "/master/state-summary"),
     DESCRIPTION(
         "This endpoint gives a summary of the state of all tasks and",
         "registered frameworks in the cluster as a JSON object."));
@@ -1194,8 +1179,6 @@ Future<Response> Master::Http::stateSummary(const Request& request) const
 const string Master::Http::ROLES_HELP = HELP(
     TLDR(
         "Information about roles that the master is configured with."),
-    USAGE(
-        "/master/roles.json"),
     DESCRIPTION(
         "This endpoint gives information about the roles that are assigned",
         "to frameworks and resources as a JSON object."));
@@ -1223,8 +1206,6 @@ const string Master::Http::TEARDOWN_HELP = HELP(
     TLDR(
         "Tears down a running framework by shutting down all tasks/executors "
         "and removing the framework."),
-    USAGE(
-        "/master/teardown"),
     DESCRIPTION(
         "Please provide a \"frameworkId\" value designating the running "
         "framework to tear down.",
@@ -1319,8 +1300,6 @@ Future<Response> Master::Http::_teardown(
 const string Master::Http::TASKS_HELP = HELP(
     TLDR(
       "Lists tasks from all active frameworks."),
-    USAGE(
-      "/master/tasks.json"),
     DESCRIPTION(
       "Lists known tasks.",
       "",
@@ -1442,8 +1421,6 @@ Future<Response> Master::Http::tasks(const Request& request) const
 const string Master::Http::MAINTENANCE_SCHEDULE_HELP = HELP(
     TLDR(
         "Returns or updates the cluster's maintenance schedule."),
-    USAGE(
-        "/master/maintenance/schedule"),
     DESCRIPTION(
         "GET: Returns the current maintenance schedule as JSON.",
         "POST: Validates the request body as JSON",
@@ -1557,8 +1534,6 @@ Future<Response> Master::Http::maintenanceSchedule(const Request& request) const
 const string Master::Http::MACHINE_DOWN_HELP = HELP(
     TLDR(
         "Brings a set of machines down."),
-    USAGE(
-        "/master/machine/down"),
     DESCRIPTION(
         "POST: Validates the request body as JSON and transitions",
         "  the list of machines into DOWN mode.  Currently, only",
@@ -1630,8 +1605,6 @@ Future<Response> Master::Http::machineDown(const Request& request) const
 const string Master::Http::MACHINE_UP_HELP = HELP(
     TLDR(
         "Brings a set of machines back up."),
-    USAGE(
-        "/master/machine/up"),
     DESCRIPTION(
         "POST: Validates the request body as JSON and transitions",
         "  the list of machines into UP mode.  This also removes",
@@ -1732,8 +1705,6 @@ Future<Response> Master::Http::machineUp(const Request& request) const
 const string Master::Http::MAINTENANCE_STATUS_HELP = HELP(
     TLDR(
         "Retrieves the maintenance status of the cluster."),
-    USAGE(
-        "/master/maintenance/status"),
     DESCRIPTION(
         "Returns an object with one list of machines per machine mode."));
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/0bbeab25/src/master/registrar.cpp
----------------------------------------------------------------------
diff --git a/src/master/registrar.cpp b/src/master/registrar.cpp
index ca8efb4..d81560a 100644
--- a/src/master/registrar.cpp
+++ b/src/master/registrar.cpp
@@ -254,8 +254,6 @@ string RegistrarProcess::registryHelp()
   return HELP(
       TLDR(
           "Returns the current contents of the Registry in JSON."),
-      USAGE(
-          "/registrar(1)/registry"),
       DESCRIPTION(
           "Example:"
           "",

http://git-wip-us.apache.org/repos/asf/mesos/blob/0bbeab25/src/slave/http.cpp
----------------------------------------------------------------------
diff --git a/src/slave/http.cpp b/src/slave/http.cpp
index b0fe5f5..101aa06 100644
--- a/src/slave/http.cpp
+++ b/src/slave/http.cpp
@@ -185,8 +185,6 @@ void Slave::Http::log(const Request& request)
 const string Slave::Http::HEALTH_HELP = HELP(
     TLDR(
         "Health check of the Slave."),
-    USAGE(
-        "/health"),
     DESCRIPTION(
         "Returns 200 OK iff the Slave is healthy.",
         "Delayed responses are also indicative of poor health."));
@@ -201,8 +199,6 @@ Future<Response> Slave::Http::health(const Request& request) const
 const string Slave::Http::STATE_HELP = HELP(
     TLDR(
         "Information about state of the Slave."),
-    USAGE(
-        "/state.json"),
     DESCRIPTION(
         "This endpoint shows information about the frameworks, executors",
         "and the slave's master as a JSON object."));

http://git-wip-us.apache.org/repos/asf/mesos/blob/0bbeab25/src/slave/monitor.cpp
----------------------------------------------------------------------
diff --git a/src/slave/monitor.cpp b/src/slave/monitor.cpp
index 82aa659..93ba279 100644
--- a/src/slave/monitor.cpp
+++ b/src/slave/monitor.cpp
@@ -47,8 +47,6 @@ static const string STATISTICS_HELP()
   return HELP(
       TLDR(
           "Retrieve resource monitoring information."),
-      USAGE(
-          "/statistics.json"),
       DESCRIPTION(
           "Returns the current resource consumption data for containers",
           "running under this slave.",