| 696 | } |
| 697 | |
| 698 | void update(const TaskStatus& status) |
| 699 | { |
| 700 | CHECK_EQ(SUBSCRIBED, state); |
| 701 | |
| 702 | cout << "Received status update " << status.state() |
| 703 | << " for task '" << status.task_id() << "'" << endl; |
| 704 | |
| 705 | if (status.has_message()) { |
| 706 | cout << " message: '" << status.message() << "'" << endl; |
| 707 | } |
| 708 | if (status.has_source()) { |
| 709 | cout << " source: " << TaskStatus::Source_Name(status.source()) << endl; |
| 710 | } |
| 711 | if (status.has_reason()) { |
| 712 | cout << " reason: " << TaskStatus::Reason_Name(status.reason()) << endl; |
| 713 | } |
| 714 | if (status.has_healthy()) { |
| 715 | cout << " healthy?: " << status.healthy() << endl; |
| 716 | } |
| 717 | if (status.has_check_status()) { |
| 718 | cout << " check status: " << status.check_status() << endl; |
| 719 | } |
| 720 | if (status.has_limitation() && !status.limitation().resources().empty()) { |
| 721 | cout << " resource limit violation: " |
| 722 | << status.limitation().resources() << endl; |
| 723 | } |
| 724 | |
| 725 | if (status.has_uuid()) { |
| 726 | Call call; |
| 727 | call.set_type(Call::ACKNOWLEDGE); |
| 728 | |
| 729 | CHECK(frameworkInfo.has_id()); |
| 730 | call.mutable_framework_id()->CopyFrom(frameworkInfo.id()); |
| 731 | |
| 732 | Call::Acknowledge* acknowledge = call.mutable_acknowledge(); |
| 733 | acknowledge->mutable_agent_id()->CopyFrom(status.agent_id()); |
| 734 | acknowledge->mutable_task_id()->CopyFrom(status.task_id()); |
| 735 | acknowledge->set_uuid(status.uuid()); |
| 736 | |
| 737 | mesos->send(call); |
| 738 | } |
| 739 | |
| 740 | // If a task kill delay has been specified, schedule task kill. |
| 741 | if (killAfter.isSome() && TaskState::TASK_RUNNING == status.state()) { |
| 742 | delay(killAfter.get(), |
| 743 | self(), |
| 744 | &Self::killTask, |
| 745 | status.task_id(), |
| 746 | status.agent_id()); |
| 747 | } |
| 748 | |
| 749 | if (mesos::internal::protobuf::isTerminalState(devolve(status).state())) { |
| 750 | CHECK_NE(task.isSome(), taskGroup.isSome()) |
| 751 | << "Either task or task group should be set but not both"; |
| 752 | |
| 753 | if (task.isSome()) { |
| 754 | terminate(self()); |
| 755 | } else { |