private void assignTasksToContainers(int[] taskCountPerContainer, List<String> taskNamesToAssign, List<TaskGroup> containers) {
    for (TaskGroup taskGroup : containers) {
      for (int j = taskGroup.size(); j < taskCountPerContainer[Integer.valueOf(taskGroup.getContainerId())]; j++) {
        String taskName = taskNamesToAssign.remove(0);
        taskGroup.addTaskName(taskName);
        LOG.info("Assigned task {} to container {}", taskName, taskGroup.getContainerId());
      }
    }
  }
Assigns tasks from the specified list to containers that have fewer containers than indicated
in taskCountPerContainer.

@param taskCountPerContainer the expected number of tasks for each container.
@param taskNamesToAssign     the list of tasks to assign to the containers.
@param containers            the containers (as {@link TaskGroup}) to which the tasks will be assigned.
samza-core/src/main/java/org/apache/samza/container/grouper/task/GroupByContainerCount.java