use of org.apache.samza.coordinator.JobModelManager in project samza by apache.
the class TestHostAwareContainerAllocator method getJobModelManager.
private static JobModelManager getJobModelManager(int containerCount) {
//Ideally, the JobModelReader should be constructed independent of HttpServer.
//That way it becomes easier to mock objects. Save it for later.
HttpServer server = new MockHttpServer("/", 7777, null, new ServletHolder(DefaultServlet.class));
Map<String, ContainerModel> containers = new java.util.HashMap<>();
for (int i = 0; i < containerCount; i++) {
ContainerModel container = new ContainerModel(String.valueOf(i), i, new HashMap<TaskName, TaskModel>());
containers.put(String.valueOf(i), container);
}
JobModel jobModel = new JobModel(getConfig(), containers);
return new JobModelManager(jobModel, server, null);
}
use of org.apache.samza.coordinator.JobModelManager in project samza by apache.
the class YarnResourceManagerFactory method getClusterResourceManager.
@Override
public ClusterResourceManager getClusterResourceManager(ClusterResourceManager.Callback callback, SamzaApplicationState state) {
log.info("Creating an instance of a cluster resource manager for Yarn. ");
JobModelManager jobModelManager = state.jobModelManager;
Config config = jobModelManager.jobModel().getConfig();
YarnClusterResourceManager manager = new YarnClusterResourceManager(config, jobModelManager, callback, state);
return manager;
}
use of org.apache.samza.coordinator.JobModelManager in project samza by apache.
the class TestContainerAllocator method getJobModelReader.
private static JobModelManager getJobModelReader(int containerCount) {
//Ideally, the JobModelReader should be constructed independent of HttpServer.
//That way it becomes easier to mock objects. Save it for later.
HttpServer server = new MockHttpServer("/", 7777, null, new ServletHolder(DefaultServlet.class));
Map<String, ContainerModel> containers = new java.util.HashMap<>();
for (int i = 0; i < containerCount; i++) {
ContainerModel container = new ContainerModel(String.valueOf(i), i, new HashMap<TaskName, TaskModel>());
containers.put(String.valueOf(i), container);
}
JobModel jobModel = new JobModel(getConfig(), containers);
return new JobModelManager(jobModel, server, null);
}
use of org.apache.samza.coordinator.JobModelManager in project samza by apache.
the class TestContainerProcessManager method getCoordinator.
private JobModelManager getCoordinator(int containerCount) {
Map<String, ContainerModel> containers = new java.util.HashMap<>();
for (int i = 0; i < containerCount; i++) {
ContainerModel container = new ContainerModel(String.valueOf(i), i, new HashMap<TaskName, TaskModel>());
containers.put(String.valueOf(i), container);
}
Map<String, Map<String, String>> localityMap = new HashMap<>();
localityMap.put("0", new HashMap<String, String>() {
{
put(SetContainerHostMapping.HOST_KEY, "abc");
}
});
LocalityManager mockLocalityManager = mock(LocalityManager.class);
when(mockLocalityManager.readContainerLocality()).thenReturn(localityMap);
JobModel jobModel = new JobModel(getConfig(), containers, mockLocalityManager);
JobModelManager.jobModelRef().getAndSet(jobModel);
return new JobModelManager(jobModel, this.server, null);
}
use of org.apache.samza.coordinator.JobModelManager in project samza by apache.
the class StorageRecovery method getContainerModels.
/**
* Build ContainerModels from job config file and put the results in the containerModels map.
*/
private void getContainerModels() {
MetricsRegistryMap metricsRegistryMap = new MetricsRegistryMap();
CoordinatorStreamStore coordinatorStreamStore = new CoordinatorStreamStore(jobConfig, metricsRegistryMap);
coordinatorStreamStore.init();
try {
Config configFromCoordinatorStream = CoordinatorStreamUtil.readConfigFromCoordinatorStream(coordinatorStreamStore);
ChangelogStreamManager changelogStreamManager = new ChangelogStreamManager(coordinatorStreamStore);
JobModelManager jobModelManager = JobModelManager.apply(configFromCoordinatorStream, changelogStreamManager.readPartitionMapping(), coordinatorStreamStore, metricsRegistryMap);
JobModel jobModel = jobModelManager.jobModel();
this.jobModel = jobModel;
containers = jobModel.getContainers();
} finally {
coordinatorStreamStore.close();
}
}
Aggregations