Ejemplo n.º 1
0
 /// <exception cref="System.IO.IOException"/>
 private void DoneApplicationAttempt(ApplicationAttemptId applicationAttemptId, RMAppAttemptState
                                     rmAppAttemptFinalState, bool keepContainers)
 {
     lock (this)
     {
         FiCaSchedulerApp attempt = GetApplicationAttempt(applicationAttemptId);
         SchedulerApplication <FiCaSchedulerApp> application = applications[applicationAttemptId
                                                                            .GetApplicationId()];
         if (application == null || attempt == null)
         {
             throw new IOException("Unknown application " + applicationAttemptId + " has completed!"
                                   );
         }
         // Kill all 'live' containers
         foreach (RMContainer container in attempt.GetLiveContainers())
         {
             if (keepContainers && container.GetState().Equals(RMContainerState.Running))
             {
                 // do not kill the running container in the case of work-preserving AM
                 // restart.
                 Log.Info("Skip killing " + container.GetContainerId());
                 continue;
             }
             CompletedContainer(container, SchedulerUtils.CreateAbnormalContainerStatus(container
                                                                                        .GetContainerId(), SchedulerUtils.CompletedApplication), RMContainerEventType.Kill
                                );
         }
         // Clean up pending requests, metrics etc.
         attempt.Stop(rmAppAttemptFinalState);
     }
 }
Ejemplo n.º 2
0
 public virtual void AddApplicationAttempt(ApplicationAttemptId appAttemptId, bool
                                           transferStateFromPreviousAttempt, bool isAttemptRecovering)
 {
     lock (this)
     {
         SchedulerApplication <FiCaSchedulerApp> application = applications[appAttemptId.GetApplicationId
                                                                                ()];
         string user = application.GetUser();
         // TODO: Fix store
         FiCaSchedulerApp schedulerApp = new FiCaSchedulerApp(appAttemptId, user, DefaultQueue
                                                              , activeUsersManager, this.rmContext);
         if (transferStateFromPreviousAttempt)
         {
             schedulerApp.TransferStateFromPreviousAttempt(application.GetCurrentAppAttempt());
         }
         application.SetCurrentAppAttempt(schedulerApp);
         metrics.SubmitAppAttempt(user);
         Log.Info("Added Application Attempt " + appAttemptId + " to scheduler from user "
                  + application.GetUser());
         if (isAttemptRecovering)
         {
             if (Log.IsDebugEnabled())
             {
                 Log.Debug(appAttemptId + " is recovering. Skipping notifying ATTEMPT_ADDED");
             }
         }
         else
         {
             rmContext.GetDispatcher().GetEventHandler().Handle(new RMAppAttemptEvent(appAttemptId
                                                                                      , RMAppAttemptEventType.AttemptAdded));
         }
     }
 }
Ejemplo n.º 3
0
 public virtual void AddApplication(ApplicationId applicationId, string queue, string
                                    user, bool isAppRecovering)
 {
     lock (this)
     {
         SchedulerApplication <FiCaSchedulerApp> application = new SchedulerApplication <FiCaSchedulerApp
                                                                                         >(DefaultQueue, user);
         applications[applicationId] = application;
         metrics.SubmitApp(user);
         Log.Info("Accepted application " + applicationId + " from user: "******", currently num of applications: "
                  + applications.Count);
         if (isAppRecovering)
         {
             if (Log.IsDebugEnabled())
             {
                 Log.Debug(applicationId + " is recovering. Skip notifying APP_ACCEPTED");
             }
         }
         else
         {
             rmContext.GetDispatcher().GetEventHandler().Handle(new RMAppEvent(applicationId,
                                                                               RMAppEventType.AppAccepted));
         }
     }
 }
Ejemplo n.º 4
0
 private void DoneApplication(ApplicationId applicationId, RMAppState finalState)
 {
     lock (this)
     {
         SchedulerApplication <FiCaSchedulerApp> application = applications[applicationId];
         if (application == null)
         {
             Log.Warn("Couldn't find application " + applicationId);
             return;
         }
         // Inform the activeUsersManager
         activeUsersManager.DeactivateApplication(application.GetUser(), applicationId);
         application.Stop(finalState);
         Sharpen.Collections.Remove(applications, applicationId);
     }
 }
Ejemplo n.º 5
0
        /// <exception cref="System.Exception"/>
        private void CheckAppQueue(MockRM resourceManager, string user, string submissionQueue
                                   , string expected)
        {
            RMApp app = resourceManager.SubmitApp(200, "name", user, new Dictionary <ApplicationAccessType
                                                                                     , string>(), false, submissionQueue, -1, null, "MAPREDUCE", false);
            RMAppState expectedState = expected.IsEmpty() ? RMAppState.Failed : RMAppState.Accepted;

            resourceManager.WaitForState(app.GetApplicationId(), expectedState);
            // get scheduler app
            CapacityScheduler    cs           = (CapacityScheduler)resourceManager.GetResourceScheduler();
            SchedulerApplication schedulerApp = cs.GetSchedulerApplications()[app.GetApplicationId
                                                                                  ()];
            string queue = string.Empty;

            if (schedulerApp != null)
            {
                queue = schedulerApp.GetQueue().GetQueueName();
            }
            NUnit.Framework.Assert.IsTrue("expected " + expected + " actual " + queue, expected
                                          .Equals(queue));
            NUnit.Framework.Assert.AreEqual(expected, app.GetQueue());
        }