MCPcopy Create free account
hub / github.com/apache/mesos / injectAllocationInfo

Function injectAllocationInfo

src/common/protobuf_utils.cpp:704–839  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

702
703
704void injectAllocationInfo(
705 Offer::Operation* operation,
706 const Resource::AllocationInfo& allocationInfo)
707{
708 struct Injector
709 {
710 void operator()(
711 Resource& resource, const Resource::AllocationInfo& allocationInfo)
712 {
713 if (!resource.has_allocation_info()) {
714 resource.mutable_allocation_info()->CopyFrom(allocationInfo);
715 }
716 }
717
718 void operator()(
719 RepeatedPtrField<Resource>* resources,
720 const Resource::AllocationInfo& allocationInfo)
721 {
722 foreach (Resource& resource, *resources) {
723 operator()(resource, allocationInfo);
724 }
725 }
726 } inject;
727
728 switch (operation->type()) {
729 case Offer::Operation::LAUNCH: {
730 Offer::Operation::Launch* launch = operation->mutable_launch();
731
732 foreach (TaskInfo& task, *launch->mutable_task_infos()) {
733 inject(task.mutable_resources(), allocationInfo);
734
735 if (task.has_executor()) {
736 inject(
737 task.mutable_executor()->mutable_resources(),
738 allocationInfo);
739 }
740 }
741 break;
742 }
743
744 case Offer::Operation::LAUNCH_GROUP: {
745 Offer::Operation::LaunchGroup* launchGroup =
746 operation->mutable_launch_group();
747
748 if (launchGroup->has_executor()) {
749 inject(
750 launchGroup->mutable_executor()->mutable_resources(),
751 allocationInfo);
752 }
753
754 TaskGroupInfo* taskGroup = launchGroup->mutable_task_group();
755
756 foreach (TaskInfo& task, *taskGroup->mutable_tasks()) {
757 inject(task.mutable_resources(), allocationInfo);
758
759 if (task.has_executor()) {
760 inject(
761 task.mutable_executor()->mutable_resources(),

Callers 6

TEST_PFunction · 0.85
TESTFunction · 0.85
runMethod · 0.85
recoverMethod · 0.85
acceptMethod · 0.85
__reregisterSlaveMethod · 0.85

Calls 2

typeMethod · 0.80
foreachFunction · 0.70

Tested by 2

TEST_PFunction · 0.68
TESTFunction · 0.68