Пример #1
0
        /// <exception cref="System.Exception"/>
        public virtual void TestWarnCommandOpts()
        {
            Logger logger = Logger.GetLogger(typeof(YARNRunner));
            ByteArrayOutputStream bout = new ByteArrayOutputStream();
            Layout   layout            = new SimpleLayout();
            Appender appender          = new WriterAppender(layout, bout);

            logger.AddAppender(appender);
            JobConf jobConf = new JobConf();

            jobConf.Set(MRJobConfig.MrAmAdminCommandOpts, "-Djava.net.preferIPv4Stack=true -Djava.library.path=foo"
                        );
            jobConf.Set(MRJobConfig.MrAmCommandOpts, "-Xmx1024m -Djava.library.path=bar");
            YARNRunner yarnRunner = new YARNRunner(jobConf);
            ApplicationSubmissionContext submissionContext = BuildSubmitContext(yarnRunner, jobConf
                                                                                );
            string logMsg = bout.ToString();

            NUnit.Framework.Assert.IsTrue(logMsg.Contains("WARN - Usage of -Djava.library.path in "
                                                          + "yarn.app.mapreduce.am.admin-command-opts can cause programs to no " + "longer function if hadoop native libraries are used. These values "
                                                          + "should be set as part of the LD_LIBRARY_PATH in the app master JVM " + "env using yarn.app.mapreduce.am.admin.user.env config settings."
                                                          ));
            NUnit.Framework.Assert.IsTrue(logMsg.Contains("WARN - Usage of -Djava.library.path in "
                                                          + "yarn.app.mapreduce.am.command-opts can cause programs to no longer " + "function if hadoop native libraries are used. These values should "
                                                          + "be set as part of the LD_LIBRARY_PATH in the app master JVM env " + "using yarn.app.mapreduce.am.env config settings."
                                                          ));
        }
Пример #2
0
            private LogCapturer(Logger logger)
            {
                this.logger = logger;
                Layout         layout = Logger.GetRootLogger().GetAppender("stdout").GetLayout();
                WriterAppender wa     = new WriterAppender(layout, sw);

                logger.AddAppender(wa);
            }
Пример #3
0
        public virtual void TestJobMonitorAndPrint()
        {
            JobStatus jobStatus_1 = new JobStatus(new JobID("job_000", 1), 1f, 0.1f, 0.1f, 0f
                                                  , JobStatus.State.Running, JobPriority.High, "tmp-user", "tmp-jobname", "tmp-queue"
                                                  , "tmp-jobfile", "tmp-url", true);
            JobStatus jobStatus_2 = new JobStatus(new JobID("job_000", 1), 1f, 1f, 1f, 1f, JobStatus.State
                                                  .Succeeded, JobPriority.High, "tmp-user", "tmp-jobname", "tmp-queue", "tmp-jobfile"
                                                  , "tmp-url", true);

            Org.Mockito.Mockito.DoAnswer(new _Answer_85()).When(job).GetTaskCompletionEvents(
                Matchers.AnyInt(), Matchers.AnyInt());
            Org.Mockito.Mockito.DoReturn(new TaskReport[5]).When(job).GetTaskReports(Matchers.IsA
                                                                                     <TaskType>());
            Org.Mockito.Mockito.When(clientProtocol.GetJobStatus(Matchers.Any <JobID>())).ThenReturn
                (jobStatus_1, jobStatus_2);
            // setup the logger to capture all logs
            Layout layout                  = Logger.GetRootLogger().GetAppender("stdout").GetLayout();
            ByteArrayOutputStream os       = new ByteArrayOutputStream();
            WriterAppender        appender = new WriterAppender(layout, os);

            appender.SetThreshold(Level.All);
            Logger qlogger = Logger.GetLogger(typeof(Job));

            qlogger.AddAppender(appender);
            job.MonitorAndPrintJob();
            qlogger.RemoveAppender(appender);
            LineNumberReader r = new LineNumberReader(new StringReader(os.ToString()));
            string           line;
            bool             foundHundred    = false;
            bool             foundComplete   = false;
            bool             foundUber       = false;
            string           uberModeMatch   = "uber mode : true";
            string           progressMatch   = "map 100% reduce 100%";
            string           completionMatch = "completed successfully";

            while ((line = r.ReadLine()) != null)
            {
                if (line.Contains(uberModeMatch))
                {
                    foundUber = true;
                }
                foundHundred = line.Contains(progressMatch);
                if (foundHundred)
                {
                    break;
                }
            }
            line          = r.ReadLine();
            foundComplete = line.Contains(completionMatch);
            NUnit.Framework.Assert.IsTrue(foundUber);
            NUnit.Framework.Assert.IsTrue(foundHundred);
            NUnit.Framework.Assert.IsTrue(foundComplete);
            System.Console.Out.WriteLine("The output of job.toString() is : \n" + job.ToString
                                             ());
            NUnit.Framework.Assert.IsTrue(job.ToString().Contains("Number of maps: 5\n"));
            NUnit.Framework.Assert.IsTrue(job.ToString().Contains("Number of reduces: 5\n"));
        }
Пример #4
0
        public virtual Logger CreateLogger(TextWriter writer)
        {
            TestLog4Json.TestLoggerRepository repo = new TestLog4Json.TestLoggerRepository();
            Logger         logger   = repo.GetLogger("test");
            Log4Json       layout   = new Log4Json();
            WriterAppender appender = new WriterAppender(layout, writer);

            logger.AddAppender(appender);
            return(logger);
        }