/** * Returns a list of all the resources associated with a task, including {@link Executor} resources. * * @param taskInfo The {@link Protos.TaskInfo} containing the {@link Protos.Resource}. * @return a list of {@link Protos.Resource}s. */ public static List<Protos.Resource> getAllResources(Protos.TaskInfo taskInfo) { // Get all resources from both the task level and the executor level List<Protos.Resource> resources = new ArrayList<>(taskInfo.getResourcesList()); if (taskInfo.hasExecutor()) { resources.addAll(taskInfo.getExecutor().getResourcesList()); } return resources; }
/** * This method keeps the resources associated with tasks in the state store up to date, when a task which shares * their resource-set is launched. * * @param podInstance the parent pod associated with the task being launched * @param taskInfo the task being launched */ @VisibleForTesting void updateTaskResourcesWithinResourceSet(PodInstance podInstance, Protos.TaskInfo taskInfo) { Optional<TaskSpec> taskSpec = TaskUtils.getTaskSpec(podInstance, taskInfo.getName()); if (!taskSpec.isPresent()) { return; } // Update any other TaskInfos in this resource set to have the same resources: Collection<Protos.TaskInfo> taskInfosWithSameResourceSet = getOtherTasksInResourceSet(podInstance, taskSpec.get()); stateStore.storeTasks(updateTasksWithResources( taskInfosWithSameResourceSet, taskInfo.getResourcesList(), taskInfo.hasExecutor() ? Optional.of(taskInfo.getExecutor().getResourcesList()) : Optional.empty())); }
.setTaskId(taskInfo.getTaskId()) .setState(Protos.TaskState.TASK_STAGING); if (taskInfo.hasExecutor()) { taskStatusBuilder.setExecutorId(taskInfo.getExecutor().getExecutorId());
Assert.assertFalse(launchTask.hasExecutor()); Assert.assertEquals("pod-type-0-taskA", launchTask.getName()); Assert.assertFalse(launchTask.hasExecutor()); Assert.assertEquals("pod-type-0-taskB", launchTask.getName());