use of org.apache.samza.container.TaskName in project samza by apache.
the class TestJobModelServingContext method testSetGet.
@Test
public void testSetGet() throws IOException {
// return empty if no job model has been set
assertFalse(this.jobModelServingContext.getSerializedJobModel().isPresent());
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)))));
JobModel jobModel = new JobModel(config, containerModelMap);
this.jobModelServingContext.setJobModel(jobModel);
Optional<byte[]> serializedJobModel = this.jobModelServingContext.getSerializedJobModel();
assertTrue(serializedJobModel.isPresent());
assertEquals(jobModel, SamzaObjectMapper.getObjectMapper().readValue(serializedJobModel.get(), JobModel.class));
config = new MapConfig(ImmutableMap.of("samza.user.config0", "config-value0"));
containerModelMap = ImmutableMap.of("0", new ContainerModel("0", ImmutableMap.of(new TaskName("Partition 0"), new TaskModel(new TaskName("Partition 0"), ImmutableSet.of(new SystemStreamPartition("system0", "stream0", new Partition(0))), new Partition(0)))));
jobModel = new JobModel(config, containerModelMap);
this.jobModelServingContext.setJobModel(jobModel);
serializedJobModel = this.jobModelServingContext.getSerializedJobModel();
assertTrue(serializedJobModel.isPresent());
assertEquals(jobModel, SamzaObjectMapper.getObjectMapper().readValue(serializedJobModel.get(), JobModel.class));
}
use of org.apache.samza.container.TaskName in project samza by apache.
the class TestJobModelHelper method standbyTaskModel.
private static TaskModel standbyTaskModel(int taskId, int standbyId) {
TaskName taskName = new TaskName(String.format("Standby-Partition %s-%s", taskId, standbyId));
Set<SystemStreamPartition> ssps = ImmutableSet.of(new SystemStreamPartition(SYSTEM_STREAM0, new Partition(taskId)));
return new TaskModel(taskName, ssps, new Partition(taskId), TaskMode.Standby);
}
use of org.apache.samza.container.TaskName 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.container.TaskName 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.container.TaskName 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);
}
Aggregations