Search in sources :

Example 1 with Job

use of org.apache.samza.rest.model.Job in project samza by apache.

the class YarnCliJobStatusProvider method getJobStatus.

@Override
public Job getJobStatus(JobInstance jobInstance) throws IOException, InterruptedException {
    Job info = new Job(jobInstance.getJobName(), jobInstance.getJobId());
    getJobStatuses(Collections.singletonList(info));
    return info;
}
Also used : Job(org.apache.samza.rest.model.Job)

Example 2 with Job

use of org.apache.samza.rest.model.Job in project samza by apache.

the class TestJobsResource method testGetJobs.

@Test
public void testGetJobs() throws IOException {
    Response resp = target("v1/jobs").request().get();
    assertEquals(200, resp.getStatus());
    final Job[] jobs = objectMapper.readValue(resp.readEntity(String.class), Job[].class);
    assertEquals(4, jobs.length);
    assertEquals(MockJobProxy.JOB_INSTANCE_1_NAME, jobs[0].getJobName());
    assertEquals(MockJobProxy.JOB_INSTANCE_1_ID, jobs[0].getJobId());
    assertStatusNotDefault(jobs[0]);
    assertEquals(MockJobProxy.JOB_INSTANCE_2_NAME, jobs[1].getJobName());
    assertEquals(MockJobProxy.JOB_INSTANCE_2_ID, jobs[1].getJobId());
    assertStatusNotDefault(jobs[1]);
    assertEquals(MockJobProxy.JOB_INSTANCE_3_NAME, jobs[2].getJobName());
    assertEquals(MockJobProxy.JOB_INSTANCE_3_ID, jobs[2].getJobId());
    assertStatusNotDefault(jobs[2]);
    assertEquals(MockJobProxy.JOB_INSTANCE_4_NAME, jobs[3].getJobName());
    assertEquals(MockJobProxy.JOB_INSTANCE_4_ID, jobs[3].getJobId());
    assertStatusNotDefault(jobs[3]);
    resp.close();
}
Also used : Response(javax.ws.rs.core.Response) Job(org.apache.samza.rest.model.Job) Test(org.junit.Test) JerseyTest(org.glassfish.jersey.test.JerseyTest)

Example 3 with Job

use of org.apache.samza.rest.model.Job in project samza by apache.

the class TestJobsResource method testStopJob.

@Test
public void testStopJob() throws IOException {
    Response resp = target(String.format("v1/jobs/%s/%s", MockJobProxy.JOB_INSTANCE_2_NAME, MockJobProxy.JOB_INSTANCE_2_ID)).queryParam("status", "stopped").request().put(Entity.form(new Form()));
    assertEquals(202, resp.getStatus());
    final Job job2 = objectMapper.readValue(resp.readEntity(String.class), Job.class);
    assertEquals(MockJobProxy.JOB_INSTANCE_2_NAME, job2.getJobName());
    assertEquals(MockJobProxy.JOB_INSTANCE_2_ID, job2.getJobId());
    assertStatusNotDefault(job2);
    resp.close();
}
Also used : Response(javax.ws.rs.core.Response) Form(javax.ws.rs.core.Form) Job(org.apache.samza.rest.model.Job) Test(org.junit.Test) JerseyTest(org.glassfish.jersey.test.JerseyTest)

Example 4 with Job

use of org.apache.samza.rest.model.Job in project samza by apache.

the class MockJobStatusProvider method getJobStatus.

@Override
public Job getJobStatus(JobInstance jobInstance) throws IOException, InterruptedException {
    Job info = new Job(jobInstance.getJobName(), jobInstance.getJobId());
    setStatusStarted(info);
    return info;
}
Also used : Job(org.apache.samza.rest.model.Job)

Example 5 with Job

use of org.apache.samza.rest.model.Job in project samza by apache.

the class TestJobsResource method testGetJob.

@Test
public void testGetJob() throws IOException {
    Response resp = target(String.format("v1/jobs/%s/%s", MockJobProxy.JOB_INSTANCE_2_NAME, MockJobProxy.JOB_INSTANCE_2_ID)).request().get();
    assertEquals(200, resp.getStatus());
    final Job job2 = objectMapper.readValue(resp.readEntity(String.class), Job.class);
    assertEquals(MockJobProxy.JOB_INSTANCE_2_NAME, job2.getJobName());
    assertEquals(MockJobProxy.JOB_INSTANCE_2_ID, job2.getJobId());
    assertStatusNotDefault(job2);
    resp.close();
}
Also used : Response(javax.ws.rs.core.Response) Job(org.apache.samza.rest.model.Job) Test(org.junit.Test) JerseyTest(org.glassfish.jersey.test.JerseyTest)

Aggregations

Job (org.apache.samza.rest.model.Job)9 Response (javax.ws.rs.core.Response)4 JerseyTest (org.glassfish.jersey.test.JerseyTest)4 Test (org.junit.Test)4 Form (javax.ws.rs.core.Form)2 JobStatus (org.apache.samza.rest.model.JobStatus)2 BufferedReader (java.io.BufferedReader)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 PUT (javax.ws.rs.PUT)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 SamzaException (org.apache.samza.SamzaException)1 JobInstance (org.apache.samza.rest.proxy.job.JobInstance)1 ScriptOutputHandler (org.apache.samza.rest.script.ScriptOutputHandler)1 ScriptRunner (org.apache.samza.rest.script.ScriptRunner)1