use of org.apache.samza.job.model.ContainerModel in project samza by apache.
the class TestJobModelHelper method testNewContainerWithProcessorLocality.
@Test
public void testNewContainerWithProcessorLocality() {
Map<String, ContainerModel> oldContainerModels = ImmutableMap.of("0", new ContainerModel("0", ImmutableMap.of(taskName(0), taskModel(0, 0, 0))));
Map<String, ProcessorLocality> processorLocalities = ImmutableMap.of("0", processorLocality("0", HOST0));
when(this.localityModel.getProcessorLocalities()).thenReturn(processorLocalities);
setupOldTaskAssignments(oldContainerModels);
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))));
runAndCheckNewJobModel(config(), containerModels);
verifyGrouperMetadata(processorIdToLocationId(ImmutableMap.of("0", HOST0)), ImmutableMap.of(taskName(0), new LocationId(HOST0)), activeTaskToSSPs(oldContainerModels), activeTaskToContainer(oldContainerModels));
verifyNewTaskAssignments(taskNameStrings(oldContainerModels, TaskMode.Active), allSSPs(containerModels), containerToTaskToMode(containerModels), sspToTasks(containerModels));
}
use of org.apache.samza.job.model.ContainerModel in project samza by apache.
the class TestJobModelHttpServlet method jobModel.
private static JobModel jobModel() {
Config config = new MapConfig(ImmutableMap.of("samza.user.config", "config-value"));
Map<String, ContainerModel> containerModelMap = ImmutableMap.of("0", new ContainerModel("0", ImmutableMap.of(new TaskName("Partition 0"), new TaskModel(new TaskName("Partition 0"), ImmutableSet.of(new SystemStreamPartition("system", "stream", new Partition(0))), new Partition(0)))));
return new JobModel(config, containerModelMap);
}
use of org.apache.samza.job.model.ContainerModel in project samza by apache.
the class TestJobCoordinatorMetadataManager method setup.
@Before
public void setup() {
Map<TaskName, TaskModel> tasksForContainer1 = ImmutableMap.of(new TaskName("t1"), new TaskModel(new TaskName("t1"), ImmutableSet.of(), new Partition(0)), new TaskName("t2"), new TaskModel(new TaskName("t2"), ImmutableSet.of(), new Partition(1)));
Map<TaskName, TaskModel> tasksForContainer2 = ImmutableMap.of(new TaskName("t3"), new TaskModel(new TaskName("t3"), ImmutableSet.of(), new Partition(2)), new TaskName("t4"), new TaskModel(new TaskName("t4"), ImmutableSet.of(), new Partition(3)), new TaskName("t5"), new TaskModel(new TaskName("t5"), ImmutableSet.of(), new Partition(4)));
ContainerModel containerModel1 = new ContainerModel("0", tasksForContainer1);
ContainerModel containerModel2 = new ContainerModel("1", tasksForContainer2);
containerModelMap = ImmutableMap.of("0", containerModel1, "1", containerModel2);
CoordinatorStreamStoreTestUtil mockCoordinatorStreamStore = new CoordinatorStreamStoreTestUtil(COORDINATOR_STORE_CONFIG);
metadataStore = spy(new NamespaceAwareCoordinatorStreamStore(mockCoordinatorStreamStore.getCoordinatorStreamStore(), SetJobCoordinatorMetadataMessage.TYPE));
jobCoordinatorMetadataManager = spy(new JobCoordinatorMetadataManager(metadataStore, ClusterType.YARN, new MetricsRegistryMap()));
}
use of org.apache.samza.job.model.ContainerModel in project samza by apache.
the class SingleContainerGrouper method group.
@Override
public Set<ContainerModel> group(Set<TaskModel> taskModels) {
Map<TaskName, TaskModel> taskNameTaskModelMap = new HashMap<>();
for (TaskModel taskModel : taskModels) {
taskNameTaskModelMap.put(taskModel.getTaskName(), taskModel);
}
ContainerModel containerModel = new ContainerModel(containerId, taskNameTaskModelMap);
return Collections.singleton(containerModel);
}
use of org.apache.samza.job.model.ContainerModel in project samza by apache.
the class TaskGroup method buildContainerModels.
/**
* Converts the {@link TaskGroup} list to a set of ContainerModel.
*
* @param taskModels the TaskModels to assign to the ContainerModels.
* @param taskGroups the TaskGroups defining how the tasks should be grouped.
* @return a set of ContainerModels.
*/
public static Set<ContainerModel> buildContainerModels(Set<TaskModel> taskModels, Collection<TaskGroup> taskGroups) {
// Map task names to models
Map<String, TaskModel> taskNameToModel = new HashMap<>();
for (TaskModel model : taskModels) {
taskNameToModel.put(model.getTaskName().getTaskName(), model);
}
// Build container models
Set<ContainerModel> containerModels = new HashSet<>();
for (TaskGroup container : taskGroups) {
Map<TaskName, TaskModel> containerTaskModels = new HashMap<>();
for (String taskName : container.taskNames) {
TaskModel model = taskNameToModel.get(taskName);
containerTaskModels.put(model.getTaskName(), model);
}
containerModels.add(new ContainerModel(container.containerId, containerTaskModels));
}
return Collections.unmodifiableSet(containerModels);
}
Aggregations