Search in sources :

Example 1 with HttpServer

use of org.apache.samza.coordinator.server.HttpServer 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 HttpServer

use of org.apache.samza.coordinator.server.HttpServer in project samza by apache.

the class HttpCoordinatorToWorkerCommunicationFactory method coordinatorCommunication.

@Override
public CoordinatorCommunication coordinatorCommunication(CoordinatorCommunicationContext context) {
    ClusterManagerConfig clusterManagerConfig = new ClusterManagerConfig(context.getConfigForFactory());
    JobModelHttpServlet jobModelHttpServlet = new JobModelHttpServlet(context.getJobInfoProvider(), new JobModelHttpServlet.Metrics(context.getMetricsRegistry()));
    HttpServer httpServer = new HttpServer("/", clusterManagerConfig.getCoordinatorUrlPort(), null, new ServletHolder(DefaultServlet.class));
    httpServer.addServlet("/", jobModelHttpServlet);
    return new HttpCoordinatorCommunication(httpServer);
}
Also used : ClusterManagerConfig(org.apache.samza.config.ClusterManagerConfig) ServletHolder(org.eclipse.jetty.servlet.ServletHolder) HttpServer(org.apache.samza.coordinator.server.HttpServer) DefaultServlet(org.eclipse.jetty.servlet.DefaultServlet)

Example 3 with HttpServer

use of org.apache.samza.coordinator.server.HttpServer in project samza by apache.

the class TestYarnContainerHeartbeatServlet method setup.

@Before
public void setup() throws Exception {
    container = mock(YarnContainer.class);
    ReadableMetricsRegistry registry = new MetricsRegistryMap();
    yarnAppState = new YarnAppState(-1, ConverterUtils.toContainerId("container_1350670447861_0003_01_000001"), "testHost", 1, 1);
    webApp = new HttpServer("/", 0, "", new ServletHolder(new DefaultServlet()));
    webApp.addServlet("/", new YarnContainerHeartbeatServlet(yarnAppState, registry));
    webApp.start();
    mapper = new ObjectMapper();
}
Also used : ReadableMetricsRegistry(org.apache.samza.metrics.ReadableMetricsRegistry) ServletHolder(org.eclipse.jetty.servlet.ServletHolder) YarnAppState(org.apache.samza.job.yarn.YarnAppState) HttpServer(org.apache.samza.coordinator.server.HttpServer) YarnContainer(org.apache.samza.job.yarn.YarnContainer) DefaultServlet(org.eclipse.jetty.servlet.DefaultServlet) MetricsRegistryMap(org.apache.samza.metrics.MetricsRegistryMap) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Before(org.junit.Before)

Example 4 with HttpServer

use of org.apache.samza.coordinator.server.HttpServer in project samza by apache.

the class TestLocalityServlet method setup.

@Before
public void setup() throws Exception {
    localityManager = mock(LocalityManager.class);
    when(localityManager.readLocality()).thenReturn(new LocalityModel(ImmutableMap.of(PROCESSOR_ID1, PROCESSOR_1_LOCALITY, PROCESSOR_ID2, PROCESSOR_2_LOCALITY)));
    webApp = new HttpServer("/", 0, "", new ServletHolder(new DefaultServlet()));
    webApp.addServlet("/locality", new LocalityServlet(localityManager));
    webApp.start();
}
Also used : LocalityServlet(org.apache.samza.coordinator.server.LocalityServlet) ServletHolder(org.eclipse.jetty.servlet.ServletHolder) HttpServer(org.apache.samza.coordinator.server.HttpServer) DefaultServlet(org.eclipse.jetty.servlet.DefaultServlet) LocalityManager(org.apache.samza.container.LocalityManager) LocalityModel(org.apache.samza.job.model.LocalityModel) Before(org.junit.Before)

Example 5 with HttpServer

use of org.apache.samza.coordinator.server.HttpServer 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)

Aggregations

HttpServer (org.apache.samza.coordinator.server.HttpServer)6 DefaultServlet (org.eclipse.jetty.servlet.DefaultServlet)6 ServletHolder (org.eclipse.jetty.servlet.ServletHolder)6 HashMap (java.util.HashMap)2 TaskName (org.apache.samza.container.TaskName)2 JobModelManager (org.apache.samza.coordinator.JobModelManager)2 ContainerModel (org.apache.samza.job.model.ContainerModel)2 JobModel (org.apache.samza.job.model.JobModel)2 TaskModel (org.apache.samza.job.model.TaskModel)2 Before (org.junit.Before)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 URI (java.net.URI)1 ClusterManagerConfig (org.apache.samza.config.ClusterManagerConfig)1 LocalityManager (org.apache.samza.container.LocalityManager)1 LocalityServlet (org.apache.samza.coordinator.server.LocalityServlet)1 LocalityModel (org.apache.samza.job.model.LocalityModel)1 YarnAppState (org.apache.samza.job.yarn.YarnAppState)1 YarnContainer (org.apache.samza.job.yarn.YarnContainer)1 MetricsRegistryMap (org.apache.samza.metrics.MetricsRegistryMap)1 ReadableMetricsRegistry (org.apache.samza.metrics.ReadableMetricsRegistry)1