use of org.apache.samza.job.model.ContainerModel in project samza by apache.
the class TestJobModelHelper method testAddBroadcastInput.
@Test
public void testAddBroadcastInput() {
Map<String, ContainerModel> oldContainerModels = ImmutableMap.of("0", new ContainerModel("0", ImmutableMap.of(taskName(0), taskModel(0, 0))), "1", new ContainerModel("1", ImmutableMap.of(taskName(1), taskModel(1, 1))));
setupOldTaskAssignments(oldContainerModels);
TaskModel taskModel0 = taskModel(0, ImmutableSet.of(new SystemStreamPartition(SYSTEM_STREAM0, new Partition(0)), new SystemStreamPartition(SYSTEM_STREAM1, new Partition(0))));
TaskModel taskModel1 = taskModel(1, ImmutableSet.of(new SystemStreamPartition(SYSTEM_STREAM0, new Partition(1)), new SystemStreamPartition(SYSTEM_STREAM1, new Partition(0))));
Map<String, ContainerModel> containerModels = ImmutableMap.of("0", new ContainerModel("0", ImmutableMap.of(taskName(0), taskModel0)), "1", new ContainerModel("1", ImmutableMap.of(taskName(1), taskModel1)));
runAndCheckNewJobModel(config(), containerModels);
verifyGrouperMetadata(anyHostProcessorIdToLocationId(), anyHostTaskNameToLocationId(2), activeTaskToSSPs(oldContainerModels), activeTaskToContainer(oldContainerModels));
verifyNewTaskAssignments(null, null, containerToTaskToMode(containerModels), sspToTasks(containerModels));
}
use of org.apache.samza.job.model.ContainerModel in project samza by apache.
the class TestJobModelHelper method testExistingBroadcastInput.
@Test
public void testExistingBroadcastInput() {
TaskModel taskModel0 = taskModel(0, ImmutableSet.of(new SystemStreamPartition(SYSTEM_STREAM0, new Partition(0)), new SystemStreamPartition(SYSTEM_STREAM1, new Partition(0))));
TaskModel taskModel1 = taskModel(1, ImmutableSet.of(new SystemStreamPartition(SYSTEM_STREAM0, new Partition(1)), new SystemStreamPartition(SYSTEM_STREAM1, new Partition(0))));
Map<String, ContainerModel> containerModels = ImmutableMap.of("0", new ContainerModel("0", ImmutableMap.of(taskName(0), taskModel0)), "1", new ContainerModel("1", ImmutableMap.of(taskName(1), taskModel1)));
setupOldTaskAssignments(containerModels);
runAndCheckNewJobModel(config(), containerModels);
verifyGrouperMetadata(anyHostProcessorIdToLocationId(), anyHostTaskNameToLocationId(2), activeTaskToSSPs(containerModels), activeTaskToContainer(containerModels));
verifyNewTaskAssignments(null, null, containerToTaskToMode(containerModels), sspToTasks(containerModels));
}
use of org.apache.samza.job.model.ContainerModel in project samza by apache.
the class TestJobModelHelper method testSameJobModelAsPrevious.
@Test
public void testSameJobModelAsPrevious() {
Map<String, ContainerModel> containerModels = ImmutableMap.of("0", new ContainerModel("0", ImmutableMap.of(taskName(0), taskModel(0, 0, 0), taskName(2), taskModel(2, 2, 2))), "1", new ContainerModel("1", ImmutableMap.of(taskName(1), taskModel(1, 1, 1), taskName(3), taskModel(3, 3))));
setupOldTaskAssignments(containerModels);
runAndCheckNewJobModel(config(), containerModels);
verifyGrouperMetadata(anyHostProcessorIdToLocationId(), anyHostTaskNameToLocationId(4), activeTaskToSSPs(containerModels), activeTaskToContainer(containerModels));
verifyNewTaskAssignments(null, null, containerToTaskToMode(containerModels), sspToTasks(containerModels));
}
use of org.apache.samza.job.model.ContainerModel in project samza by apache.
the class TestJobModelHelper method testNewStandbyTasks.
@Test
public void testNewStandbyTasks() {
Map<String, ContainerModel> oldContainerModels = ImmutableMap.of("0", new ContainerModel("0", ImmutableMap.of(taskName(0), taskModel(0, 0))), "1", new ContainerModel("1", ImmutableMap.of(taskName(1), taskModel(1, 1))), "0-0", new ContainerModel("0-0", ImmutableMap.of(standbyTaskName(0, 0), standbyTaskModel(0, 0))), "1-0", new ContainerModel("1-0", ImmutableMap.of(standbyTaskName(1, 0), standbyTaskModel(1, 0))));
setupOldTaskAssignments(oldContainerModels);
Map<String, ContainerModel> containerModels = new ImmutableMap.Builder<String, ContainerModel>().put("0", new ContainerModel("0", ImmutableMap.of(taskName(0), taskModel(0, 0)))).put("1", new ContainerModel("1", ImmutableMap.of(taskName(1), taskModel(1, 1)))).put("2", new ContainerModel("2", ImmutableMap.of(taskName(2), taskModel(2, 2)))).put("0-0", new ContainerModel("0-0", ImmutableMap.of(standbyTaskName(0, 0), standbyTaskModel(0, 0)))).put("1-0", new ContainerModel("1-0", ImmutableMap.of(standbyTaskName(1, 0), standbyTaskModel(1, 0)))).put("2-0", new ContainerModel("2-0", ImmutableMap.of(standbyTaskName(2, 0), standbyTaskModel(2, 0)))).build();
runAndCheckNewJobModel(config(), containerModels);
verifyGrouperMetadata(anyHostProcessorIdToLocationId(), anyHostTaskNameToLocationId(2), activeTaskToSSPs(oldContainerModels), activeTaskToContainer(oldContainerModels));
// noinspection unchecked: ArgumentCaptor doesn't ideally handle multiple levels of generics, so need cast
ArgumentCaptor<Iterable<String>> deleteTaskContainerMappingsCaptor = (ArgumentCaptor<Iterable<String>>) (ArgumentCaptor<?>) ArgumentCaptor.forClass(Iterable.class);
verify(this.taskAssignmentManager, times(2)).deleteTaskContainerMappings(deleteTaskContainerMappingsCaptor.capture());
assertEquals(taskNameStrings(oldContainerModels, TaskMode.Active), ImmutableSet.copyOf(deleteTaskContainerMappingsCaptor.getAllValues().get(0)));
assertEquals(taskNameStrings(oldContainerModels, TaskMode.Standby), ImmutableSet.copyOf(deleteTaskContainerMappingsCaptor.getAllValues().get(1)));
verify(this.taskPartitionAssignmentManager).delete(allSSPs(containerModels));
verify(this.taskPartitionAssignmentManager).delete(any());
verify(this.taskAssignmentManager).writeTaskContainerMappings(containerToTaskToMode(containerModels));
verify(this.taskAssignmentManager).writeTaskContainerMappings(any());
verify(this.taskPartitionAssignmentManager).writeTaskPartitionAssignments(sspToTasks(containerModels));
verify(this.taskPartitionAssignmentManager).writeTaskPartitionAssignments(any());
}
use of org.apache.samza.job.model.ContainerModel in project samza by apache.
the class TestApplicationMasterRestClient method generateContainers.
private HashMap<String, ContainerModel> generateContainers() {
Set<TaskModel> taskModels = ImmutableSet.of(new TaskModel(new TaskName("task1"), ImmutableSet.of(new SystemStreamPartition(new SystemStream("system1", "stream1"), new Partition(0))), new Partition(0)), new TaskModel(new TaskName("task2"), ImmutableSet.of(new SystemStreamPartition(new SystemStream("system1", "stream1"), new Partition(1))), new Partition(1)));
GroupByContainerCount grouper = new GroupByContainerCount(2);
Set<ContainerModel> containerModels = grouper.group(taskModels);
HashMap<String, ContainerModel> containers = new HashMap<>();
for (ContainerModel containerModel : containerModels) {
containers.put(containerModel.getId(), containerModel);
}
return containers;
}
Aggregations