/** * Reads the task-container mapping from the provided {@link GrouperMetadata} and returns a * list of TaskGroups, ordered ascending by containerId. * * @param grouperMetadata the {@link GrouperMetadata} will be used to retrieve the previous task to container assignments. * @param taskCount the number of tasks, for validation against the persisted tasks. * @return a list of TaskGroups, ordered ascending by containerId or {@code null} * if the previous mapping doesn't exist or isn't usable. */ private List<TaskGroup> getPreviousContainers(GrouperMetadata grouperMetadata, int taskCount) { Map<TaskName, String> taskToContainerId = grouperMetadata.getPreviousTaskToProcessorAssignment(); if (taskToContainerId.isEmpty()) { LOG.info("No task assignment map was saved."); return null; } else if (taskCount != taskToContainerId.size()) { return null; } List<TaskGroup> containers; try { containers = getOrderedContainers(taskToContainerId); } catch (Exception e) { LOG.error("Exception while parsing task mapping", e); return null; } return containers; }
public Set<ContainerModel> group(Set<TaskModel> taskModels, GrouperMetadata grouperMetadata) { Map<TaskName, LocationId> taskLocality = grouperMetadata.getTaskLocality(); Preconditions.checkArgument(!taskModels.isEmpty(), "No tasks found. Likely due to no input partitions. Can't run a job with no tasks."); if (MapUtils.isEmpty(grouperMetadata.getProcessorLocality())) { LOG.info("ProcessorLocality is empty. Generating with the default group method."); return group(taskModels, new ArrayList<>()); Map<String, LocationId> processorLocality = new TreeMap<>(grouperMetadata.getProcessorLocality());