コード例 #1
0
ファイル: TestEvents.cs プロジェクト: orf53975/hadoop.net
        /*
         * test EventReader EventReader should read the list of events and return
         * instance of HistoryEvent Different HistoryEvent should have a different
         * datum.
         */
        /// <exception cref="System.Exception"/>
        public virtual void TestEvents()
        {
            EventReader reader = new EventReader(new DataInputStream(new ByteArrayInputStream
                                                                         (GetEvents())));
            HistoryEvent e = reader.GetNextEvent();

            NUnit.Framework.Assert.IsTrue(e.GetEventType().Equals(EventType.JobPriorityChanged
                                                                  ));
            NUnit.Framework.Assert.AreEqual("ID", ((JobPriorityChange)e.GetDatum()).jobid.ToString
                                                ());
            e = reader.GetNextEvent();
            NUnit.Framework.Assert.IsTrue(e.GetEventType().Equals(EventType.JobStatusChanged)
                                          );
            NUnit.Framework.Assert.AreEqual("ID", ((JobStatusChanged)e.GetDatum()).jobid.ToString
                                                ());
            e = reader.GetNextEvent();
            NUnit.Framework.Assert.IsTrue(e.GetEventType().Equals(EventType.TaskUpdated));
            NUnit.Framework.Assert.AreEqual("ID", ((TaskUpdated)e.GetDatum()).taskid.ToString
                                                ());
            e = reader.GetNextEvent();
            NUnit.Framework.Assert.IsTrue(e.GetEventType().Equals(EventType.ReduceAttemptKilled
                                                                  ));
            NUnit.Framework.Assert.AreEqual("task_1_2_r03_4", ((TaskAttemptUnsuccessfulCompletion
                                                                )e.GetDatum()).taskid.ToString());
            e = reader.GetNextEvent();
            NUnit.Framework.Assert.IsTrue(e.GetEventType().Equals(EventType.JobKilled));
            NUnit.Framework.Assert.AreEqual("ID", ((JobUnsuccessfulCompletion)e.GetDatum()).jobid
                                            .ToString());
            e = reader.GetNextEvent();
            NUnit.Framework.Assert.IsTrue(e.GetEventType().Equals(EventType.ReduceAttemptStarted
                                                                  ));
            NUnit.Framework.Assert.AreEqual("task_1_2_r03_4", ((TaskAttemptStarted)e.GetDatum
                                                                   ()).taskid.ToString());
            e = reader.GetNextEvent();
            NUnit.Framework.Assert.IsTrue(e.GetEventType().Equals(EventType.ReduceAttemptFinished
                                                                  ));
            NUnit.Framework.Assert.AreEqual("task_1_2_r03_4", ((TaskAttemptFinished)e.GetDatum
                                                                   ()).taskid.ToString());
            e = reader.GetNextEvent();
            NUnit.Framework.Assert.IsTrue(e.GetEventType().Equals(EventType.ReduceAttemptKilled
                                                                  ));
            NUnit.Framework.Assert.AreEqual("task_1_2_r03_4", ((TaskAttemptUnsuccessfulCompletion
                                                                )e.GetDatum()).taskid.ToString());
            e = reader.GetNextEvent();
            NUnit.Framework.Assert.IsTrue(e.GetEventType().Equals(EventType.ReduceAttemptKilled
                                                                  ));
            NUnit.Framework.Assert.AreEqual("task_1_2_r03_4", ((TaskAttemptUnsuccessfulCompletion
                                                                )e.GetDatum()).taskid.ToString());
            e = reader.GetNextEvent();
            NUnit.Framework.Assert.IsTrue(e.GetEventType().Equals(EventType.ReduceAttemptStarted
                                                                  ));
            NUnit.Framework.Assert.AreEqual("task_1_2_r03_4", ((TaskAttemptStarted)e.GetDatum
                                                                   ()).taskid.ToString());
            e = reader.GetNextEvent();
            NUnit.Framework.Assert.IsTrue(e.GetEventType().Equals(EventType.ReduceAttemptFinished
                                                                  ));
            NUnit.Framework.Assert.AreEqual("task_1_2_r03_4", ((TaskAttemptFinished)e.GetDatum
                                                                   ()).taskid.ToString());
            e = reader.GetNextEvent();
            NUnit.Framework.Assert.IsTrue(e.GetEventType().Equals(EventType.ReduceAttemptKilled
                                                                  ));
            NUnit.Framework.Assert.AreEqual("task_1_2_r03_4", ((TaskAttemptUnsuccessfulCompletion
                                                                )e.GetDatum()).taskid.ToString());
            e = reader.GetNextEvent();
            NUnit.Framework.Assert.IsTrue(e.GetEventType().Equals(EventType.ReduceAttemptKilled
                                                                  ));
            NUnit.Framework.Assert.AreEqual("task_1_2_r03_4", ((TaskAttemptUnsuccessfulCompletion
                                                                )e.GetDatum()).taskid.ToString());
            reader.Close();
        }