Examples of PigJob


Examples of com.twitter.ambrose.pig.PigJob

    String[] aliases = new String[] { "alias1" };
    String[] features = new String[] { "feature1" };
    Map<String, Number> m = new HashMap<String, Number>();
    m.put("somemetric", 45);

    pigJob = new PigJob();
    pigJob.setAliases(aliases);
    pigJob.setFeatures(features);
    pigJob.setConfiguration(properties);
    pigJob.setMetrics(m);
  }
View Full Code Here

Examples of com.twitter.ambrose.pig.PigJob

                   "  },\n" +
                   "  \"id\" : 1,\n" +
                   "  \"timestamp\" : 1373560988033\n" +
                   "}";
    Event event = Event.fromJson(json);
    PigJob job = ((DAGNode<PigJob>)event.getPayload()).getJob();
    assertEquals("job_local_0001", job.getId());
    assertArrayEquals(new String[] {"A", "AA", "B", "C"}, job.getAliases());
    assertArrayEquals(new String[] {"GROUP_BY", "COMBINER", "MAP_PARTIALAGG"}, job.getFeatures());
    assertNotNull(job.getMetrics());
    assertEquals(123, job.getMetrics().get("somemetric"));
  }
View Full Code Here

Examples of org.apache.ambari.view.pig.resources.jobs.models.PigJob

    return doCreateJob(title, pigScript, templetonArguments, null);
  }

  private Response doCreateJob(String title, String pigScript, String templetonArguments, String forcedContent) {
    JobService.PigJobRequest request = new JobService.PigJobRequest();
    request.job = new PigJob();
    request.job.setTitle(title);
    request.job.setPigScript(pigScript);
    request.job.setTempletonArguments(templetonArguments);
    request.job.setForcedContent(forcedContent);
View Full Code Here

Examples of org.apache.ambari.view.pig.resources.jobs.models.PigJob

    Assert.assertTrue(obj.containsKey("job"));
    Assert.assertNotNull(((PigJob) obj.get("job")).getId());
    Assert.assertFalse(((PigJob) obj.get("job")).getId().isEmpty());
    Assert.assertTrue(((PigJob) obj.get("job")).getStatusDir().startsWith("/tmp/.pigjobs/ambari-qa/test"));

    PigJob job = ((PigJob) obj.get("job"));
    Assert.assertEquals(PigJob.Status.SUBMITTED, job.getStatus());
    Assert.assertTrue(job.isInProgress());
  }
View Full Code Here

Examples of org.apache.ambari.view.pig.resources.jobs.models.PigJob

    Assert.assertTrue(obj.containsKey("job"));
    Assert.assertNotNull(((PigJob) obj.get("job")).getId());
    Assert.assertFalse(((PigJob) obj.get("job")).getId().isEmpty());
    Assert.assertTrue(((PigJob) obj.get("job")).getStatusDir().startsWith("/tmp/.pigjobs/ambari-qa/test"));

    PigJob job = ((PigJob) obj.get("job"));
    Assert.assertEquals(PigJob.Status.SUBMITTED, job.getStatus());
    Assert.assertTrue(job.isInProgress());
  }
View Full Code Here

Examples of org.apache.ambari.view.pig.resources.jobs.models.PigJob

    reset(api);
    api.killJob(eq("job_id_##"));
    replay(api);
    JSONObject obj = (JSONObject)response.getEntity();
    PigJob job = ((PigJob)obj.get("job"));
    response = jobService.killJob(job.getId());
    Assert.assertEquals(204, response.getStatus());
  }
View Full Code Here

Examples of org.apache.ambari.view.pig.resources.jobs.models.PigJob

    Response response = doCreateJob("Test", "/tmp/script.pig", "-useHCatalog");

    Assert.assertEquals("-useHCatalog", do_stream.toString());
    Assert.assertEquals(201, response.getStatus());

    PigJob job = ((PigJob) ((JSONObject)response.getEntity()).get("job"));
    Assert.assertEquals(PigJob.Status.SUBMITTED, job.getStatus());
    Assert.assertTrue(job.isInProgress());

    // Retrieve status:
    // SUBMITTED
    reset(api);
    TempletonApi.JobInfo info = api.new JobInfo();
    expect(api.checkJob(eq("job_id_#"))).andReturn(info);
    replay(api);
    response = jobService.getJob(job.getId());
    Assert.assertEquals(200, response.getStatus());
    job = ((PigJob) ((JSONObject)response.getEntity()).get("job"));
    Assert.assertEquals(PigJob.Status.SUBMITTED, job.getStatus());

    // RUNNING
    reset(api);
    info = api.new JobInfo();
    info.status = new HashMap<String, Object>();
    info.status.put("runState", (double)PigJob.RUN_STATE_RUNNING);
    info.percentComplete = "30% complete";
    expect(api.checkJob(eq("job_id_#"))).andReturn(info);
    replay(api);
    response = jobService.getJob(job.getId());
    Assert.assertEquals(200, response.getStatus());
    job = ((PigJob) ((JSONObject)response.getEntity()).get("job"));
    Assert.assertEquals(PigJob.Status.RUNNING, job.getStatus());
    Assert.assertTrue(job.isInProgress());
    Assert.assertEquals(30, (Object) job.getPercentComplete());

    // SUCCEED
    reset(api);
    info = api.new JobInfo();
    info.status = new HashMap<String, Object>();
    info.status.put("runState", (double)PigJob.RUN_STATE_SUCCEEDED);
    expect(api.checkJob(eq("job_id_#"))).andReturn(info);
    replay(api);
    response = jobService.getJob(job.getId());
    Assert.assertEquals(200, response.getStatus());
    job = ((PigJob) ((JSONObject)response.getEntity()).get("job"));
    Assert.assertEquals(PigJob.Status.COMPLETED, job.getStatus());
    Assert.assertFalse(job.isInProgress());
    Assert.assertNull(job.getPercentComplete());

    // PREP
    reset(api);
    info = api.new JobInfo();
    info.status = new HashMap<String, Object>();
    info.status.put("runState", (double)PigJob.RUN_STATE_PREP);
    expect(api.checkJob(eq("job_id_#"))).andReturn(info);
    replay(api);
    response = jobService.getJob(job.getId());
    Assert.assertEquals(200, response.getStatus());
    job = ((PigJob) ((JSONObject)response.getEntity()).get("job"));
    Assert.assertEquals(PigJob.Status.RUNNING, job.getStatus());

    // FAILED
    reset(api);
    info = api.new JobInfo();
    info.status = new HashMap<String, Object>();
    info.status.put("runState", (double)PigJob.RUN_STATE_FAILED);
    expect(api.checkJob(eq("job_id_#"))).andReturn(info);
    replay(api);
    response = jobService.getJob(job.getId());
    Assert.assertEquals(200, response.getStatus());
    job = ((PigJob) ((JSONObject)response.getEntity()).get("job"));
    Assert.assertEquals(PigJob.Status.FAILED, job.getStatus());
    Assert.assertFalse(job.isInProgress());

    // KILLED
    reset(api);
    info = api.new JobInfo();
    info.status = new HashMap<String, Object>();
    info.status.put("runState", (double)PigJob.RUN_STATE_KILLED);
    expect(api.checkJob(eq("job_id_#"))).andReturn(info);
    replay(api);
    response = jobService.getJob(job.getId());
    Assert.assertEquals(200, response.getStatus());
    job = ((PigJob) ((JSONObject)response.getEntity()).get("job"));
    Assert.assertEquals(PigJob.Status.KILLED, job.getStatus());
    Assert.assertFalse(job.isInProgress());
  }
View Full Code Here

Examples of org.apache.ambari.view.pig.resources.jobs.models.PigJob

  @GET
  @Path("{jobId}")
  @Produces(MediaType.APPLICATION_JSON)
  public Response getJob(@PathParam("jobId") String jobId) {
    try {
      PigJob job = null;
      try {
        job = getResourceManager().read(jobId);
      } catch (ItemNotFound itemNotFound) {
        throw new NotFoundFormattedException(itemNotFound.getMessage(), itemNotFound);
      }
View Full Code Here

Examples of org.apache.ambari.view.pig.resources.jobs.models.PigJob

   */
  @DELETE
  @Path("{jobId}")
  public Response killJob(@PathParam("jobId") String jobId) throws IOException {
    try {
      PigJob job = null;
      try {
        job = getResourceManager().read(jobId);
      } catch (ItemNotFound itemNotFound) {
        throw new NotFoundFormattedException(itemNotFound.getMessage(), itemNotFound);
      }
View Full Code Here

Examples of org.apache.ambari.view.pig.resources.jobs.models.PigJob

  @Path("{jobId}/notify")
  public Response jobCompletionNotification(@Context HttpHeaders headers,
                                            @Context UriInfo ui,
                                            @PathParam("jobId") final String jobId) {
    try {
      PigJob job = null;
      job = getResourceManager().ignorePermissions(new Callable<PigJob>() {
        public PigJob call() throws Exception {
          PigJob job = null;
          try {
            job = getResourceManager().read(jobId);
          } catch (ItemNotFound itemNotFound) {
            return null;
          }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.