示例#1
0
        /// <exception cref="System.Exception"/>
        public virtual void TestControlledJob()
        {
            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
                {
                    Sharpen.Thread.Sleep(100);
                }
                catch (Exception)
                {
                    break;
                }
            }
            NUnit.Framework.Assert.IsNotNull(cjob1.GetMapredJobId());
            // wait till all the jobs complete
            WaitTillAllFinished(theControl);
            NUnit.Framework.Assert.AreEqual("Some jobs failed", 0, theControl.GetFailedJobList
                                                ().Count);
            theControl.Stop();
        }
示例#2
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);
        }
示例#3
0
        /// <exception cref="System.Exception"/>
        public virtual void TestJobControl()
        {
            Log.Info("Starting testJobControl");
            Configuration conf = CreateJobConf();

            CleanupData(conf);
            Job        job1       = MapReduceTestUtil.CreateCopyJob(conf, outdir_1, indir);
            JobControl theControl = CreateDependencies(conf, job1);

            // wait till all the jobs complete
            WaitTillAllFinished(theControl);
            NUnit.Framework.Assert.AreEqual("Some jobs failed", 0, theControl.GetFailedJobList
                                                ().Count);
            theControl.Stop();
        }