@Test public void testCircularDependency() throws IOException { ControlledJob job1 = new ControlledJob(new Configuration()); job1.setJobName("job1"); ControlledJob job2 = new ControlledJob(new Configuration()); job2.setJobName("job2"); ControlledJob job3 = new ControlledJob(new Configuration()); job3.setJobName("job3"); job1.addDependingJob(job2); job2.addDependingJob(job3); job3.addDependingJob(job1); JobControl jobControl = new JobControl("test"); jobControl.addJob(job1); jobControl.addJob(job2); jobControl.addJob(job3); try { jobControl.run(); } catch (Exception e) { assertTrue(e instanceof IllegalArgumentException); } } }
@Test public void testUnexpectedJobStatus() throws Exception { Cluster cluster = mock(Cluster.class); JobID jobid = new JobID("1014873536921", 6); ClientProtocol clientProtocol = mock(ClientProtocol.class); when(cluster.getClient()).thenReturn(clientProtocol); JobStatus status = new JobStatus(jobid, 0f, 0f, 0f, 0f, State.RUNNING, JobPriority.DEFAULT, "root", "testUnexpectedJobStatus", "job file", "tracking URL"); when(clientProtocol.getJobStatus(jobid)).thenReturn(status); Job job = Job.getInstance(cluster, status, new JobConf()); // ensurer job status is RUNNING Assert.assertNotNull(job.getStatus()); Assert.assertTrue(job.getStatus().getState() == State.RUNNING); // when updating job status, job client could not retrieve // job status, and status reset to null when(clientProtocol.getJobStatus(jobid)).thenReturn(null); try { job.updateStatus(); } catch (IOException e) { Assert.assertTrue(e != null && e.getMessage().contains("Job status not available")); } try { ControlledJob cj = new ControlledJob(job, null); Assert.assertNotNull(cj.toString()); } catch (NullPointerException e) { Assert.fail("job API fails with NPE"); } }
private ControlledJob createControlledJob(JobControl jobControl, boolean successful, ControlledJob... dependingJobs) throws IOException, InterruptedException { List<ControlledJob> dependingJobsList = dependingJobs == null ? null : Arrays.asList(dependingJobs); ControlledJob job = new ControlledJob(createJob(true, successful), dependingJobsList); jobControl.addJob(job); return job; }
@Test public void testAddingDependingJobToRunningJobFails() throws Exception { Configuration conf = new Configuration(); ControlledJob job1 = new ControlledJob(conf); job1.setJobState(ControlledJob.State.RUNNING); assertFalse(job1.addDependingJob(new ControlledJob(conf))); }
@Test public void testAddingDependingJobToCompletedJobFails() throws Exception { Configuration conf = new Configuration(); ControlledJob job1 = new ControlledJob(conf); job1.setJobState(ControlledJob.State.SUCCESS); assertFalse(job1.addDependingJob(new ControlledJob(conf))); }
/** * Add new job to JobControl instance. */ public synchronized void addJob(String[] args) throws IOException { Job job = createJob(args); this.jc.addJob(new ControlledJob(job, null)); if(this.jobIndexMap.containsKey(job.getJobName())) { throw new IllegalStateException("Job name should be unique. please check name with: " + job.getJobName()); } this.jobIndexMap.put(job.getJobName(), this.jobIndex); this.jobIndexParams.put(this.jobIndex, args); this.jobRunningTimes.put(this.jobIndex, 1); this.jobIndex += 1; }
/** * Add new job to JobControl instance. */ public synchronized void addJob(String[] args) throws IOException { Job job = createJob(args); this.jc.addJob(new ControlledJob(job, null)); if(this.jobIndexMap.containsKey(job.getJobName())) { throw new IllegalStateException("Job name should be unique. please check name with: " + job.getJobName()); } this.jobIndexMap.put(job.getJobName(), this.jobIndex); this.jobIndexParams.put(this.jobIndex, args); this.jobRunningTimes.put(this.jobIndex, 1); this.jobIndex += 1; }
public static JobControl createValueAggregatorJobs(String args[], Class<? extends ValueAggregatorDescriptor>[] descriptors) throws IOException { JobControl theControl = new JobControl("ValueAggregatorJobs"); ArrayList<ControlledJob> dependingJobs = new ArrayList<ControlledJob>(); Configuration conf = new Configuration(); if (descriptors != null) { conf = setAggregatorDescriptors(descriptors); } Job job = createValueAggregatorJob(conf, args); ControlledJob cjob = new ControlledJob(job, dependingJobs); theControl.addJob(cjob); return theControl; }
public static JobControl createValueAggregatorJobs(String args[], Class<? extends ValueAggregatorDescriptor>[] descriptors) throws IOException { JobControl theControl = new JobControl("ValueAggregatorJobs"); ArrayList<ControlledJob> dependingJobs = new ArrayList<ControlledJob>(); Configuration conf = new Configuration(); if (descriptors != null) { conf = setAggregatorDescriptors(descriptors); } Job job = createValueAggregatorJob(conf, args); ControlledJob cjob = new ControlledJob(job, dependingJobs); theControl.addJob(cjob); return theControl; }
public static JobControl createValueAggregatorJobs(String args[], Class<? extends ValueAggregatorDescriptor>[] descriptors) throws IOException { JobControl theControl = new JobControl("ValueAggregatorJobs"); ArrayList<ControlledJob> dependingJobs = new ArrayList<ControlledJob>(); Configuration conf = new Configuration(); if (descriptors != null) { conf = setAggregatorDescriptors(descriptors); } Job job = createValueAggregatorJob(conf, args); ControlledJob cjob = new ControlledJob(job, dependingJobs); theControl.addJob(cjob); return theControl; }
job.setInputFormatClass(TextInputFormat.class); ControlledJob controlledJob = new ControlledJob(job.getConfiguration()); jobControl.addJob(controlledJob); Thread thread = new Thread(jobControl);
public static JobControl createValueAggregatorJobs(String args[], Class<? extends ValueAggregatorDescriptor>[] descriptors) throws IOException { JobControl theControl = new JobControl("ValueAggregatorJobs"); ArrayList<ControlledJob> dependingJobs = new ArrayList<ControlledJob>(); Configuration conf = new Configuration(); if (descriptors != null) { conf = setAggregatorDescriptors(descriptors); } Job job = createValueAggregatorJob(conf, args); ControlledJob cjob = new ControlledJob(job, dependingJobs); theControl.addJob(cjob); return theControl; }
public static JobControl createValueAggregatorJobs(String args[], Class<? extends ValueAggregatorDescriptor>[] descriptors) throws IOException { JobControl theControl = new JobControl("ValueAggregatorJobs"); ArrayList<ControlledJob> dependingJobs = new ArrayList<ControlledJob>(); Configuration conf = new Configuration(); if (descriptors != null) { conf = setAggregatorDescriptors(descriptors); } Job job = createValueAggregatorJob(conf, args); ControlledJob cjob = new ControlledJob(job, dependingJobs); theControl.addJob(cjob); return theControl; }
throws Exception { List<ControlledJob> dependingJobs = null; cjob1 = new ControlledJob(job1, dependingJobs); Job job2 = MapReduceTestUtil.createCopyJob(conf, outdir_2, indir); cjob2 = new ControlledJob(job2, dependingJobs); dependingJobs.add(cjob1); dependingJobs.add(cjob2); cjob3 = new ControlledJob(job3, dependingJobs); cjob4 = new ControlledJob(job4, dependingJobs);
ControlledJob controlledJob = new ControlledJob(conf); controlledJob.setJob(job); if(i>0){
private ControlledJob createControlledJob(JobControl jobControl, boolean successful, ControlledJob... dependingJobs) throws IOException, InterruptedException { List<ControlledJob> dependingJobsList = dependingJobs == null ? null : Arrays.asList(dependingJobs); ControlledJob job = new ControlledJob(createJob(true, successful), dependingJobsList); jobControl.addJob(job); return job; }
@Test public void testAddingDependingJobToRunningJobFails() throws Exception { Configuration conf = new Configuration(); ControlledJob job1 = new ControlledJob(conf); job1.setJobState(ControlledJob.State.RUNNING); assertFalse(job1.addDependingJob(new ControlledJob(conf))); }
@Test public void testAddingDependingJobToCompletedJobFails() throws Exception { Configuration conf = new Configuration(); ControlledJob job1 = new ControlledJob(conf); job1.setJobState(ControlledJob.State.SUCCESS); assertFalse(job1.addDependingJob(new ControlledJob(conf))); }
throws Exception { List<ControlledJob> dependingJobs = null; cjob1 = new ControlledJob(job1, dependingJobs); Job job2 = MapReduceTestUtil.createCopyJob(conf, outdir_2, indir); cjob2 = new ControlledJob(job2, dependingJobs); dependingJobs.add(cjob1); dependingJobs.add(cjob2); cjob3 = new ControlledJob(job3, dependingJobs); cjob4 = new ControlledJob(job4, dependingJobs);
@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(); } }