You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by vi...@apache.org on 2016/10/14 19:00:07 UTC
[3/5] mesos git commit: Exposed the executor's type in the endpoints.
Exposed the executor's type in the endpoints.
Review: https://reviews.apache.org/r/52520/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/88cd1df7
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/88cd1df7
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/88cd1df7
Branch: refs/heads/master
Commit: 88cd1df7af6904e2a34ece1f10bee59915d68f67
Parents: d2da824
Author: haosdent huang <ha...@gmail.com>
Authored: Fri Oct 14 11:59:39 2016 -0700
Committer: Vinod Kone <vi...@gmail.com>
Committed: Fri Oct 14 11:59:39 2016 -0700
----------------------------------------------------------------------
src/common/http.cpp | 4 ++++
src/slave/http.cpp | 4 ++++
src/tests/default_executor_tests.cpp | 23 +++++++++++++++++++++++
3 files changed, 31 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/88cd1df7/src/common/http.cpp
----------------------------------------------------------------------
diff --git a/src/common/http.cpp b/src/common/http.cpp
index 538330a..fb8454a 100644
--- a/src/common/http.cpp
+++ b/src/common/http.cpp
@@ -530,6 +530,10 @@ void json(JSON::ObjectWriter* writer, const ExecutorInfo& executorInfo)
if (executorInfo.has_labels()) {
writer->field("labels", executorInfo.labels());
}
+
+ if (executorInfo.has_type()) {
+ writer->field("type", ExecutorInfo::Type_Name(executorInfo.type()));
+ }
}
http://git-wip-us.apache.org/repos/asf/mesos/blob/88cd1df7/src/slave/http.cpp
----------------------------------------------------------------------
diff --git a/src/slave/http.cpp b/src/slave/http.cpp
index a1fbb7a..a32aca4 100644
--- a/src/slave/http.cpp
+++ b/src/slave/http.cpp
@@ -153,6 +153,10 @@ struct ExecutorWriter
writer->field("labels", executor_->info.labels());
}
+ if (executor_->info.has_type()) {
+ writer->field("type", ExecutorInfo::Type_Name(executor_->info.type()));
+ }
+
writer->field("tasks", [this](JSON::ArrayWriter* writer) {
foreach (Task* task, executor_->launchedTasks.values()) {
if (!approveViewTask(taskApprover_, *task, framework_->info)) {
http://git-wip-us.apache.org/repos/asf/mesos/blob/88cd1df7/src/tests/default_executor_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/default_executor_tests.cpp b/src/tests/default_executor_tests.cpp
index dc002c6..92e6b9f 100644
--- a/src/tests/default_executor_tests.cpp
+++ b/src/tests/default_executor_tests.cpp
@@ -25,6 +25,7 @@
#include <mesos/v1/executor.hpp>
#include <mesos/v1/scheduler.hpp>
+#include <process/http.hpp>
#include <process/owned.hpp>
#include <stout/hashset.hpp>
@@ -40,6 +41,9 @@ using mesos::v1::scheduler::Mesos;
using process::Future;
using process::Owned;
+using process::http::OK;
+using process::http::Response;
+
using std::pair;
using std::set;
using std::string;
@@ -181,6 +185,25 @@ TEST_P(DefaultExecutorTest, ROOT_TaskRunning)
executorInfo.executor_id()),
"tasks",
taskInfo.task_id().value())));
+
+ // Verify that the executor's type is exposed in the agent's state
+ // endpoint.
+ Future<Response> response = process::http::get(
+ slave.get()->pid,
+ "state",
+ None(),
+ createBasicAuthHeaders(DEFAULT_CREDENTIAL));
+
+ AWAIT_EXPECT_RESPONSE_STATUS_EQ(OK().status, response);
+ AWAIT_EXPECT_RESPONSE_HEADER_EQ(APPLICATION_JSON, "Content-Type", response);
+
+ Try<JSON::Object> parse = JSON::parse<JSON::Object>(response.get().body);
+ ASSERT_SOME(parse);
+ JSON::Object state = parse.get();
+
+ EXPECT_SOME_EQ(
+ JSON::String(ExecutorInfo::Type_Name(executorInfo.type())),
+ state.find<JSON::String>("frameworks[0].executors[0].type"));
}