| 1851 | |
| 1852 | |
| 1853 | Option<Error> validateTaskGroupAndExecutorResources( |
| 1854 | const TaskGroupInfo& taskGroup, |
| 1855 | const ExecutorInfo& executor) |
| 1856 | { |
| 1857 | Resources total = executor.resources(); |
| 1858 | |
| 1859 | vector<Resources> taskResources; |
| 1860 | foreach (const TaskInfo& task, taskGroup.tasks()) { |
| 1861 | taskResources.push_back(task.resources()); |
| 1862 | total += task.resources(); |
| 1863 | } |
| 1864 | |
| 1865 | Option<Error> error = resource::validateUniquePersistenceID(total); |
| 1866 | if (error.isSome()) { |
| 1867 | return Error("Task group and executor use duplicate persistence ID: " + |
| 1868 | error->message); |
| 1869 | } |
| 1870 | |
| 1871 | error = resource::validateRevocableAndNonRevocableResources(total); |
| 1872 | if (error.isSome()) { |
| 1873 | return Error("Task group and executor mix revocable and non-revocable" |
| 1874 | " resources: " + error->message); |
| 1875 | } |
| 1876 | |
| 1877 | vector<Resources> allResources(taskResources); |
| 1878 | allResources.push_back(executor.resources()); |
| 1879 | |
| 1880 | if (resource::detectOverlappingSetAndRangeResources(allResources)) { |
| 1881 | return Error("There are overlapping resources in the task group's task" |
| 1882 | " resources " + stringify(taskResources) + |
| 1883 | " and/or executor resources " + |
| 1884 | stringify(executor.resources())); |
| 1885 | } |
| 1886 | |
| 1887 | return None(); |
| 1888 | } |
| 1889 | |
| 1890 | |
| 1891 | Option<Error> validateExecutor( |