/// <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"); } }
/* * 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(); }
public JobHistoryEvent(JobId jobID, HistoryEvent historyEvent, long timestamp) : base(historyEvent.GetEventType(), timestamp) { this.jobID = jobID; this.historyEvent = historyEvent; }
public virtual void HandleEvent(HistoryEvent @event) { EventType type = @event.GetEventType(); switch (type) { case EventType.JobSubmitted: { HandleJobSubmittedEvent((JobSubmittedEvent)@event); break; } case EventType.JobStatusChanged: { break; } case EventType.JobInfoChanged: { HandleJobInfoChangeEvent((JobInfoChangeEvent)@event); break; } case EventType.JobInited: { HandleJobInitedEvent((JobInitedEvent)@event); break; } case EventType.JobPriorityChanged: { HandleJobPriorityChangeEvent((JobPriorityChangeEvent)@event); break; } case EventType.JobQueueChanged: { HandleJobQueueChangeEvent((JobQueueChangeEvent)@event); break; } case EventType.JobFailed: case EventType.JobKilled: case EventType.JobError: { HandleJobFailedEvent((JobUnsuccessfulCompletionEvent)@event); break; } case EventType.JobFinished: { HandleJobFinishedEvent((JobFinishedEvent)@event); break; } case EventType.TaskStarted: { HandleTaskStartedEvent((TaskStartedEvent)@event); break; } case EventType.TaskFailed: { HandleTaskFailedEvent((TaskFailedEvent)@event); break; } case EventType.TaskUpdated: { HandleTaskUpdatedEvent((TaskUpdatedEvent)@event); break; } case EventType.TaskFinished: { HandleTaskFinishedEvent((TaskFinishedEvent)@event); break; } case EventType.MapAttemptStarted: case EventType.CleanupAttemptStarted: case EventType.ReduceAttemptStarted: case EventType.SetupAttemptStarted: { HandleTaskAttemptStartedEvent((TaskAttemptStartedEvent)@event); break; } case EventType.MapAttemptFailed: case EventType.CleanupAttemptFailed: case EventType.ReduceAttemptFailed: case EventType.SetupAttemptFailed: case EventType.MapAttemptKilled: case EventType.CleanupAttemptKilled: case EventType.ReduceAttemptKilled: case EventType.SetupAttemptKilled: { HandleTaskAttemptFailedEvent((TaskAttemptUnsuccessfulCompletionEvent)@event); break; } case EventType.MapAttemptFinished: { HandleMapAttemptFinishedEvent((MapAttemptFinishedEvent)@event); break; } case EventType.ReduceAttemptFinished: { HandleReduceAttemptFinishedEvent((ReduceAttemptFinishedEvent)@event); break; } case EventType.SetupAttemptFinished: case EventType.CleanupAttemptFinished: { HandleTaskAttemptFinishedEvent((TaskAttemptFinishedEvent)@event); break; } case EventType.AmStarted: { HandleAMStartedEvent((AMStartedEvent)@event); break; } default: { break; } } }