/** * @return the state of this job */ public synchronized int getState() { State state = super.getJobState(); if (state == State.SUCCESS) { return SUCCESS; } if (state == State.WAITING) { return WAITING; } if (state == State.RUNNING) { return RUNNING; } if (state == State.READY) { return READY; } if (state == State.FAILED ) { return FAILED; } if (state == State.DEPENDENT_FAILED ) { return DEPENDENT_FAILED; } return -1; }
/** * @return the state of this job */ public synchronized int getState() { State state = super.getJobState(); if (state == State.SUCCESS) { return SUCCESS; } if (state == State.WAITING) { return WAITING; } if (state == State.RUNNING) { return RUNNING; } if (state == State.READY) { return READY; } if (state == State.FAILED ) { return FAILED; } if (state == State.DEPENDENT_FAILED ) { return DEPENDENT_FAILED; } return -1; }
/** * @return the state of this job */ public synchronized int getState() { State state = super.getJobState(); if (state == State.SUCCESS) { return SUCCESS; } if (state == State.WAITING) { return WAITING; } if (state == State.RUNNING) { return RUNNING; } if (state == State.READY) { return READY; } if (state == State.FAILED ) { return FAILED; } if (state == State.DEPENDENT_FAILED ) { return DEPENDENT_FAILED; } return -1; }
/** * @return the state of this job */ public synchronized int getState() { State state = super.getJobState(); if (state == State.SUCCESS) { return SUCCESS; } if (state == State.WAITING) { return WAITING; } if (state == State.RUNNING) { return RUNNING; } if (state == State.READY) { return READY; } if (state == State.FAILED ) { return FAILED; } if (state == State.DEPENDENT_FAILED ) { return DEPENDENT_FAILED; } return -1; }
/** * @return the state of this job */ public synchronized int getState() { State state = super.getJobState(); if (state == State.SUCCESS) { return SUCCESS; } if (state == State.WAITING) { return WAITING; } if (state == State.RUNNING) { return RUNNING; } if (state == State.READY) { return READY; } if (state == State.FAILED ) { return FAILED; } if (state == State.DEPENDENT_FAILED ) { return DEPENDENT_FAILED; } return -1; }
synchronized private List<ControlledJob> getJobsIn(State state) { LinkedList<ControlledJob> l = new LinkedList<ControlledJob>(); for(ControlledJob j: jobsInProgress) { if(j.getJobState() == state) { l.add(j); } } return l; }
synchronized private List<ControlledJob> getJobsIn(State state) { LinkedList<ControlledJob> l = new LinkedList<ControlledJob>(); for(ControlledJob j: jobsInProgress) { if(j.getJobState() == state) { l.add(j); } } return l; }
synchronized private List<ControlledJob> getJobsIn(State state) { LinkedList<ControlledJob> l = new LinkedList<ControlledJob>(); for(ControlledJob j: jobsInProgress) { if(j.getJobState() == state) { l.add(j); } } return l; }
synchronized private List<ControlledJob> getJobsIn(State state) { LinkedList<ControlledJob> l = new LinkedList<ControlledJob>(); for(ControlledJob j: jobsInProgress) { if(j.getJobState() == state) { l.add(j); } } return l; }
private void addToQueue(ControlledJob aJob) { Map<String, ControlledJob> queue = getQueue(aJob.getJobState()); addToQueue(aJob, queue); }
public void testJobControlWithFailJob() throws Exception { Configuration conf = createJobConf(); cleanupData(conf); // create a Fail job Job job1 = MapReduceTestUtil.createFailJob(conf, outdir_1, indir); // create job dependencies JobControl theControl = createDependencies(conf, job1); // wait till all the jobs complete waitTillAllFinished(theControl); assertTrue(cjob1.getJobState() == ControlledJob.State.FAILED); assertTrue(cjob2.getJobState() == ControlledJob.State.SUCCESS); assertTrue(cjob3.getJobState() == ControlledJob.State.DEPENDENT_FAILED); assertTrue(cjob4.getJobState() == ControlledJob.State.DEPENDENT_FAILED); theControl.stop(); }
@Test public void testSuccessfulJobs() throws Exception { JobControl jobControl = new JobControl("Test"); ControlledJob job1 = createSuccessfulControlledJob(jobControl); ControlledJob job2 = createSuccessfulControlledJob(jobControl); ControlledJob job3 = createSuccessfulControlledJob(jobControl, job1, job2); ControlledJob job4 = createSuccessfulControlledJob(jobControl, job3); runJobControl(jobControl); assertEquals("Success list", 4, jobControl.getSuccessfulJobList().size()); assertEquals("Failed list", 0, jobControl.getFailedJobList().size()); assertTrue(job1.getJobState() == ControlledJob.State.SUCCESS); assertTrue(job2.getJobState() == ControlledJob.State.SUCCESS); assertTrue(job3.getJobState() == ControlledJob.State.SUCCESS); assertTrue(job4.getJobState() == ControlledJob.State.SUCCESS); jobControl.stop(); }
@Test public void testFailedJob() throws Exception { JobControl jobControl = new JobControl("Test"); ControlledJob job1 = createFailedControlledJob(jobControl); ControlledJob job2 = createSuccessfulControlledJob(jobControl); ControlledJob job3 = createSuccessfulControlledJob(jobControl, job1, job2); ControlledJob job4 = createSuccessfulControlledJob(jobControl, job3); runJobControl(jobControl); assertEquals("Success list", 1, jobControl.getSuccessfulJobList().size()); assertEquals("Failed list", 3, jobControl.getFailedJobList().size()); assertTrue(job1.getJobState() == ControlledJob.State.FAILED); assertTrue(job2.getJobState() == ControlledJob.State.SUCCESS); assertTrue(job3.getJobState() == ControlledJob.State.DEPENDENT_FAILED); assertTrue(job4.getJobState() == ControlledJob.State.DEPENDENT_FAILED); jobControl.stop(); }
public void testJobControlWithFailJob() throws Exception { LOG.info("Starting testJobControlWithFailJob"); Configuration conf = createJobConf(); cleanupData(conf); // create a Fail job Job job1 = MapReduceTestUtil.createFailJob(conf, outdir_1, indir); // create job dependencies JobControl theControl = createDependencies(conf, job1); // wait till all the jobs complete waitTillAllFinished(theControl); assertTrue(cjob1.getJobState() == ControlledJob.State.FAILED); assertTrue(cjob2.getJobState() == ControlledJob.State.SUCCESS); assertTrue(cjob3.getJobState() == ControlledJob.State.DEPENDENT_FAILED); assertTrue(cjob4.getJobState() == ControlledJob.State.DEPENDENT_FAILED); theControl.stop(); }
/** * Returns the progress of a Job j which is part of a submitted JobControl object. The progress is for this Job. So * it has to be scaled down by the number of jobs that are present in the JobControl. * * @param cjob * - The Job for which progress is required * @param jobClient * - the JobClient to which it has been submitted * @return Returns the percentage progress of this Job * @throws IOException * In case any IOException connecting to JobTracker. */ protected double progressOfRunningJob(ControlledJob cjob, JobClient jobClient) throws IOException { @SuppressWarnings("deprecation") RunningJob rj = jobClient.getJob(cjob.getJob().getJobID().toString()); if(rj == null && cjob.getJobState() == ControlledJob.State.SUCCESS) return 1; else if(rj == null) return 0; else { return rj.mapProgress(); } }
/** * Returns the progress of a Job j which is part of a submitted JobControl object. The progress is for this Job. So * it has to be scaled down by the number of jobs that are present in the JobControl. * * @param cjob * - The Job for which progress is required * @param jobClient * - the JobClient to which it has been submitted * @return Returns the percentage progress of this Job * @throws IOException * In case any IOException connecting to JobTracker. */ protected double progressOfRunningJob(ControlledJob cjob, JobClient jobClient) throws IOException { @SuppressWarnings("deprecation") RunningJob rj = jobClient.getJob(cjob.getJob().getJobID().toString()); if(rj == null && cjob.getJobState() == ControlledJob.State.SUCCESS) return 1; else if(rj == null) return 0; else { return rj.mapProgress(); } }
@Test public void testErrorWhileSubmitting() throws Exception { JobControl jobControl = new JobControl("Test"); Job mockJob = mock(Job.class); ControlledJob job1 = new ControlledJob(mockJob, null); when(mockJob.getConfiguration()).thenReturn(new Configuration()); doThrow(new IncompatibleClassChangeError("This is a test")).when(mockJob).submit(); jobControl.addJob(job1); runJobControl(jobControl); try { assertEquals("Success list", 0, jobControl.getSuccessfulJobList().size()); assertEquals("Failed list", 1, jobControl.getFailedJobList().size()); assertTrue(job1.getJobState() == ControlledJob.State.FAILED); } finally { jobControl.stop(); } }
@Test public void testSuccessfulJobs() throws Exception { JobControl jobControl = new JobControl("Test"); ControlledJob job1 = createSuccessfulControlledJob(jobControl); ControlledJob job2 = createSuccessfulControlledJob(jobControl); ControlledJob job3 = createSuccessfulControlledJob(jobControl, job1, job2); ControlledJob job4 = createSuccessfulControlledJob(jobControl, job3); runJobControl(jobControl); assertEquals("Success list", 4, jobControl.getSuccessfulJobList().size()); assertEquals("Failed list", 0, jobControl.getFailedJobList().size()); assertTrue(job1.getJobState() == ControlledJob.State.SUCCESS); assertTrue(job2.getJobState() == ControlledJob.State.SUCCESS); assertTrue(job3.getJobState() == ControlledJob.State.SUCCESS); assertTrue(job4.getJobState() == ControlledJob.State.SUCCESS); jobControl.stop(); }
@Test public void testFailedJob() throws Exception { JobControl jobControl = new JobControl("Test"); ControlledJob job1 = createFailedControlledJob(jobControl); ControlledJob job2 = createSuccessfulControlledJob(jobControl); ControlledJob job3 = createSuccessfulControlledJob(jobControl, job1, job2); ControlledJob job4 = createSuccessfulControlledJob(jobControl, job3); runJobControl(jobControl); assertEquals("Success list", 1, jobControl.getSuccessfulJobList().size()); assertEquals("Failed list", 3, jobControl.getFailedJobList().size()); assertTrue(job1.getJobState() == ControlledJob.State.FAILED); assertTrue(job2.getJobState() == ControlledJob.State.SUCCESS); assertTrue(job3.getJobState() == ControlledJob.State.DEPENDENT_FAILED); assertTrue(job4.getJobState() == ControlledJob.State.DEPENDENT_FAILED); jobControl.stop(); }
@Test(timeout = 30000) public void testControlledJob() throws Exception { LOG.info("Starting testControlledJob"); Configuration conf = createJobConf(); cleanupData(conf); Job job1 = MapReduceTestUtil.createCopyJob(conf, outdir_1, indir); JobControl theControl = createDependencies(conf, job1); while (cjob1.getJobState() != ControlledJob.State.RUNNING) { try { Thread.sleep(100); } catch (InterruptedException e) { break; } } Assert.assertNotNull(cjob1.getMapredJobId()); // wait till all the jobs complete waitTillAllFinished(theControl); assertEquals("Some jobs failed", 0, theControl.getFailedJobList().size()); theControl.stop(); } }