Search in sources :

Example 1 with JobModelManager

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);
}
Also used : HashMap(java.util.HashMap) ServletHolder(org.eclipse.jetty.servlet.ServletHolder) JobModelManager(org.apache.samza.coordinator.JobModelManager) ContainerModel(org.apache.samza.job.model.ContainerModel) TaskName(org.apache.samza.container.TaskName) HttpServer(org.apache.samza.coordinator.server.HttpServer) JobModel(org.apache.samza.job.model.JobModel) DefaultServlet(org.eclipse.jetty.servlet.DefaultServlet) TaskModel(org.apache.samza.job.model.TaskModel)

Example 2 with JobModelManager

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;
}
Also used : Config(org.apache.samza.config.Config) JobModelManager(org.apache.samza.coordinator.JobModelManager)

Example 3 with JobModelManager

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);
}
Also used : HashMap(java.util.HashMap) ServletHolder(org.eclipse.jetty.servlet.ServletHolder) JobModelManager(org.apache.samza.coordinator.JobModelManager) ContainerModel(org.apache.samza.job.model.ContainerModel) TaskName(org.apache.samza.container.TaskName) HttpServer(org.apache.samza.coordinator.server.HttpServer) JobModel(org.apache.samza.job.model.JobModel) DefaultServlet(org.eclipse.jetty.servlet.DefaultServlet) TaskModel(org.apache.samza.job.model.TaskModel)

Example 4 with JobModelManager

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);
}
Also used : HashMap(java.util.HashMap) JobModelManager(org.apache.samza.coordinator.JobModelManager) ContainerModel(org.apache.samza.job.model.ContainerModel) TaskName(org.apache.samza.container.TaskName) JobModel(org.apache.samza.job.model.JobModel) LocalityManager(org.apache.samza.container.LocalityManager) HashMap(java.util.HashMap) Map(java.util.Map) MetricsRegistryMap(org.apache.samza.metrics.MetricsRegistryMap) TaskModel(org.apache.samza.job.model.TaskModel)

Example 5 with JobModelManager

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();
    }
}
Also used : CoordinatorStreamStore(org.apache.samza.coordinator.metadatastore.CoordinatorStreamStore) SystemConfig(org.apache.samza.config.SystemConfig) StorageConfig(org.apache.samza.config.StorageConfig) SerializerConfig(org.apache.samza.config.SerializerConfig) TaskConfig(org.apache.samza.config.TaskConfig) Config(org.apache.samza.config.Config) JobModelManager(org.apache.samza.coordinator.JobModelManager) JobModel(org.apache.samza.job.model.JobModel) MetricsRegistryMap(org.apache.samza.metrics.MetricsRegistryMap)

Aggregations

JobModelManager (org.apache.samza.coordinator.JobModelManager)6 JobModel (org.apache.samza.job.model.JobModel)5 ContainerModel (org.apache.samza.job.model.ContainerModel)4 HashMap (java.util.HashMap)3 TaskName (org.apache.samza.container.TaskName)3 TaskModel (org.apache.samza.job.model.TaskModel)3 Config (org.apache.samza.config.Config)2 HttpServer (org.apache.samza.coordinator.server.HttpServer)2 MetricsRegistryMap (org.apache.samza.metrics.MetricsRegistryMap)2 DefaultServlet (org.eclipse.jetty.servlet.DefaultServlet)2 ServletHolder (org.eclipse.jetty.servlet.ServletHolder)2 Map (java.util.Map)1 SamzaApplicationState (org.apache.samza.clustermanager.SamzaApplicationState)1 SamzaResource (org.apache.samza.clustermanager.SamzaResource)1 SerializerConfig (org.apache.samza.config.SerializerConfig)1 StorageConfig (org.apache.samza.config.StorageConfig)1 SystemConfig (org.apache.samza.config.SystemConfig)1 TaskConfig (org.apache.samza.config.TaskConfig)1 LocalityManager (org.apache.samza.container.LocalityManager)1 CoordinatorStreamStore (org.apache.samza.coordinator.metadatastore.CoordinatorStreamStore)1