Removed '.json' extension in master endpoints url. Added HTTP endpoints in master without the json extension.
Review: https://reviews.apache.org/r/36125 Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/f893c856 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/f893c856 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/f893c856 Branch: refs/heads/master Commit: f893c856c60f8169713f19fd99be73ac10dcc259 Parents: 7b8da01 Author: Isabel Jimenez <[email protected]> Authored: Fri Sep 11 22:23:56 2015 -0700 Committer: Adam B <[email protected]> Committed: Sat Sep 12 02:21:32 2015 -0700 ---------------------------------------------------------------------- src/cli/mesos-cat | 2 +- src/cli/mesos-ps | 2 +- src/cli/mesos-scp | 2 +- src/cli/mesos-tail | 2 +- src/master/constants.hpp | 2 +- src/master/master.cpp | 24 ++++++++++++++ src/master/master.hpp | 6 ++-- src/tests/fault_tolerance_tests.cpp | 8 ++--- src/tests/master_tests.cpp | 45 +++++++++++++------------- src/webui/master/static/js/controllers.js | 6 ++-- 10 files changed, 62 insertions(+), 37 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/f893c856/src/cli/mesos-cat ---------------------------------------------------------------------- diff --git a/src/cli/mesos-cat b/src/cli/mesos-cat index 24a1e64..63a90d1 100755 --- a/src/cli/mesos-cat +++ b/src/cli/mesos-cat @@ -116,7 +116,7 @@ def main(): # Get the master's state. try: state = json.loads(http.get(resolve(options.master), - '/master/state.json')) + '/master/state')) except: fatal('Failed to get the master state') http://git-wip-us.apache.org/repos/asf/mesos/blob/f893c856/src/cli/mesos-ps ---------------------------------------------------------------------- diff --git a/src/cli/mesos-ps b/src/cli/mesos-ps index 7976069..f7fac4b 100755 --- a/src/cli/mesos-ps +++ b/src/cli/mesos-ps @@ -163,7 +163,7 @@ def main(): # Get the master's state. try: state = json.loads(http.get(resolve(options.master), - '/master/state.json')) + '/master/state')) except: fatal('Failed to get the master state') http://git-wip-us.apache.org/repos/asf/mesos/blob/f893c856/src/cli/mesos-scp ---------------------------------------------------------------------- diff --git a/src/cli/mesos-scp b/src/cli/mesos-scp index 77b8557..f305abd 100755 --- a/src/cli/mesos-scp +++ b/src/cli/mesos-scp @@ -50,7 +50,7 @@ def main(): # Get the master's state. try: state = json.loads(http.get(resolve(options.master), - '/master/state.json')) + '/master/state')) except: fatal('Failed to get the master state') http://git-wip-us.apache.org/repos/asf/mesos/blob/f893c856/src/cli/mesos-tail ---------------------------------------------------------------------- diff --git a/src/cli/mesos-tail b/src/cli/mesos-tail index 6acec2c..28e16b2 100755 --- a/src/cli/mesos-tail +++ b/src/cli/mesos-tail @@ -95,7 +95,7 @@ def main(): # Get the master's state. try: master_state = json.loads(http.get(resolve(options.master), - '/master/state.json')) + '/master/state')) except: fatal('Failed to get the master state') http://git-wip-us.apache.org/repos/asf/mesos/blob/f893c856/src/master/constants.hpp ---------------------------------------------------------------------- diff --git a/src/master/constants.hpp b/src/master/constants.hpp index c3fe140..51d4774 100644 --- a/src/master/constants.hpp +++ b/src/master/constants.hpp @@ -100,7 +100,7 @@ extern const uint32_t MAX_COMPLETED_TASKS_PER_FRAMEWORK; // Time interval to check for updated watchers list. extern const Duration WHITELIST_WATCH_INTERVAL; -// Default number of tasks (limit) for /master/tasks.json endpoint. +// Default number of tasks (limit) for /master/tasks endpoint. extern const uint32_t TASK_LIMIT; /** http://git-wip-us.apache.org/repos/asf/mesos/blob/f893c856/src/master/master.cpp ---------------------------------------------------------------------- diff --git a/src/master/master.cpp b/src/master/master.cpp index 4b60e63..c90311f 100644 --- a/src/master/master.cpp +++ b/src/master/master.cpp @@ -785,12 +785,20 @@ void Master::initialize() [http](const process::http::Request& request) { return http.reserve(request); }); + // TODO(ijimenez): Remove this endpoint at the end of the + // deprecation cycle on 0.26. route("/roles.json", Http::ROLES_HELP, [http](const process::http::Request& request) { Http::log(request); return http.roles(request); }); + route("/roles", + Http::ROLES_HELP, + [http](const process::http::Request& request) { + Http::log(request); + return http.roles(request); + }); route("/teardown", Http::TEARDOWN_HELP, [http](const process::http::Request& request) { @@ -803,24 +811,40 @@ void Master::initialize() Http::log(request); return http.slaves(request); }); + // TODO(ijimenez): Remove this endpoint at the end of the + // deprecation cycle on 0.26. route("/state.json", Http::STATE_HELP, [http](const process::http::Request& request) { Http::log(request); return http.state(request); }); + route("/state", + Http::STATE_HELP, + [http](const process::http::Request& request) { + Http::log(request); + return http.state(request); + }); route("/state-summary", Http::STATESUMMARY_HELP, [http](const process::http::Request& request) { Http::log(request); return http.stateSummary(request); }); + // TODO(ijimenez): Remove this endpoint at the end of the + // deprecation cycle. route("/tasks.json", Http::TASKS_HELP, [http](const process::http::Request& request) { Http::log(request); return http.tasks(request); }); + route("/tasks", + Http::TASKS_HELP, + [http](const process::http::Request& request) { + Http::log(request); + return http.tasks(request); + }); route("/maintenance/schedule", Http::MAINTENANCE_SCHEDULE_HELP, [http](const process::http::Request& request) { http://git-wip-us.apache.org/repos/asf/mesos/blob/f893c856/src/master/master.hpp ---------------------------------------------------------------------- diff --git a/src/master/master.hpp b/src/master/master.hpp index 1dfc947..12cc1ad 100644 --- a/src/master/master.hpp +++ b/src/master/master.hpp @@ -826,7 +826,7 @@ private: process::Future<process::http::Response> reserve( const process::http::Request& request) const; - // /master/roles.json + // /master/roles process::Future<process::http::Response> roles( const process::http::Request& request) const; @@ -838,7 +838,7 @@ private: process::Future<process::http::Response> slaves( const process::http::Request& request) const; - // /master/state.json + // /master/state process::Future<process::http::Response> state( const process::http::Request& request) const; @@ -846,7 +846,7 @@ private: process::Future<process::http::Response> stateSummary( const process::http::Request& request) const; - // /master/tasks.json + // /master/tasks process::Future<process::http::Response> tasks( const process::http::Request& request) const; http://git-wip-us.apache.org/repos/asf/mesos/blob/f893c856/src/tests/fault_tolerance_tests.cpp ---------------------------------------------------------------------- diff --git a/src/tests/fault_tolerance_tests.cpp b/src/tests/fault_tolerance_tests.cpp index 82f8cfd..061e099 100644 --- a/src/tests/fault_tolerance_tests.cpp +++ b/src/tests/fault_tolerance_tests.cpp @@ -167,7 +167,7 @@ TEST_F(FaultToleranceTest, ReregisterCompletedFrameworks) ASSERT_SOME(slave); // Verify master/slave have 0 completed/running frameworks. - Future<Response> masterState = process::http::get(master.get(), "state.json"); + Future<Response> masterState = process::http::get(master.get(), "state"); AWAIT_EXPECT_RESPONSE_STATUS_EQ(OK().status, masterState); AWAIT_EXPECT_RESPONSE_HEADER_EQ( @@ -224,7 +224,7 @@ TEST_F(FaultToleranceTest, ReregisterCompletedFrameworks) EXPECT_EQ(TASK_RUNNING, statusRunning.get().state()); // Verify master and slave recognize the running task/framework. - masterState = process::http::get(master.get(), "state.json"); + masterState = process::http::get(master.get(), "state"); parse = JSON::parse<JSON::Object>(masterState.get().body); ASSERT_SOME(parse); @@ -262,7 +262,7 @@ TEST_F(FaultToleranceTest, ReregisterCompletedFrameworks) // At this point, the task is killed, but the framework is still // running. This is because the executor has to time-out before // it exits. - masterState = process::http::get(master.get(), "state.json"); + masterState = process::http::get(master.get(), "state"); parse = JSON::parse<JSON::Object>(masterState.get().body); ASSERT_SOME(parse); masterJSON = parse.get(); @@ -340,7 +340,7 @@ TEST_F(FaultToleranceTest, ReregisterCompletedFrameworks) Clock::settle(); Clock::resume(); - masterState = process::http::get(master.get(), "state.json"); + masterState = process::http::get(master.get(), "state"); parse = JSON::parse<JSON::Object>(masterState.get().body); ASSERT_SOME(parse); masterJSON = parse.get(); http://git-wip-us.apache.org/repos/asf/mesos/blob/f893c856/src/tests/master_tests.cpp ---------------------------------------------------------------------- diff --git a/src/tests/master_tests.cpp b/src/tests/master_tests.cpp index 8a6b98b..dd65fcc 100644 --- a/src/tests/master_tests.cpp +++ b/src/tests/master_tests.cpp @@ -280,7 +280,7 @@ TEST_F(MasterTest, ShutdownFrameworkWhileTaskRunning) // Request master state. Future<process::http::Response> response = - process::http::get(master.get(), "state.json"); + process::http::get(master.get(), "state"); AWAIT_READY(response); // These checks are not essential for the test, but may help @@ -2178,7 +2178,7 @@ TEST_F(MasterZooKeeperTest, MasterInfoAddress) // This test ensures that when a master fails over, those tasks that // belong to some currently unregistered frameworks will appear in the -// "orphan_tasks" field in the state.json. And those unregistered frameworks +// "orphan_tasks" field in the state endpoint. And those unregistered frameworks // will appear in the "unregistered_frameworks" field. TEST_F(MasterTest, OrphanTasks) { @@ -2224,7 +2224,7 @@ TEST_F(MasterTest, OrphanTasks) // Get the master's state. Future<process::http::Response> response = - process::http::get(master.get(), "state.json"); + process::http::get(master.get(), "state"); AWAIT_READY(response); EXPECT_SOME_EQ( @@ -2290,7 +2290,7 @@ TEST_F(MasterTest, OrphanTasks) AWAIT_READY(subscribeCall); // Get the master's state. - response = process::http::get(master.get(), "state.json"); + response = process::http::get(master.get(), "state"); AWAIT_READY(response); EXPECT_SOME_EQ( @@ -2325,7 +2325,7 @@ TEST_F(MasterTest, OrphanTasks) AWAIT_READY(frameworkRegisteredMessage); // Get the master's state. - response = process::http::get(master.get(), "state.json"); + response = process::http::get(master.get(), "state"); AWAIT_READY(response); EXPECT_SOME_EQ( @@ -2792,7 +2792,7 @@ TEST_F(MasterTest, StateEndpoint) ASSERT_SOME(master); Future<process::http::Response> response = - process::http::get(master.get(), "state.json"); + process::http::get(master.get(), "state"); AWAIT_EXPECT_RESPONSE_STATUS_EQ(process::http::OK().status, response); @@ -2973,7 +2973,7 @@ TEST_F(MasterTest, StateSummaryEndpoint) // This test ensures that the web UI and capabilities of a framework -// are included in the state.json endpoint, if provided by the +// are included in the master's state endpoint, if provided by the // framework. TEST_F(MasterTest, FrameworkWebUIUrlandCapabilities) { @@ -2998,7 +2998,7 @@ TEST_F(MasterTest, FrameworkWebUIUrlandCapabilities) AWAIT_READY(registered); Future<process::http::Response> masterState = - process::http::get(master.get(), "state.json"); + process::http::get(master.get(), "state"); AWAIT_EXPECT_RESPONSE_STATUS_EQ(process::http::OK().status, masterState); Try<JSON::Object> parse = JSON::parse<JSON::Object>(masterState.get().body); @@ -3035,7 +3035,7 @@ TEST_F(MasterTest, FrameworkWebUIUrlandCapabilities) } -// This test verifies that label values are exposed over the master +// This test verifies that label values are exposed over the master's // state endpoint. TEST_F(MasterTest, TaskLabels) { @@ -3103,9 +3103,9 @@ TEST_F(MasterTest, TaskLabels) AWAIT_READY(update); - // Verify label key and value in master state.json. + // Verify label key and value in the master's state endpoint. Future<process::http::Response> response = - process::http::get(master.get(), "state.json"); + process::http::get(master.get(), "state"); AWAIT_READY(response); EXPECT_SOME_EQ( @@ -3143,7 +3143,7 @@ TEST_F(MasterTest, TaskLabels) // This test verifies that TaskStatus label values are exposed over -// the master state endpoint. +// the master's state endpoint. TEST_F(MasterTest, TaskStatusLabels) { Try<PID<Master>> master = StartMaster(); @@ -3244,9 +3244,9 @@ TEST_F(MasterTest, TaskStatusLabels) } -// This tests the 'active' field in slave entries from state.json. We -// first verify an active slave, deactivate it and verify that the -// 'active' field is false. +// This tests the 'active' field in slave entries from the master's +// state endpoint. We first verify an active slave, deactivate it +// and verify that the 'active' field is false. TEST_F(MasterTest, SlaveActiveEndpoint) { // Start a master. @@ -3263,7 +3263,7 @@ TEST_F(MasterTest, SlaveActiveEndpoint) // Verify slave is active. Future<process::http::Response> response = - process::http::get(master.get(), "state.json"); + process::http::get(master.get(), "state"); AWAIT_READY(response); Try<JSON::Object> parse = JSON::parse<JSON::Object>(response.get().body); @@ -3285,7 +3285,7 @@ TEST_F(MasterTest, SlaveActiveEndpoint) AWAIT_READY(deactivateSlave); // Verify slave is inactive. - response = process::http::get(master.get(), "state.json"); + response = process::http::get(master.get(), "state"); AWAIT_READY(response); parse = JSON::parse<JSON::Object>(response.get().body); @@ -3300,7 +3300,7 @@ TEST_F(MasterTest, SlaveActiveEndpoint) // This test verifies that service info for tasks is exposed over the -// master state endpoint. +// master's state endpoint. TEST_F(MasterTest, TaskDiscoveryInfo) { Try<PID<Master>> master = StartMaster(); @@ -3382,9 +3382,9 @@ TEST_F(MasterTest, TaskDiscoveryInfo) AWAIT_READY(update); - // Verify label key and value in master state.json. + // Verify label key and value in the master's state endpoint. Future<process::http::Response> response = - process::http::get(master.get(), "state.json"); + process::http::get(master.get(), "state"); AWAIT_READY(response); EXPECT_SOME_EQ( @@ -3594,8 +3594,9 @@ TEST_F(MasterTest, MasterFailoverLongLivedExecutor) Shutdown(); // Must shutdown before 'containerizer' gets deallocated. } -// This test ensures that if a framework scheduler provides any labels in its -// FrameworkInfo message, those labels are included in the state.json endpoint. +// This test ensures that if a framework scheduler provides any +// labels in its FrameworkInfo message, those labels are included +// in the master's state endpoint. TEST_F(MasterTest, FrameworkInfoLabels) { Try<PID<Master>> master = StartMaster(); http://git-wip-us.apache.org/repos/asf/mesos/blob/f893c856/src/webui/master/static/js/controllers.js ---------------------------------------------------------------------- diff --git a/src/webui/master/static/js/controllers.js b/src/webui/master/static/js/controllers.js index 6b46ab2..8193a44 100644 --- a/src/webui/master/static/js/controllers.js +++ b/src/webui/master/static/js/controllers.js @@ -282,7 +282,7 @@ }); var poll = function() { - $http.get('master/state.json', + $http.get('master/state', {transformResponse: function(data) { return data; }}) .success(function(data) { if (update($scope, $timeout, data)) { @@ -637,8 +637,8 @@ // directory to browse is known by the slave but not by the master. Request // the directory from the slave, and then redirect to it. // - // TODO(ssorallen): Add `executor.directory` to the state.json output so this - // controller of rerouting is no longer necessary. + // TODO(ssorallen): Add `executor.directory` to the master's state endpoint + // output so this controller of rerouting is no longer necessary. mesosApp.controller('SlaveExecutorRerouterCtrl', function($alert, $http, $location, $routeParams, $scope, $window) {
