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;
  }
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.
samza-core/src/main/java/org/apache/samza/container/grouper/task/GroupByContainerCount.java