TaskAssignmentManager { public TaskAssignmentManager(MetadataStore taskContainerMappingMetadataStore, MetadataStore taskModeMappingMetadataStore) { Preconditions.checkNotNull(taskContainerMappingMetadataStore, "Metadata store cannot be null"); Preconditions.checkNotNull(taskModeMappingMetadataStore, "Metadata store cannot be null"); this.taskModeMappingMetadataStore = taskModeMappingMetadataStore; this.taskContainerMappingMetadataStore = taskContainerMappingMetadataStore; this.containerIdSerde = new CoordinatorStreamValueSerde(SetTaskContainerMapping.TYPE); this.taskModeSerde = new CoordinatorStreamValueSerde(SetTaskModeMapping.TYPE); } TaskAssignmentManager(MetadataStore taskContainerMappingMetadataStore, MetadataStore taskModeMappingMetadataStore); Map<String, String> readTaskAssignment(); Map<TaskName, TaskMode> readTaskModes(); void writeTaskContainerMappings(Map<String, Map<String, TaskMode>> mappings); void deleteTaskContainerMappings(Iterable<String> taskNames); void close();  }
@Test public void testTaskAssignmentManager() { Map<String, String> expectedMap = ImmutableMap.of("Task0", "0", "Task1", "1", "Task2", "2", "Task3", "0", "Task4", "1"); Map<String, Map<String, TaskMode>> taskContainerMappings = ImmutableMap.of( "0", ImmutableMap.of("Task0", TaskMode.Active, "Task3", TaskMode.Active), "1", ImmutableMap.of("Task1", TaskMode.Active, "Task4", TaskMode.Active), "2", ImmutableMap.of("Task2", TaskMode.Active) ); taskAssignmentManager.writeTaskContainerMappings(taskContainerMappings); Map<String, String> localMap = taskAssignmentManager.readTaskAssignment(); assertEquals(expectedMap, localMap); taskAssignmentManager.close(); }