Use this helper to create a status update from scratch, i.e., without previously attached extra information like `data` or `check_status`.
| 1124 | // Use this helper to create a status update from scratch, i.e., without |
| 1125 | // previously attached extra information like `data` or `check_status`. |
| 1126 | TaskStatus createTaskStatus( |
| 1127 | const TaskID& _taskId, |
| 1128 | const TaskState& state, |
| 1129 | const Option<TaskStatus::Reason>& reason = None(), |
| 1130 | const Option<string>& message = None()) |
| 1131 | { |
| 1132 | TaskStatus status = protobuf::createTaskStatus( |
| 1133 | _taskId, |
| 1134 | state, |
| 1135 | id::UUID::random(), |
| 1136 | Clock::now().secs()); |
| 1137 | |
| 1138 | status.mutable_executor_id()->CopyFrom(executorId); |
| 1139 | status.set_source(TaskStatus::SOURCE_EXECUTOR); |
| 1140 | |
| 1141 | if (reason.isSome()) { |
| 1142 | status.set_reason(reason.get()); |
| 1143 | } |
| 1144 | |
| 1145 | if (message.isSome()) { |
| 1146 | status.set_message(message.get()); |
| 1147 | } |
| 1148 | |
| 1149 | // TODO(alexr): Augment health information in a way similar to |
| 1150 | // `CheckStatusInfo`. See MESOS-6417 for more details. |
| 1151 | |
| 1152 | // If a check for the task has been defined, `check_status` field in each |
| 1153 | // task status must be set to a valid `CheckStatusInfo` message even if |
| 1154 | // there is no check status available yet. |
| 1155 | if (taskData->taskInfo.has_check()) { |
| 1156 | CheckStatusInfo checkStatusInfo; |
| 1157 | checkStatusInfo.set_type(taskData->taskInfo.check().type()); |
| 1158 | switch (taskData->taskInfo.check().type()) { |
| 1159 | case CheckInfo::COMMAND: { |
| 1160 | checkStatusInfo.mutable_command(); |
| 1161 | break; |
| 1162 | } |
| 1163 | case CheckInfo::HTTP: { |
| 1164 | checkStatusInfo.mutable_http(); |
| 1165 | break; |
| 1166 | } |
| 1167 | case CheckInfo::TCP: { |
| 1168 | checkStatusInfo.mutable_tcp(); |
| 1169 | break; |
| 1170 | } |
| 1171 | case CheckInfo::UNKNOWN: { |
| 1172 | LOG(FATAL) << "UNKNOWN check type is invalid"; |
| 1173 | break; |
| 1174 | } |
| 1175 | } |
| 1176 | |
| 1177 | status.mutable_check_status()->CopyFrom(checkStatusInfo); |
| 1178 | } |
| 1179 | |
| 1180 | return status; |
| 1181 | } |
| 1182 | |
| 1183 | void forward(const TaskStatus& status) |