/// <exception cref="System.Exception"/> public static SchedulerApplication <SchedulerApplicationAttempt> VerifyAppAddedAndRemovedFromScheduler (IDictionary <ApplicationId, SchedulerApplication <SchedulerApplicationAttempt> > applications , EventHandler <SchedulerEvent> handler, string queueName) { ApplicationId appId = ApplicationId.NewInstance(Runtime.CurrentTimeMillis(), 1); AppAddedSchedulerEvent appAddedEvent = new AppAddedSchedulerEvent(appId, queueName , "user"); handler.Handle(appAddedEvent); SchedulerApplication <SchedulerApplicationAttempt> app = applications[appId]; // verify application is added. NUnit.Framework.Assert.IsNotNull(app); NUnit.Framework.Assert.AreEqual("user", app.GetUser()); AppRemovedSchedulerEvent appRemoveEvent = new AppRemovedSchedulerEvent(appId, RMAppState .Finished); handler.Handle(appRemoveEvent); NUnit.Framework.Assert.IsNull(applications[appId]); return(app); }
public override void Handle(SchedulerEvent @event) { switch (@event.GetType()) { case SchedulerEventType.NodeAdded: { NodeAddedSchedulerEvent nodeAddedEvent = (NodeAddedSchedulerEvent)@event; AddNode(nodeAddedEvent.GetAddedRMNode()); RecoverContainersOnNode(nodeAddedEvent.GetContainerReports(), nodeAddedEvent.GetAddedRMNode ()); break; } case SchedulerEventType.NodeRemoved: { NodeRemovedSchedulerEvent nodeRemovedEvent = (NodeRemovedSchedulerEvent)@event; RemoveNode(nodeRemovedEvent.GetRemovedRMNode()); break; } case SchedulerEventType.NodeResourceUpdate: { NodeResourceUpdateSchedulerEvent nodeResourceUpdatedEvent = (NodeResourceUpdateSchedulerEvent )@event; UpdateNodeResource(nodeResourceUpdatedEvent.GetRMNode(), nodeResourceUpdatedEvent .GetResourceOption()); break; } case SchedulerEventType.NodeUpdate: { NodeUpdateSchedulerEvent nodeUpdatedEvent = (NodeUpdateSchedulerEvent)@event; NodeUpdate(nodeUpdatedEvent.GetRMNode()); break; } case SchedulerEventType.AppAdded: { AppAddedSchedulerEvent appAddedEvent = (AppAddedSchedulerEvent)@event; AddApplication(appAddedEvent.GetApplicationId(), appAddedEvent.GetQueue(), appAddedEvent .GetUser(), appAddedEvent.GetIsAppRecovering()); break; } case SchedulerEventType.AppRemoved: { AppRemovedSchedulerEvent appRemovedEvent = (AppRemovedSchedulerEvent)@event; DoneApplication(appRemovedEvent.GetApplicationID(), appRemovedEvent.GetFinalState ()); break; } case SchedulerEventType.AppAttemptAdded: { AppAttemptAddedSchedulerEvent appAttemptAddedEvent = (AppAttemptAddedSchedulerEvent )@event; AddApplicationAttempt(appAttemptAddedEvent.GetApplicationAttemptId(), appAttemptAddedEvent .GetTransferStateFromPreviousAttempt(), appAttemptAddedEvent.GetIsAttemptRecovering ()); break; } case SchedulerEventType.AppAttemptRemoved: { AppAttemptRemovedSchedulerEvent appAttemptRemovedEvent = (AppAttemptRemovedSchedulerEvent )@event; try { DoneApplicationAttempt(appAttemptRemovedEvent.GetApplicationAttemptID(), appAttemptRemovedEvent .GetFinalAttemptState(), appAttemptRemovedEvent.GetKeepContainersAcrossAppAttempts ()); } catch (IOException ie) { Log.Error("Unable to remove application " + appAttemptRemovedEvent.GetApplicationAttemptID (), ie); } break; } case SchedulerEventType.ContainerExpired: { ContainerExpiredSchedulerEvent containerExpiredEvent = (ContainerExpiredSchedulerEvent )@event; ContainerId containerid = containerExpiredEvent.GetContainerId(); CompletedContainer(GetRMContainer(containerid), SchedulerUtils.CreateAbnormalContainerStatus (containerid, SchedulerUtils.ExpiredContainer), RMContainerEventType.Expire); break; } case SchedulerEventType.ContainerRescheduled: { ContainerRescheduledEvent containerRescheduledEvent = (ContainerRescheduledEvent) @event; RMContainer container = containerRescheduledEvent.GetContainer(); RecoverResourceRequestForContainer(container); break; } default: { Log.Error("Invalid eventtype " + @event.GetType() + ". Ignoring!"); break; } } }