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/07/07 01:43:11 UTC
mesos git commit: Added stub /call endpoint on the master.
Repository: mesos
Updated Branches:
refs/heads/master 7f1d97c93 -> abc5cd9e8
Added stub /call endpoint on the master.
Review: https://reviews.apache.org/r/36215
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/abc5cd9e
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/abc5cd9e
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/abc5cd9e
Branch: refs/heads/master
Commit: abc5cd9e89af6ef8315d279ce01ad58f96850598
Parents: 7f1d97c
Author: Isabel Jimenez <co...@isabeljimenez.com>
Authored: Mon Jul 6 16:22:45 2015 -0700
Committer: Benjamin Mahler <be...@gmail.com>
Committed: Mon Jul 6 16:34:48 2015 -0700
----------------------------------------------------------------------
src/Makefile.am | 3 +-
src/master/http.cpp | 18 +++++++++++
src/master/master.cpp | 5 ++++
src/master/master.hpp | 5 ++++
src/tests/http_api_tests.cpp | 63 +++++++++++++++++++++++++++++++++++++++
5 files changed, 93 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/abc5cd9e/src/Makefile.am
----------------------------------------------------------------------
diff --git a/src/Makefile.am b/src/Makefile.am
index addb63f..37aa878 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1480,13 +1480,14 @@ mesos_tests_SOURCES = \
tests/external_containerizer_test.cpp \
tests/health_check_tests.cpp \
tests/fault_tolerance_tests.cpp \
- tests/fetcher_cache_tests.cpp \
+ tests/fetcher_cache_tests.cpp \
tests/fetcher_tests.cpp \
tests/files_tests.cpp \
tests/flags.cpp \
tests/gc_tests.cpp \
tests/hierarchical_allocator_tests.cpp \
tests/hook_tests.cpp \
+ tests/http_api_tests.cpp \
tests/isolator_tests.cpp \
tests/log_tests.cpp \
tests/logging_tests.cpp \
http://git-wip-us.apache.org/repos/asf/mesos/blob/abc5cd9e/src/master/http.cpp
----------------------------------------------------------------------
diff --git a/src/master/http.cpp b/src/master/http.cpp
index 2be613b..23a6d4b 100644
--- a/src/master/http.cpp
+++ b/src/master/http.cpp
@@ -63,6 +63,7 @@ using process::HELP;
using process::TLDR;
using process::USAGE;
+using process::http::Accepted;
using process::http::BadRequest;
using process::http::InternalServerError;
using process::http::NotFound;
@@ -291,6 +292,23 @@ void Master::Http::log(const Request& request)
}
+// TODO(ijiminez): Add some information or pointers to help
+// users understand the HTTP Event/Call API.
+const string Master::Http::CALL_HELP = HELP(
+ TLDR(
+ "Endpoint for schedulers to make Calls against the master."),
+ USAGE(
+ "/master/call"),
+ DESCRIPTION(
+ "Returns 202 Accepted iff the request is accepted."));
+
+
+Future<Response> Master::Http::call(const Request& request) const
+{
+ return Accepted();
+}
+
+
const string Master::Http::HEALTH_HELP = HELP(
TLDR(
"Health check of the Master."),
http://git-wip-us.apache.org/repos/asf/mesos/blob/abc5cd9e/src/master/master.cpp
----------------------------------------------------------------------
diff --git a/src/master/master.cpp b/src/master/master.cpp
index c5a4875..35e1475 100644
--- a/src/master/master.cpp
+++ b/src/master/master.cpp
@@ -737,6 +737,11 @@ void Master::initialize()
// Setup HTTP routes.
Http http = Http(this);
+ route("/call",
+ Http::CALL_HELP,
+ [http](const process::http::Request& request) {
+ return http.call(request);
+ });
route("/health",
Http::HEALTH_HELP,
[http](const process::http::Request& request) {
http://git-wip-us.apache.org/repos/asf/mesos/blob/abc5cd9e/src/master/master.hpp
----------------------------------------------------------------------
diff --git a/src/master/master.hpp b/src/master/master.hpp
index baaf849..2343a68 100644
--- a/src/master/master.hpp
+++ b/src/master/master.hpp
@@ -1061,6 +1061,10 @@ private:
// desired request handler to get consistent request logging.
static void log(const process::http::Request& request);
+ // /master/call
+ process::Future<process::http::Response> call(
+ const process::http::Request& request) const;
+
// /master/health
process::Future<process::http::Response> health(
const process::http::Request& request) const;
@@ -1097,6 +1101,7 @@ private:
process::Future<process::http::Response> tasks(
const process::http::Request& request) const;
+ const static std::string CALL_HELP;
const static std::string HEALTH_HELP;
const static std::string OBSERVE_HELP;
const static std::string REDIRECT_HELP;
http://git-wip-us.apache.org/repos/asf/mesos/blob/abc5cd9e/src/tests/http_api_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/http_api_tests.cpp b/src/tests/http_api_tests.cpp
new file mode 100644
index 0000000..64bbeb6
--- /dev/null
+++ b/src/tests/http_api_tests.cpp
@@ -0,0 +1,63 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <process/future.hpp>
+#include <process/gtest.hpp>
+#include <process/http.hpp>
+#include <process/pid.hpp>
+
+#include "master/master.hpp"
+
+#include "tests/mesos.hpp"
+#include "tests/utils.hpp"
+
+
+using mesos::internal::master::Master;
+
+using process::Future;
+using process::PID;
+
+using process::http::Accepted;
+using process::http::Response;
+
+namespace mesos {
+namespace internal {
+namespace tests {
+
+
+class HttpApiTest : public MesosTest {};
+
+
+// Ensures that the master returns 202 from the /call stub.
+TEST_F(HttpApiTest, Call)
+{
+ Try<PID<Master>> master = StartMaster();
+ ASSERT_SOME(master);
+
+ Future<Response> response = process::http::post(
+ master.get(),
+ "call",
+ None(),
+ None());
+
+ AWAIT_EXPECT_RESPONSE_STATUS_EQ(Accepted().status, response);
+}
+
+} // namespace tests {
+} // namespace internal {
+} // namespace mesos {