Пример #1
0
        /// <summary>
        /// Given a path with a jar, make a classloader with that jar on the
        /// classpath, and check that findContainingJar can correctly
        /// identify the path of the jar.
        /// </summary>
        /// <exception cref="System.Exception"/>
        private void TestJarAtPath(string path)
        {
            FilePath jar = new FilePath(path).GetAbsoluteFile();

            NUnit.Framework.Assert.IsTrue(jar.Exists());
            Uri[]       urls  = new Uri[] { jar.ToURI().ToURL() };
            ClassLoader cl    = new URLClassLoader(urls);
            Type        clazz = Sharpen.Runtime.GetType(Classname, true, cl);

            NUnit.Framework.Assert.IsNotNull(clazz);
            string containingJar = ClassUtil.FindContainingJar(clazz);

            NUnit.Framework.Assert.AreEqual(jar.GetAbsolutePath(), containingJar);
        }
Пример #2
0
        /// <exception cref="System.Exception"/>
        private void TestSleepJobInternal(bool useRemoteJar)
        {
            Log.Info("\n\n\nStarting testSleepJob: useRemoteJar=" + useRemoteJar);
            if (!(new FilePath(MiniMRYarnCluster.Appjar)).Exists())
            {
                Log.Info("MRAppJar " + MiniMRYarnCluster.Appjar + " not found. Not running test."
                         );
                return;
            }
            Configuration sleepConf = new Configuration(mrCluster.GetConfig());

            // set master address to local to test that local mode applied iff framework == local
            sleepConf.Set(MRConfig.MasterAddress, "local");
            SleepJob sleepJob = new SleepJob();

            sleepJob.SetConf(sleepConf);
            // job with 3 maps (10s) and numReduces reduces (5s), 1 "record" each:
            Job job = sleepJob.CreateJob(3, numSleepReducers, 10000, 1, 5000, 1);

            job.AddFileToClassPath(AppJar);
            // The AppMaster jar itself.
            if (useRemoteJar)
            {
                Path localJar = new Path(ClassUtil.FindContainingJar(typeof(SleepJob)));
                ConfigUtil.AddLink(job.GetConfiguration(), "/jobjars", localFs.MakeQualified(localJar
                                                                                             .GetParent()).ToUri());
                job.SetJar("viewfs:///jobjars/" + localJar.GetName());
            }
            else
            {
                job.SetJarByClass(typeof(SleepJob));
            }
            job.SetMaxMapAttempts(1);
            // speed up failures
            job.Submit();
            string trackingUrl = job.GetTrackingURL();
            string jobId       = job.GetJobID().ToString();
            bool   succeeded   = job.WaitForCompletion(true);

            NUnit.Framework.Assert.IsTrue(succeeded);
            NUnit.Framework.Assert.AreEqual(JobStatus.State.Succeeded, job.GetJobState());
            NUnit.Framework.Assert.IsTrue("Tracking URL was " + trackingUrl + " but didn't Match Job ID "
                                          + jobId, trackingUrl.EndsWith(Sharpen.Runtime.Substring(jobId, jobId.LastIndexOf
                                                                                                      ("_")) + "/"));
            VerifySleepJobCounters(job);
            VerifyTaskProgress(job);
        }