TaskNameGrouperProxy { Set<ContainerModel> generateStandbyTasks(Set<ContainerModel> containerModels, int replicationFactor) { LOG.info("Received current containerModel map : {}, replicationFactor : {}", containerModels, replicationFactor); Set<ContainerModel> buddyContainers = new HashSet<>(); for (ContainerModel activeContainer : containerModels) { for (int replicaNum = 0; replicaNum < replicationFactor - 1; replicaNum++) { String buddyContainerId = StandbyTaskUtil.getStandbyContainerId(activeContainer.getId(), replicaNum); ContainerModel buddyContainerModel = new ContainerModel(buddyContainerId, getTaskModelForBuddyContainer(activeContainer.getTasks(), replicaNum)); buddyContainers.add(buddyContainerModel); } } LOG.info("Adding buddy containers : {}", buddyContainers); buddyContainers.addAll(containerModels); return buddyContainers; } TaskNameGrouperProxy(TaskNameGrouper taskNameGrouper, boolean standbyTasksEnabled,
      int replicationFactor); Set<ContainerModel> group(Set<TaskModel> taskModels, GrouperMetadata grouperMetadata); Set<ContainerModel> group(Set<TaskModel> taskModels, List<String> containersIds);  }
@Test public void testBuddyContainerBasedGenerationIdentity() { this.standbyTaskGenerator = new TaskNameGrouperProxy(Mockito.mock(TaskNameGrouper.class), true, 2); Assert.assertEquals("Shouldnt add standby tasks to empty container map", Collections.emptySet(), this.standbyTaskGenerator.generateStandbyTasks(Collections.emptySet(), 1)); Assert.assertEquals("Shouldnt add standby tasks when repl factor = 1", getContainerMap(), this.standbyTaskGenerator.generateStandbyTasks(getContainerMap(), 1)); }