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 2016/05/26 06:59:32 UTC
[2/4] mesos git commit: Moved `Task` to public protobuf definitions.
Moved `Task` to public protobuf definitions.
As we need to authorize `Task`, we need to include `Task` in the public
protobuf definitions. This move also requires the json logic to adapt.
Review: https://reviews.apache.org/r/47490/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/5f3d6050
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/5f3d6050
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/5f3d6050
Branch: refs/heads/master
Commit: 5f3d60505b64f91061dc309d368b5f5dd863533d
Parents: 116f202
Author: Joerg Schad <jo...@mesosphere.io>
Authored: Wed May 25 23:01:44 2016 -0700
Committer: Michael Park <mp...@apache.org>
Committed: Wed May 25 23:48:19 2016 -0700
----------------------------------------------------------------------
include/mesos/mesos.proto | 46 ++++++++++++++++++++++++++++++++++++
include/mesos/type_utils.hpp | 1 +
src/common/http.cpp | 49 ++++++++++++++++++++-------------------
src/common/http.hpp | 6 ++---
src/common/type_utils.cpp | 27 +++++++++++++++++++++
src/messages/messages.cpp | 27 ---------------------
src/messages/messages.proto | 46 ------------------------------------
7 files changed, 102 insertions(+), 100 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/5f3d6050/include/mesos/mesos.proto
----------------------------------------------------------------------
diff --git a/include/mesos/mesos.proto b/include/mesos/mesos.proto
index f666535..afa6e5e 100644
--- a/include/mesos/mesos.proto
+++ b/include/mesos/mesos.proto
@@ -1301,6 +1301,52 @@ message TaskInfo {
}
+// TODO(bmahler): Add executor_uuid here, and send it to the master. This will
+// allow us to expose executor work directories for tasks in the webui when
+// looking from the master level. Currently only the slave knows which run the
+// task belongs to.
+/**
+ * Describes a task, similar to `TaskInfo`.
+ *
+ * `Task` is used in some of the Mesos messages found below.
+ * `Task` is used instead of `TaskInfo` if:
+ * 1) we need additional IDs, such as a specific
+ * framework, executor, or agent; or
+ * 2) we do not need the additional data, such as the command run by the
+ * task or the health checks. These additional fields may be large and
+ * unnecessary for some Mesos messages.
+ *
+ * `Task` is generally constructed from a `TaskInfo`. See protobuf::createTask.
+ */
+message Task {
+ required string name = 1;
+ required TaskID task_id = 2;
+ required FrameworkID framework_id = 3;
+ optional ExecutorID executor_id = 4;
+ required SlaveID slave_id = 5;
+ required TaskState state = 6; // Latest state of the task.
+ repeated Resource resources = 7;
+ repeated TaskStatus statuses = 8;
+
+ // These fields correspond to the state and uuid of the latest
+ // status update forwarded to the master.
+ // NOTE: Either both the fields must be set or both must be unset.
+ optional TaskState status_update_state = 9;
+ optional bytes status_update_uuid = 10;
+
+ optional Labels labels = 11;
+
+ // Service discovery information for the task. It is not interpreted
+ // or acted upon by Mesos. It is up to a service discovery system
+ // to use this information as needed and to handle tasks without
+ // service discovery information.
+ optional DiscoveryInfo discovery = 12;
+
+ // Container information for the task.
+ optional ContainerInfo container = 13;
+}
+
+
/**
* Describes possible task states. IMPORTANT: Mesos assumes tasks that
* enter terminal states (see below) imply the task is no longer
http://git-wip-us.apache.org/repos/asf/mesos/blob/5f3d6050/include/mesos/type_utils.hpp
----------------------------------------------------------------------
diff --git a/include/mesos/type_utils.hpp b/include/mesos/type_utils.hpp
index 27fa8c9..0d4dd2f 100644
--- a/include/mesos/type_utils.hpp
+++ b/include/mesos/type_utils.hpp
@@ -64,6 +64,7 @@ bool operator==(
const ResourceStatistics& right);
bool operator==(const SlaveInfo& left, const SlaveInfo& right);
+bool operator==(const Task& left, const Task& right);
bool operator==(const TaskStatus& left, const TaskStatus& right);
bool operator==(const URL& left, const URL& right);
bool operator==(const Volume& left, const Volume& right);
http://git-wip-us.apache.org/repos/asf/mesos/blob/5f3d6050/src/common/http.cpp
----------------------------------------------------------------------
diff --git a/src/common/http.cpp b/src/common/http.cpp
index ad6a4b4..a6572f5 100644
--- a/src/common/http.cpp
+++ b/src/common/http.cpp
@@ -372,30 +372,6 @@ JSON::Object model(const ExecutorInfo& executorInfo)
}
-void json(JSON::ObjectWriter* writer, const Task& task)
-{
- writer->field("id", task.task_id().value());
- writer->field("name", task.name());
- writer->field("framework_id", task.framework_id().value());
- writer->field("executor_id", task.executor_id().value());
- writer->field("slave_id", task.slave_id().value());
- writer->field("state", TaskState_Name(task.state()));
- writer->field("resources", Resources(task.resources()));
- writer->field("statuses", task.statuses());
-
- if (task.has_labels()) {
- writer->field("labels", task.labels());
- }
-
- if (task.has_discovery()) {
- writer->field("discovery", JSON::Protobuf(task.discovery()));
- }
-
- if (task.has_container()) {
- writer->field("container", JSON::Protobuf(task.container()));
- }
-}
-
} // namespace internal {
void json(JSON::ObjectWriter* writer, const Attributes& attributes)
@@ -541,6 +517,31 @@ void json(JSON::ObjectWriter* writer, const Resources& resources)
}
+void json(JSON::ObjectWriter* writer, const Task& task)
+{
+ writer->field("id", task.task_id().value());
+ writer->field("name", task.name());
+ writer->field("framework_id", task.framework_id().value());
+ writer->field("executor_id", task.executor_id().value());
+ writer->field("slave_id", task.slave_id().value());
+ writer->field("state", TaskState_Name(task.state()));
+ writer->field("resources", Resources(task.resources()));
+ writer->field("statuses", task.statuses());
+
+ if (task.has_labels()) {
+ writer->field("labels", task.labels());
+ }
+
+ if (task.has_discovery()) {
+ writer->field("discovery", JSON::Protobuf(task.discovery()));
+ }
+
+ if (task.has_container()) {
+ writer->field("container", JSON::Protobuf(task.container()));
+ }
+}
+
+
void json(JSON::ObjectWriter* writer, const TaskStatus& status)
{
writer->field("state", TaskState_Name(status.state()));
http://git-wip-us.apache.org/repos/asf/mesos/blob/5f3d6050/src/common/http.hpp
----------------------------------------------------------------------
diff --git a/src/common/http.hpp b/src/common/http.hpp
index f47e358..588a1eb 100644
--- a/src/common/http.hpp
+++ b/src/common/http.hpp
@@ -36,11 +36,9 @@ namespace mesos {
class Attributes;
class Resources;
-
-namespace internal {
-
class Task;
+namespace internal {
// Serializes a protobuf message for transmission
// based on the HTTP content type.
@@ -95,8 +93,10 @@ void json(JSON::ObjectWriter* writer, const CommandInfo& command);
void json(JSON::ObjectWriter* writer, const ExecutorInfo& executorInfo);
void json(JSON::ArrayWriter* writer, const Labels& labels);
void json(JSON::ObjectWriter* writer, const Resources& resources);
+void json(JSON::ObjectWriter* writer, const Task& task);
void json(JSON::ObjectWriter* writer, const TaskStatus& status);
+
const process::http::authorization::AuthorizationCallbacks
createAuthorizationCallbacks(Authorizer* authorizer);
http://git-wip-us.apache.org/repos/asf/mesos/blob/5f3d6050/src/common/type_utils.cpp
----------------------------------------------------------------------
diff --git a/src/common/type_utils.cpp b/src/common/type_utils.cpp
index 037c433..b49e68b 100644
--- a/src/common/type_utils.cpp
+++ b/src/common/type_utils.cpp
@@ -350,6 +350,33 @@ bool operator==(const SlaveInfo& left, const SlaveInfo& right)
}
+bool operator==(const Task& left, const Task& right)
+{
+ // Order of task statuses is important.
+ if (left.statuses().size() != right.statuses().size()) {
+ return false;
+ }
+
+ for (int i = 0; i < left.statuses().size(); i++) {
+ if (left.statuses().Get(i) != right.statuses().Get(i)) {
+ return false;
+ }
+ }
+
+ return left.name() == right.name() &&
+ left.task_id() == right.task_id() &&
+ left.framework_id() == right.framework_id() &&
+ left.executor_id() == right.executor_id() &&
+ left.slave_id() == right.slave_id() &&
+ left.state() == right.state() &&
+ Resources(left.resources()) == Resources(right.resources()) &&
+ left.status_update_state() == right.status_update_state() &&
+ left.status_update_uuid() == right.status_update_uuid() &&
+ left.labels() == right.labels() &&
+ left.discovery() == right.discovery();
+}
+
+
// TODO(bmahler): Use SerializeToString here?
bool operator==(const TaskStatus& left, const TaskStatus& right)
{
http://git-wip-us.apache.org/repos/asf/mesos/blob/5f3d6050/src/messages/messages.cpp
----------------------------------------------------------------------
diff --git a/src/messages/messages.cpp b/src/messages/messages.cpp
index 41dcdb3..9274b1b 100644
--- a/src/messages/messages.cpp
+++ b/src/messages/messages.cpp
@@ -26,33 +26,6 @@ using std::ostream;
namespace mesos {
namespace internal {
-bool operator==(const Task& left, const Task& right)
-{
- // Order of task statuses is important.
- if (left.statuses().size() != right.statuses().size()) {
- return false;
- }
-
- for (int i = 0; i < left.statuses().size(); i++) {
- if (left.statuses().Get(i) != right.statuses().Get(i)) {
- return false;
- }
- }
-
- return left.name() == right.name() &&
- left.task_id() == right.task_id() &&
- left.framework_id() == right.framework_id() &&
- left.executor_id() == right.executor_id() &&
- left.slave_id() == right.slave_id() &&
- left.state() == right.state() &&
- Resources(left.resources()) == Resources(right.resources()) &&
- left.status_update_state() == right.status_update_state() &&
- left.status_update_uuid() == right.status_update_uuid() &&
- left.labels() == right.labels() &&
- left.discovery() == right.discovery();
-}
-
-
ostream& operator<<(ostream& stream, const StatusUpdate& update)
{
stream << update.status().state();
http://git-wip-us.apache.org/repos/asf/mesos/blob/5f3d6050/src/messages/messages.proto
----------------------------------------------------------------------
diff --git a/src/messages/messages.proto b/src/messages/messages.proto
index 7fd3a2a..05e6476 100644
--- a/src/messages/messages.proto
+++ b/src/messages/messages.proto
@@ -23,52 +23,6 @@ package mesos.internal;
// "mesos.executor" package includes messages that the executor handles).
-// TODO(bmahler): Add executor_uuid here, and send it to the master. This will
-// allow us to expose executor work directories for tasks in the webui when
-// looking from the master level. Currently only the slave knows which run the
-// task belongs to.
-/**
- * Describes a task, similar to `TaskInfo`.
- *
- * `Task` is used in some of the Mesos messages found below.
- * `Task` is used instead of `TaskInfo` if:
- * 1) we need additional IDs, such as a specific
- * framework, executor, or agent; or
- * 2) we do not need the additional data, such as the command run by the
- * task or the health checks. These additional fields may be large and
- * unnecessary for some Mesos messages.
- *
- * `Task` is generally constructed from a `TaskInfo`. See protobuf::createTask.
- */
-message Task {
- required string name = 1;
- required TaskID task_id = 2;
- required FrameworkID framework_id = 3;
- optional ExecutorID executor_id = 4;
- required SlaveID slave_id = 5;
- required TaskState state = 6; // Latest state of the task.
- repeated Resource resources = 7;
- repeated TaskStatus statuses = 8;
-
- // These fields correspond to the state and uuid of the latest
- // status update forwarded to the master.
- // NOTE: Either both the fields must be set or both must be unset.
- optional TaskState status_update_state = 9;
- optional bytes status_update_uuid = 10;
-
- optional Labels labels = 11;
-
- // Service discovery information for the task. It is not interpreted
- // or acted upon by Mesos. It is up to a service discovery system
- // to use this information as needed and to handle tasks without
- // service discovery information.
- optional DiscoveryInfo discovery = 12;
-
- // Container information for the task.
- optional ContainerInfo container = 13;
-}
-
-
// TODO(vinod): Create a new UUID message type.
/**
* Describes a task's status.