예제 #1
0
        /// <summary>This is a main function for testing JobControl class.</summary>
        /// <remarks>
        /// This is a main function for testing JobControl class.
        /// It requires 4 jobs:
        /// Job 1: passed as parameter. input:indir  output:outdir_1
        /// Job 2: copy data from indir to outdir_2
        /// Job 3: copy data from outdir_1 and outdir_2 to outdir_3
        /// Job 4: copy data from outdir to outdir_4
        /// The jobs 1 and 2 have no dependency. The job 3 depends on jobs 1 and 2.
        /// The job 4 depends on job 3.
        /// Then it creates a JobControl object and add the 4 jobs to
        /// the JobControl object.
        /// Finally, it creates a thread to run the JobControl object
        /// </remarks>
        /// <exception cref="System.Exception"/>
        private JobControl CreateDependencies(Configuration conf, Job job1)
        {
            IList <ControlledJob> dependingJobs = null;

            cjob1 = new ControlledJob(job1, dependingJobs);
            Job job2 = MapReduceTestUtil.CreateCopyJob(conf, outdir_2, indir);

            cjob2 = new ControlledJob(job2, dependingJobs);
            Job job3 = MapReduceTestUtil.CreateCopyJob(conf, outdir_3, outdir_1, outdir_2);

            dependingJobs = new AList <ControlledJob>();
            dependingJobs.AddItem(cjob1);
            dependingJobs.AddItem(cjob2);
            cjob3 = new ControlledJob(job3, dependingJobs);
            Job job4 = MapReduceTestUtil.CreateCopyJob(conf, outdir_4, outdir_3);

            dependingJobs = new AList <ControlledJob>();
            dependingJobs.AddItem(cjob3);
            cjob4 = new ControlledJob(job4, dependingJobs);
            JobControl theControl = new JobControl("Test");

            theControl.AddJob(cjob1);
            theControl.AddJob(cjob2);
            theControl.AddJob(cjob3);
            theControl.AddJob(cjob4);
            Sharpen.Thread theController = new Sharpen.Thread(theControl);
            theController.Start();
            return(theControl);
        }
예제 #2
0
        public virtual void TestErrorWhileSubmitting()
        {
            JobControl    jobControl = new JobControl("Test");
            Job           mockJob    = Org.Mockito.Mockito.Mock <Job>();
            ControlledJob job1       = new ControlledJob(mockJob, null);

            Org.Mockito.Mockito.When(mockJob.GetConfiguration()).ThenReturn(new Configuration
                                                                                ());
            Org.Mockito.Mockito.DoThrow(new IncompatibleClassChangeError("This is a test")).When
                (mockJob).Submit();
            jobControl.AddJob(job1);
            RunJobControl(jobControl);
            try
            {
                NUnit.Framework.Assert.AreEqual("Success list", 0, jobControl.GetSuccessfulJobList
                                                    ().Count);
                NUnit.Framework.Assert.AreEqual("Failed list", 1, jobControl.GetFailedJobList().Count
                                                );
                NUnit.Framework.Assert.IsTrue(job1.GetJobState() == ControlledJob.State.Failed);
            }
            finally
            {
                jobControl.Stop();
            }
        }
예제 #3
0
        /// <exception cref="System.IO.IOException"/>
        /// <exception cref="System.Exception"/>
        private ControlledJob CreateControlledJob(JobControl jobControl, bool successful,
                                                  params ControlledJob[] dependingJobs)
        {
            IList <ControlledJob> dependingJobsList = dependingJobs == null ? null : Arrays.AsList
                                                          (dependingJobs);
            ControlledJob job = new ControlledJob(CreateJob(true, successful), dependingJobsList
                                                  );

            jobControl.AddJob(job);
            return(job);
        }