| 112 | } |
| 113 | |
| 114 | Result<Resources> masterLaunchTaskResourceDecorator( |
| 115 | const TaskInfo& taskInfo, |
| 116 | const Resources& slaveResources) override |
| 117 | { |
| 118 | LOG(INFO) << "Executing 'masterLaunchTaskResourceDecorator' hook"; |
| 119 | |
| 120 | // If slave does not declare network bandwidth resource, |
| 121 | // don't set a default value for it. |
| 122 | if (slaveResources.names().count("network_bandwidth") == 0) { |
| 123 | return taskInfo.resources(); |
| 124 | } |
| 125 | |
| 126 | Resources taskResources = taskInfo.resources(); |
| 127 | |
| 128 | // Add a default value for network bandwidth if absent. |
| 129 | if (taskResources.names().count("network_bandwidth") == 0) { |
| 130 | Resources bandwidth = |
| 131 | CHECK_NOTERROR(Resources::parse("network_bandwidth:10")); |
| 132 | |
| 133 | CHECK(!taskResources.allocations().empty()); |
| 134 | bandwidth.allocate(taskResources.allocations().begin()->first); |
| 135 | |
| 136 | taskResources += bandwidth; |
| 137 | } |
| 138 | |
| 139 | return taskResources; |
| 140 | } |
| 141 | |
| 142 | Try<Nothing> masterSlaveLostHook(const SlaveInfo& slaveInfo) override |
| 143 | { |