You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by al...@apache.org on 2017/03/15 21:21:07 UTC
[06/13] mesos git commit: Added a helper for building a task status
from an existing one.
Added a helper for building a task status from an existing one.
Review: https://reviews.apache.org/r/56017
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/85fbf8fc
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/85fbf8fc
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/85fbf8fc
Branch: refs/heads/master
Commit: 85fbf8fc6465d46b40696f4f1e72822765e8fc1e
Parents: cc6e063
Author: Alexander Rukletsov <al...@apache.org>
Authored: Fri Jan 20 19:26:45 2017 +0100
Committer: Alexander Rukletsov <al...@apache.org>
Committed: Wed Mar 15 22:20:20 2017 +0100
----------------------------------------------------------------------
src/common/protobuf_utils.cpp | 62 ++++++++++++++++++++++++++++++++++++++
src/common/protobuf_utils.hpp | 27 +++++++++++++++++
2 files changed, 89 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/85fbf8fc/src/common/protobuf_utils.cpp
----------------------------------------------------------------------
diff --git a/src/common/protobuf_utils.cpp b/src/common/protobuf_utils.cpp
index 34c14e8..d568d41 100644
--- a/src/common/protobuf_utils.cpp
+++ b/src/common/protobuf_utils.cpp
@@ -206,6 +206,68 @@ StatusUpdate createStatusUpdate(
}
+TaskStatus createTaskStatus(
+ TaskStatus status,
+ const UUID& uuid,
+ double timestamp,
+ const Option<TaskState>& state,
+ const Option<string>& message,
+ const Option<TaskStatus::Source>& source,
+ const Option<TaskStatus::Reason>& reason,
+ const Option<string>& data,
+ const Option<bool>& healthy,
+ const Option<CheckStatusInfo>& checkStatus,
+ const Option<Labels>& labels,
+ const Option<ContainerStatus>& containerStatus,
+ const Option<TimeInfo>& unreachableTime)
+{
+ status.set_uuid(uuid.toBytes());
+ status.set_timestamp(timestamp);
+
+ if (state.isSome()) {
+ status.set_state(state.get());
+ }
+
+ if (message.isSome()) {
+ status.set_message(message.get());
+ }
+
+ if (source.isSome()) {
+ status.set_source(source.get());
+ }
+
+ if (reason.isSome()) {
+ status.set_reason(reason.get());
+ }
+
+ if (data.isSome()) {
+ status.set_data(data.get());
+ }
+
+ if (healthy.isSome()) {
+ status.set_healthy(healthy.get());
+ }
+
+ if (checkStatus.isSome()) {
+ status.mutable_check_status()->CopyFrom(checkStatus.get());
+ }
+
+ if (labels.isSome()) {
+ status.mutable_labels()->CopyFrom(labels.get());
+ }
+
+ if (containerStatus.isSome()) {
+ status.mutable_container_status()->CopyFrom(containerStatus.get());
+ }
+
+ if (unreachableTime.isSome()) {
+ status.mutable_unreachable_time()->CopyFrom(unreachableTime.get());
+ }
+
+ return status;
+}
+
+
Task createTask(
const TaskInfo& task,
const TaskState& state,
http://git-wip-us.apache.org/repos/asf/mesos/blob/85fbf8fc/src/common/protobuf_utils.hpp
----------------------------------------------------------------------
diff --git a/src/common/protobuf_utils.hpp b/src/common/protobuf_utils.hpp
index 09e468c..3b157a0 100644
--- a/src/common/protobuf_utils.hpp
+++ b/src/common/protobuf_utils.hpp
@@ -93,6 +93,33 @@ StatusUpdate createStatusUpdate(
const Option<SlaveID>& slaveId);
+// Helper function that creates a new task status from the given task
+// status. Specific fields in `status` can be overridden in the new
+// status by specifying the appropriate argument. Fields `task_id`,
+// `slave_id`, `executor_id`, cannot be changed; while `timestamp`
+// and `uuid` cannot be preserved.
+//
+// NOTE: A task status update may be used for guaranteed delivery of
+// some task-related information, e.g., task's health update. In this
+// case, it is often desirable to preserve specific fields from the
+// previous status update to avoid shadowing information that was
+// delivered previously.
+TaskStatus createTaskStatus(
+ TaskStatus status,
+ const UUID& uuid,
+ double timestamp,
+ const Option<TaskState>& state = None(),
+ const Option<std::string>& message = None(),
+ const Option<TaskStatus::Source>& source = None(),
+ const Option<TaskStatus::Reason>& reason = None(),
+ const Option<std::string>& data = None(),
+ const Option<bool>& healthy = None(),
+ const Option<CheckStatusInfo>& checkStatus = None(),
+ const Option<Labels>& labels = None(),
+ const Option<ContainerStatus>& containerStatus = None(),
+ const Option<TimeInfo>& unreachableTime = None());
+
+
Task createTask(
const TaskInfo& task,
const TaskState& state,