Repository: mesos Updated Branches: refs/heads/master e930a9785 -> d756ff708
Remove static non-POD help strings in the master and agent. Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/ffbc7d96 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/ffbc7d96 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/ffbc7d96 Branch: refs/heads/master Commit: ffbc7d96f8c3a62cc4bdca59bb7ece08c8abc9de Parents: e930a97 Author: Benjamin Mahler <[email protected]> Authored: Tue Oct 13 14:17:55 2015 -0700 Committer: Benjamin Mahler <[email protected]> Committed: Tue Oct 13 14:17:55 2015 -0700 ---------------------------------------------------------------------- src/master/http.cpp | 81 ++++++++++++++++++++++++++++++++++++---------- src/master/master.cpp | 38 +++++++++++----------- src/master/master.hpp | 32 +++++++++--------- src/slave/http.cpp | 13 ++++++-- src/slave/slave.cpp | 8 ++--- src/slave/slave.hpp | 6 ++-- 6 files changed, 116 insertions(+), 62 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/ffbc7d96/src/master/http.cpp ---------------------------------------------------------------------- diff --git a/src/master/http.cpp b/src/master/http.cpp index 76954ac..f68f3eb 100644 --- a/src/master/http.cpp +++ b/src/master/http.cpp @@ -346,11 +346,14 @@ void Master::Http::log(const Request& request) // TODO(ijimenez): Add some information or pointers to help // users understand the HTTP Event/Call API. -const string Master::Http::SCHEDULER_HELP = HELP( +string Master::Http::SCHEDULER_HELP() +{ + return HELP( TLDR( "Endpoint for schedulers to make Calls against the master."), DESCRIPTION( "Returns 202 Accepted iff the request is accepted.")); +} Future<Response> Master::Http::scheduler(const Request& request) const @@ -520,12 +523,15 @@ Future<Response> Master::Http::scheduler(const Request& request) const } -const string Master::Http::HEALTH_HELP = HELP( +string Master::Http::HEALTH_HELP() +{ + return HELP( TLDR( "Health check of the Master."), DESCRIPTION( "Returns 200 OK iff the Master is healthy.", "Delayed responses are also indicative of poor health.")); +} Future<Response> Master::Http::health(const Request& request) const @@ -537,7 +543,9 @@ const static string HOSTS_KEY = "hosts"; const static string LEVEL_KEY = "level"; const static string MONITOR_KEY = "monitor"; -const string Master::Http::OBSERVE_HELP = HELP( +string Master::Http::OBSERVE_HELP() +{ + return HELP( TLDR( "Observe a monitor health state for host(s)."), DESCRIPTION( @@ -548,7 +556,7 @@ const string Master::Http::OBSERVE_HELP = HELP( "1. " + MONITOR_KEY + " - name of the monitor that is being reported", "2. " + HOSTS_KEY + " - comma separated list of hosts", "3. " + LEVEL_KEY + " - OK for healthy, anything else for unhealthy")); - +} Try<string> getFormValue( const string& key, @@ -627,7 +635,9 @@ Future<Response> Master::Http::observe(const Request& request) const } -const string Master::Http::REDIRECT_HELP = HELP( +string Master::Http::REDIRECT_HELP() +{ + return HELP( TLDR( "Redirects to the leading Master."), DESCRIPTION( @@ -641,6 +651,7 @@ const string Master::Http::REDIRECT_HELP = HELP( "2. This is broken currently \"on the cloud\" (e.g. EC2) as", "this will attempt to redirect to the private IP address, unless", "advertise_ip points to an externally accessible IP")); +} Future<Response> Master::Http::redirect(const Request& request) const @@ -671,13 +682,16 @@ Future<Response> Master::Http::redirect(const Request& request) const } -const string Master::Http::RESERVE_HELP = HELP( +string Master::Http::RESERVE_HELP() +{ + return HELP( TLDR( "Reserve resources dynamically on a specific slave."), DESCRIPTION( "Returns 200 OK if resource reservation was successful.", "Please provide \"slaveId\" and \"resources\" values designating ", "the resources to be reserved.")); +} Future<Response> Master::Http::reserve(const Request& request) const @@ -756,12 +770,15 @@ Future<Response> Master::Http::reserve(const Request& request) const } -const string Master::Http::SLAVES_HELP = HELP( +string Master::Http::SLAVES_HELP() +{ + return HELP( TLDR( "Information about registered slaves."), DESCRIPTION( "This endpoint shows information about the slaves registered in", "this master formatted as a JSON object.")); +} Future<Response> Master::Http::slaves(const Request& request) const @@ -784,12 +801,15 @@ Future<Response> Master::Http::slaves(const Request& request) const } -const string Master::Http::STATE_HELP = HELP( +string Master::Http::STATE_HELP() +{ + return HELP( TLDR( "Information about state of master."), DESCRIPTION( "This endpoint shows information about the frameworks, tasks,", "executors and slaves running in the cluster as a JSON object.")); +} Future<Response> Master::Http::state(const Request& request) const @@ -1076,12 +1096,15 @@ private: }; -const string Master::Http::STATESUMMARY_HELP = HELP( +string Master::Http::STATESUMMARY_HELP() +{ + return HELP( TLDR( "Summary of state of all tasks and registered frameworks in cluster."), DESCRIPTION( "This endpoint gives a summary of the state of all tasks and", "registered frameworks in the cluster as a JSON object.")); +} Future<Response> Master::Http::stateSummary(const Request& request) const @@ -1192,12 +1215,15 @@ Future<Response> Master::Http::stateSummary(const Request& request) const } -const string Master::Http::ROLES_HELP = HELP( +string Master::Http::ROLES_HELP() +{ + return HELP( TLDR( "Information about roles that the master is configured with."), DESCRIPTION( "This endpoint gives information about the roles that are assigned", "to frameworks and resources as a JSON object.")); +} Future<Response> Master::Http::roles(const Request& request) const @@ -1218,7 +1244,9 @@ Future<Response> Master::Http::roles(const Request& request) const } -const string Master::Http::TEARDOWN_HELP = HELP( +string Master::Http::TEARDOWN_HELP() +{ + return HELP( TLDR( "Tears down a running framework by shutting down all tasks/executors " "and removing the framework."), @@ -1226,6 +1254,7 @@ const string Master::Http::TEARDOWN_HELP = HELP( "Please provide a \"frameworkId\" value designating the running " "framework to tear down.", "Returns 200 OK if the framework was correctly teared down.")); +} Future<Response> Master::Http::teardown(const Request& request) const @@ -1312,7 +1341,9 @@ Future<Response> Master::Http::_teardown( } -const string Master::Http::TASKS_HELP = HELP( +string Master::Http::TASKS_HELP() +{ + return HELP( TLDR( "Lists tasks from all active frameworks."), DESCRIPTION( @@ -1326,6 +1357,7 @@ const string Master::Http::TASKS_HELP = HELP( "> order=(asc|desc) Ascending or descending sort order " "(default is descending)." "")); +} struct TaskComparator @@ -1433,13 +1465,16 @@ Future<Response> Master::Http::tasks(const Request& request) const // /master/maintenance/schedule endpoint help. -const string Master::Http::MAINTENANCE_SCHEDULE_HELP = HELP( +string Master::Http::MAINTENANCE_SCHEDULE_HELP() +{ + return HELP( TLDR( "Returns or updates the cluster's maintenance schedule."), DESCRIPTION( "GET: Returns the current maintenance schedule as JSON.", "POST: Validates the request body as JSON", " and updates the maintenance schedule.")); +} // /master/maintenance/schedule endpoint handler. @@ -1548,13 +1583,16 @@ Future<Response> Master::Http::maintenanceSchedule(const Request& request) const // /master/machine/down endpoint help. -const string Master::Http::MACHINE_DOWN_HELP = HELP( +string Master::Http::MACHINE_DOWN_HELP() +{ + return HELP( TLDR( "Brings a set of machines down."), DESCRIPTION( "POST: Validates the request body as JSON and transitions", " the list of machines into DOWN mode. Currently, only", " machines in DRAINING mode are allowed to be brought down.")); +} // /master/machine/down endpoint handler. @@ -1647,13 +1685,16 @@ Future<Response> Master::Http::machineDown(const Request& request) const // /master/maintenance/start endpoint help. -const string Master::Http::MACHINE_UP_HELP = HELP( +string Master::Http::MACHINE_UP_HELP() +{ + return HELP( TLDR( "Brings a set of machines back up."), DESCRIPTION( "POST: Validates the request body as JSON and transitions", " the list of machines into UP mode. This also removes", " the list of machines from the maintenance schedule.")); +} // /master/machine/up endpoint handler. @@ -1745,7 +1786,9 @@ Future<Response> Master::Http::machineUp(const Request& request) const // /master/maintenance/status endpoint help. -const string Master::Http::MAINTENANCE_STATUS_HELP = HELP( +string Master::Http::MAINTENANCE_STATUS_HELP() +{ + return HELP( TLDR( "Retrieves the maintenance status of the cluster."), DESCRIPTION( @@ -1754,6 +1797,7 @@ const string Master::Http::MAINTENANCE_STATUS_HELP = HELP( "to inverse offers. NOTE: Inverse offer responses are cleared if", "the master fails over. However, new inverse offers will be sent", "once the master recovers.")); +} // /master/maintenance/status endpoint handler. @@ -1817,13 +1861,16 @@ Future<Response> Master::Http::maintenanceStatus(const Request& request) const } -const string Master::Http::UNRESERVE_HELP = HELP( +string Master::Http::UNRESERVE_HELP() +{ + return HELP( TLDR( "Unreserve resources dynamically on a specific slave."), DESCRIPTION( "Returns 200 OK if resource unreservation was successful.", "Please provide \"slaveId\" and \"resources\" values designating ", "the resources to be unreserved.")); +} Future<Response> Master::Http::unreserve(const Request& request) const http://git-wip-us.apache.org/repos/asf/mesos/blob/ffbc7d96/src/master/master.cpp ---------------------------------------------------------------------- diff --git a/src/master/master.cpp b/src/master/master.cpp index 6bee4f3..2da7807 100644 --- a/src/master/master.cpp +++ b/src/master/master.cpp @@ -757,29 +757,29 @@ void Master::initialize() Http http = Http(this); route("/api/v1/scheduler", - Http::SCHEDULER_HELP, + Http::SCHEDULER_HELP(), [http](const process::http::Request& request) { Http::log(request); return http.scheduler(request); }); route("/health", - Http::HEALTH_HELP, + Http::HEALTH_HELP(), [http](const process::http::Request& request) { return http.health(request); }); route("/observe", - Http::OBSERVE_HELP, + Http::OBSERVE_HELP(), [http](const process::http::Request& request) { Http::log(request); return http.observe(request); }); route("/redirect", - Http::REDIRECT_HELP, + Http::REDIRECT_HELP(), [http](const process::http::Request& request) { return http.redirect(request); }); route("/reserve", - Http::RESERVE_HELP, + Http::RESERVE_HELP(), [http](const process::http::Request& request) { Http::log(request); return http.reserve(request); @@ -787,25 +787,25 @@ void Master::initialize() // TODO(ijimenez): Remove this endpoint at the end of the // deprecation cycle on 0.26. route("/roles.json", - Http::ROLES_HELP, + Http::ROLES_HELP(), [http](const process::http::Request& request) { Http::log(request); return http.roles(request); }); route("/roles", - Http::ROLES_HELP, + Http::ROLES_HELP(), [http](const process::http::Request& request) { Http::log(request); return http.roles(request); }); route("/teardown", - Http::TEARDOWN_HELP, + Http::TEARDOWN_HELP(), [http](const process::http::Request& request) { Http::log(request); return http.teardown(request); }); route("/slaves", - Http::SLAVES_HELP, + Http::SLAVES_HELP(), [http](const process::http::Request& request) { Http::log(request); return http.slaves(request); @@ -813,19 +813,19 @@ void Master::initialize() // TODO(ijimenez): Remove this endpoint at the end of the // deprecation cycle on 0.26. route("/state.json", - Http::STATE_HELP, + Http::STATE_HELP(), [http](const process::http::Request& request) { Http::log(request); return http.state(request); }); route("/state", - Http::STATE_HELP, + Http::STATE_HELP(), [http](const process::http::Request& request) { Http::log(request); return http.state(request); }); route("/state-summary", - Http::STATESUMMARY_HELP, + Http::STATESUMMARY_HELP(), [http](const process::http::Request& request) { Http::log(request); return http.stateSummary(request); @@ -833,43 +833,43 @@ void Master::initialize() // TODO(ijimenez): Remove this endpoint at the end of the // deprecation cycle. route("/tasks.json", - Http::TASKS_HELP, + Http::TASKS_HELP(), [http](const process::http::Request& request) { Http::log(request); return http.tasks(request); }); route("/tasks", - Http::TASKS_HELP, + Http::TASKS_HELP(), [http](const process::http::Request& request) { Http::log(request); return http.tasks(request); }); route("/maintenance/schedule", - Http::MAINTENANCE_SCHEDULE_HELP, + Http::MAINTENANCE_SCHEDULE_HELP(), [http](const process::http::Request& request) { Http::log(request); return http.maintenanceSchedule(request); }); route("/maintenance/status", - Http::MAINTENANCE_STATUS_HELP, + Http::MAINTENANCE_STATUS_HELP(), [http](const process::http::Request& request) { Http::log(request); return http.maintenanceStatus(request); }); route("/machine/down", - Http::MACHINE_DOWN_HELP, + Http::MACHINE_DOWN_HELP(), [http](const process::http::Request& request) { Http::log(request); return http.machineDown(request); }); route("/machine/up", - Http::MACHINE_UP_HELP, + Http::MACHINE_UP_HELP(), [http](const process::http::Request& request) { Http::log(request); return http.machineUp(request); }); route("/unreserve", - Http::UNRESERVE_HELP, + Http::UNRESERVE_HELP(), [http](const process::http::Request& request) { Http::log(request); return http.unreserve(request); http://git-wip-us.apache.org/repos/asf/mesos/blob/ffbc7d96/src/master/master.hpp ---------------------------------------------------------------------- diff --git a/src/master/master.hpp b/src/master/master.hpp index 9d95751..3b1bc16 100644 --- a/src/master/master.hpp +++ b/src/master/master.hpp @@ -911,22 +911,22 @@ private: process::Future<process::http::Response> unreserve( const process::http::Request& request) const; - const static std::string SCHEDULER_HELP; - const static std::string HEALTH_HELP; - const static std::string OBSERVE_HELP; - const static std::string REDIRECT_HELP; - const static std::string ROLES_HELP; - const static std::string TEARDOWN_HELP; - const static std::string SLAVES_HELP; - const static std::string STATE_HELP; - const static std::string STATESUMMARY_HELP; - const static std::string TASKS_HELP; - const static std::string MAINTENANCE_SCHEDULE_HELP; - const static std::string MAINTENANCE_STATUS_HELP; - const static std::string MACHINE_DOWN_HELP; - const static std::string MACHINE_UP_HELP; - const static std::string RESERVE_HELP; - const static std::string UNRESERVE_HELP; + static std::string SCHEDULER_HELP(); + static std::string HEALTH_HELP(); + static std::string OBSERVE_HELP(); + static std::string REDIRECT_HELP(); + static std::string ROLES_HELP(); + static std::string TEARDOWN_HELP(); + static std::string SLAVES_HELP(); + static std::string STATE_HELP(); + static std::string STATESUMMARY_HELP(); + static std::string TASKS_HELP(); + static std::string MAINTENANCE_SCHEDULE_HELP(); + static std::string MAINTENANCE_STATUS_HELP(); + static std::string MACHINE_DOWN_HELP(); + static std::string MACHINE_UP_HELP(); + static std::string RESERVE_HELP(); + static std::string UNRESERVE_HELP(); private: // Helper for doing authentication, returns the credential used if http://git-wip-us.apache.org/repos/asf/mesos/blob/ffbc7d96/src/slave/http.cpp ---------------------------------------------------------------------- diff --git a/src/slave/http.cpp b/src/slave/http.cpp index f9cf7bb..ed369da 100644 --- a/src/slave/http.cpp +++ b/src/slave/http.cpp @@ -197,7 +197,8 @@ void Slave::Http::log(const Request& request) } -const string Slave::Http::EXECUTOR_HELP = HELP( +string Slave::Http::EXECUTOR_HELP() { + return HELP( TLDR( "Endpoint for the Executor HTTP API."), DESCRIPTION( @@ -209,6 +210,7 @@ const string Slave::Http::EXECUTOR_HELP = HELP( "incrementally." "Returns 202 Accepted for all other Call messages iff the " "request is accepted.")); +} Future<Response> Slave::Http::executor(const Request& request) const @@ -319,12 +321,15 @@ Future<Response> Slave::Http::executor(const Request& request) const } -const string Slave::Http::HEALTH_HELP = HELP( +string Slave::Http::HEALTH_HELP() +{ + return HELP( TLDR( "Health check of the Slave."), DESCRIPTION( "Returns 200 OK iff the Slave is healthy.", "Delayed responses are also indicative of poor health.")); +} Future<Response> Slave::Http::health(const Request& request) const @@ -333,12 +338,14 @@ Future<Response> Slave::Http::health(const Request& request) const } -const string Slave::Http::STATE_HELP = HELP( +string Slave::Http::STATE_HELP() { + return HELP( TLDR( "Information about state of the Slave."), DESCRIPTION( "This endpoint shows information about the frameworks, executors", "and the slave's master as a JSON object.")); +} Future<Response> Slave::Http::state(const Request& request) const http://git-wip-us.apache.org/repos/asf/mesos/blob/ffbc7d96/src/slave/slave.cpp ---------------------------------------------------------------------- diff --git a/src/slave/slave.cpp b/src/slave/slave.cpp index cb2d715..9949b0f 100644 --- a/src/slave/slave.cpp +++ b/src/slave/slave.cpp @@ -515,7 +515,7 @@ void Slave::initialize() Http http = Http(this); route("/api/v1/executor", - Http::EXECUTOR_HELP, + Http::EXECUTOR_HELP(), [http](const process::http::Request& request) { Http::log(request); return http.executor(request); @@ -524,19 +524,19 @@ void Slave::initialize() // TODO(ijimenez): Remove this endpoint at the end of the // deprecation cycle on 0.26. route("/state.json", - Http::STATE_HELP, + Http::STATE_HELP(), [http](const process::http::Request& request) { Http::log(request); return http.state(request); }); route("/state", - Http::STATE_HELP, + Http::STATE_HELP(), [http](const process::http::Request& request) { Http::log(request); return http.state(request); }); route("/health", - Http::HEALTH_HELP, + Http::HEALTH_HELP(), [http](const process::http::Request& request) { return http.health(request); }); http://git-wip-us.apache.org/repos/asf/mesos/blob/ffbc7d96/src/slave/slave.hpp ---------------------------------------------------------------------- diff --git a/src/slave/slave.hpp b/src/slave/slave.hpp index d6e417b..aeccc08 100644 --- a/src/slave/slave.hpp +++ b/src/slave/slave.hpp @@ -415,9 +415,9 @@ private: process::Future<process::http::Response> state( const process::http::Request& request) const; - static const std::string EXECUTOR_HELP; - static const std::string HEALTH_HELP; - static const std::string STATE_HELP; + static std::string EXECUTOR_HELP(); + static std::string HEALTH_HELP(); + static std::string STATE_HELP(); private: Slave* slave;
