示例#1
0
 /// <exception cref="System.IO.IOException"/>
 internal virtual void Write(HistoryEvent @event)
 {
     lock (this)
     {
         Event wrapper = new Event();
         wrapper.type   = @event.GetEventType();
         wrapper.@event = @event.GetDatum();
         writer.Write(wrapper, encoder);
         encoder.Flush();
         @out.WriteBytes("\n");
     }
 }
示例#2
0
        /*
         * 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();
        }