| 394 | |
| 395 | |
| 396 | Future<bool> TaskStatusUpdateManagerProcess::acknowledgement( |
| 397 | const TaskID& taskId, |
| 398 | const FrameworkID& frameworkId, |
| 399 | const id::UUID& uuid) |
| 400 | { |
| 401 | LOG(INFO) << "Received task status update acknowledgement (UUID: " << uuid |
| 402 | << ") for task " << taskId |
| 403 | << " of framework " << frameworkId; |
| 404 | |
| 405 | TaskStatusUpdateStream* stream = getStatusUpdateStream(taskId, frameworkId); |
| 406 | |
| 407 | // This might happen if we haven't completed recovery yet or if the |
| 408 | // acknowledgement is for a stream that has been cleaned up. |
| 409 | if (stream == nullptr) { |
| 410 | return Failure( |
| 411 | "Cannot find the task status update stream for task " + |
| 412 | stringify(taskId) + " of framework " + stringify(frameworkId)); |
| 413 | } |
| 414 | |
| 415 | // Get the corresponding update for this ACK. |
| 416 | const Result<StatusUpdate>& update = stream->next(); |
| 417 | if (update.isError()) { |
| 418 | return Failure(update.error()); |
| 419 | } |
| 420 | |
| 421 | // This might happen if we retried a status update and got back |
| 422 | // acknowledgments for both the original and the retried update. |
| 423 | if (update.isNone()) { |
| 424 | return Failure( |
| 425 | "Unexpected task status update acknowledgment (UUID: " + |
| 426 | uuid.toString() + ") for task " + stringify(taskId) + " of framework " + |
| 427 | stringify(frameworkId)); |
| 428 | } |
| 429 | |
| 430 | // Handle the acknowledgement. |
| 431 | Try<bool> result = |
| 432 | stream->acknowledgement(taskId, frameworkId, uuid, update.get()); |
| 433 | |
| 434 | if (result.isError()) { |
| 435 | return Failure(result.error()); |
| 436 | } |
| 437 | |
| 438 | if (!result.get()) { |
| 439 | return Failure("Duplicate task status acknowledgement"); |
| 440 | } |
| 441 | |
| 442 | // Reset the timeout. |
| 443 | stream->timeout = None(); |
| 444 | |
| 445 | // Get the next update in the queue. |
| 446 | const Result<StatusUpdate>& next = stream->next(); |
| 447 | if (next.isError()) { |
| 448 | return Failure(next.error()); |
| 449 | } |
| 450 | |
| 451 | bool terminated = stream->terminated; |
| 452 | |
| 453 | if (terminated) { |