@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); } } }
/** * Add a new job. * @param aJob the new job */ synchronized public String addJob(ControlledJob aJob) { String id = this.getNextJobID(); aJob.setJobID(id); aJob.setJobState(State.WAITING); this.addToQueue(aJob); return id; }
/** * Add a new job. * * @param aJob * the new job */ synchronized public String addJob(CrunchControlledJob aJob) { String id = this.getNextJobID(); aJob.setJobID(id); aJob.setJobState(State.WAITING); this.addToQueue(aJob); return id; }
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; }
/** * Add a new job. * @param aJob the new job */ synchronized public String addJob(Job aJob) { return addJob((ControlledJob) aJob); }
/** * Default constructor. Construct default JobControl instance. */ public GuaguaMapReduceClient() { this.jc = new JobControl(INIT_JOB_ID_PREFIX); }
@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 void addToQueue(ControlledJob aJob) { Map<String, ControlledJob> queue = getQueue(aJob.getJobState()); addToQueue(aJob, queue); }
/** * Add a job to this jobs' dependency list. * Dependent jobs can only be added while a Job * is waiting to run, not during or afterwards. * * @param dependingJob Job that this Job depends on. * @return <tt>true</tt> if the Job was added. */ public synchronized boolean addDependingJob(Job dependingJob) { return super.addDependingJob(dependingJob); }
/** * @return the jobs in the waiting state */ public List<ControlledJob> getWaitingJobList() { return getJobsIn(State.WAITING); }
/** * @return the jobs in the success state */ synchronized public List<ControlledJob> getSuccessfulJobList() { return toList(this.successfulJobs); }
private void addToQueue(CrunchControlledJob aJob) { Map<String, CrunchControlledJob> queue = getQueue(aJob.getJobState()); addToQueue(aJob, queue); }
/** * @return the jobs in the running state */ public List<CrunchControlledJob> getRunningJobList() { return toList(this.runningJobs); }
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; }
/** * Add a collection of jobs * * @param jobs */ public void addJobCollection(Collection<ControlledJob> jobs) { for (ControlledJob job : jobs) { addJob(job); } }
/** * @return the jobs in the ready state */ public List<ControlledJob> getReadyJobsList() { return getJobsIn(State.READY); }
/** * @return the jobs in the running state */ public List<ControlledJob> getRunningJobList() { return toList(this.runningJobs); }
/** * Add a new job. * @param aJob the new job */ synchronized public String addJob(Job aJob) { return addJob((ControlledJob) aJob); }
/** * @return the jobs in the running state */ public List<ControlledJob> getRunningJobList() { return getJobsIn(State.RUNNING); }
/** * @return the jobs in the waiting state */ public List<ControlledJob> getWaitingJobList() { return getJobsIn(State.WAITING); }