| 316 | |
| 317 | |
| 318 | Future<Nothing> TaskStatusUpdateManagerProcess::_update( |
| 319 | const StatusUpdate& update, |
| 320 | const SlaveID& slaveId, |
| 321 | bool checkpoint, |
| 322 | const Option<ExecutorID>& executorId, |
| 323 | const Option<ContainerID>& containerId) |
| 324 | { |
| 325 | const TaskID& taskId = update.status().task_id(); |
| 326 | const FrameworkID& frameworkId = update.framework_id(); |
| 327 | |
| 328 | LOG(INFO) << "Received task status update " << update; |
| 329 | |
| 330 | // Write the status update to disk and enqueue it to send it to the master. |
| 331 | // Create/Get the status update stream for this task. |
| 332 | TaskStatusUpdateStream* stream = getStatusUpdateStream(taskId, frameworkId); |
| 333 | if (stream == nullptr) { |
| 334 | stream = createStatusUpdateStream( |
| 335 | taskId, frameworkId, slaveId, checkpoint, executorId, containerId); |
| 336 | } |
| 337 | |
| 338 | // Verify that we didn't get a non-checkpointable update for a |
| 339 | // stream that is checkpointable, and vice-versa. |
| 340 | if (stream->checkpoint != checkpoint) { |
| 341 | return Failure( |
| 342 | "Mismatched checkpoint value for task status update " + |
| 343 | stringify(update) + " (expected checkpoint=" + |
| 344 | stringify(stream->checkpoint) + " actual checkpoint=" + |
| 345 | stringify(checkpoint) + ")"); |
| 346 | } |
| 347 | |
| 348 | // Handle the status update. |
| 349 | Try<bool> result = stream->update(update); |
| 350 | if (result.isError()) { |
| 351 | return Failure(result.error()); |
| 352 | } |
| 353 | |
| 354 | // We don't return a failed future here so that the slave can re-ack |
| 355 | // the duplicate update. |
| 356 | if (!result.get()) { |
| 357 | return Nothing(); |
| 358 | } |
| 359 | |
| 360 | // Forward the status update to the master if this is the first in the stream. |
| 361 | // Subsequent status updates will get sent in 'acknowledgement()'. |
| 362 | if (!paused && stream->pending.size() == 1) { |
| 363 | CHECK_NONE(stream->timeout); |
| 364 | const Result<StatusUpdate>& next = stream->next(); |
| 365 | if (next.isError()) { |
| 366 | return Failure(next.error()); |
| 367 | } |
| 368 | |
| 369 | CHECK_SOME(next); |
| 370 | stream->timeout = forward(next.get(), STATUS_UPDATE_RETRY_INTERVAL_MIN); |
| 371 | } |
| 372 | |
| 373 | return Nothing(); |
| 374 | } |
| 375 | |