public AppAttemptRemovedSchedulerEvent(ApplicationAttemptId applicationAttemptId,
                                        RMAppAttemptState finalAttemptState, bool keepContainers)
     : base(SchedulerEventType.AppAttemptRemoved)
 {
     this.applicationAttemptId            = applicationAttemptId;
     this.finalAttemptState               = finalAttemptState;
     this.keepContainersAcrossAppAttempts = keepContainers;
 }
Example #2
0
 public virtual void Stop(RMAppAttemptState rmAppAttemptFinalState)
 {
     lock (this)
     {
         // Cleanup all scheduling information
         isStopped = true;
         appSchedulingInfo.Stop(rmAppAttemptFinalState);
     }
 }
 public override void SetState(RMAppAttemptState state)
 {
     MaybeInitBuilder();
     if (state == null)
     {
         builder.ClearAppAttemptState();
         return;
     }
     builder.SetAppAttemptState(ConvertToProtoFormat(state));
 }
Example #4
0
 public virtual void AppAttemptFinished(RMAppAttempt appAttempt, RMAppAttemptState
                                        appAttemtpState, RMApp app, long finishedTime)
 {
     if (publishSystemMetrics)
     {
         dispatcher.GetEventHandler().Handle(new AppAttemptFinishedEvent(appAttempt.GetAppAttemptId
                                                                             (), appAttempt.GetTrackingUrl(), appAttempt.GetOriginalTrackingUrl(), appAttempt
                                                                         .GetDiagnostics(), app.GetFinalApplicationStatus(), RMServerUtils.CreateApplicationAttemptState
                                                                             (appAttemtpState), finishedTime));
     }
 }
 public virtual void ApplicationAttemptFinished(RMAppAttempt appAttempt, RMAppAttemptState
                                                finalState)
 {
     if (historyServiceEnabled)
     {
         dispatcher.GetEventHandler().Handle(new WritingApplicationAttemptFinishEvent(appAttempt
                                                                                      .GetAppAttemptId(), ApplicationAttemptFinishData.NewInstance(appAttempt.GetAppAttemptId
                                                                                                                                                       (), appAttempt.GetDiagnostics().ToString(), appAttempt.GetTrackingUrl(), appAttempt
                                                                                                                                                   .GetFinalApplicationStatus(), RMServerUtils.CreateApplicationAttemptState(finalState
                                                                                                                                                                                                                             ))));
     }
 }
Example #6
0
 /// <exception cref="System.Exception"/>
 private void FailOverAndKillApp(ApplicationId appId, ApplicationAttemptId appAttemptId
                                 , RMAppState initialRMAppState, RMAppAttemptState initialRMAppAttemptState, RMAppState
                                 expectedAppStateBeforeKillApp)
 {
     NUnit.Framework.Assert.AreEqual(initialRMAppState, rm1.GetRMContext().GetRMApps()
                                     [appId].GetState());
     NUnit.Framework.Assert.AreEqual(initialRMAppAttemptState, rm1.GetRMContext().GetRMApps
                                         ()[appId].GetAppAttempts()[appAttemptId].GetState());
     ExplicitFailover();
     NUnit.Framework.Assert.AreEqual(expectedAppStateBeforeKillApp, rm2.GetRMContext()
                                     .GetRMApps()[appId].GetState());
     KillApplication(rm2, appId, appAttemptId, initialRMAppState);
 }
Example #7
0
        /// <exception cref="System.Exception"/>
        public virtual void WaitForState(RMAppAttemptState finalState)
        {
            RMApp        app         = context.GetRMApps()[attemptId.GetApplicationId()];
            RMAppAttempt attempt     = app.GetRMAppAttempt(attemptId);
            int          timeoutSecs = 0;

            while (!finalState.Equals(attempt.GetAppAttemptState()) && timeoutSecs++ < 40)
            {
                System.Console.Out.WriteLine("AppAttempt : " + attemptId + " State is : " + attempt
                                             .GetAppAttemptState() + " Waiting for state : " + finalState);
                Sharpen.Thread.Sleep(1000);
            }
            System.Console.Out.WriteLine("AppAttempt State is : " + attempt.GetAppAttemptState
                                             ());
            NUnit.Framework.Assert.AreEqual("AppAttempt state is not correct (timedout)", finalState
                                            , attempt.GetAppAttemptState());
        }
Example #8
0
 public virtual void Stop(RMAppAttemptState rmAppAttemptFinalState)
 {
     lock (this)
     {
         // clear pending resources metrics for the application
         QueueMetrics metrics = queue.GetMetrics();
         foreach (IDictionary <string, ResourceRequest> asks in requests.Values)
         {
             ResourceRequest request = asks[ResourceRequest.Any];
             if (request != null)
             {
                 metrics.DecrPendingResources(user, request.GetNumContainers(), request.GetCapability
                                                  ());
             }
         }
         metrics.FinishAppAttempt(applicationId, pending, user);
         // Clear requests themselves
         ClearRequests();
     }
 }
 public override void ApplicationAttemptFinished(RMAppAttempt appAttempt, RMAppAttemptState
                                                 finalState)
 {
 }
Example #10
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);
     }
 }
 public abstract void SetState(RMAppAttemptState state);
        /*
         * Contains the state data that needs to be persisted for an ApplicationAttempt
         */
        public static ApplicationAttemptStateData NewInstance(ApplicationAttemptId attemptId
                                                              , Container container, Credentials attemptTokens, long startTime, RMAppAttemptState
                                                              finalState, string finalTrackingUrl, string diagnostics, FinalApplicationStatus
                                                              amUnregisteredFinalStatus, int exitStatus, long finishTime, long memorySeconds,
                                                              long vcoreSeconds)
        {
            ApplicationAttemptStateData attemptStateData = Org.Apache.Hadoop.Yarn.Util.Records
                                                           .NewRecord <ApplicationAttemptStateData>();

            attemptStateData.SetAttemptId(attemptId);
            attemptStateData.SetMasterContainer(container);
            attemptStateData.SetAppAttemptTokens(attemptTokens);
            attemptStateData.SetState(finalState);
            attemptStateData.SetFinalTrackingUrl(finalTrackingUrl);
            attemptStateData.SetDiagnostics(diagnostics == null ? string.Empty : diagnostics);
            attemptStateData.SetStartTime(startTime);
            attemptStateData.SetFinalApplicationStatus(amUnregisteredFinalStatus);
            attemptStateData.SetAMContainerExitStatus(exitStatus);
            attemptStateData.SetFinishTime(finishTime);
            attemptStateData.SetMemorySeconds(memorySeconds);
            attemptStateData.SetVcoreSeconds(vcoreSeconds);
            return(attemptStateData);
        }
 public static RMAppAttemptState ConvertFromProtoFormat(YarnServerResourceManagerRecoveryProtos.RMAppAttemptStateProto
                                                        e)
 {
     return(RMAppAttemptState.ValueOf(e.ToString().Replace(RmAppAttemptPrefix, string.Empty
                                                           )));
 }
 public static YarnServerResourceManagerRecoveryProtos.RMAppAttemptStateProto ConvertToProtoFormat
     (RMAppAttemptState e)
 {
     return(YarnServerResourceManagerRecoveryProtos.RMAppAttemptStateProto.ValueOf(RmAppAttemptPrefix
                                                                                   + e.ToString()));
 }
Example #15
0
        public static YarnApplicationAttemptState CreateApplicationAttemptState(RMAppAttemptState
                                                                                rmAppAttemptState)
        {
            switch (rmAppAttemptState)
            {
            case RMAppAttemptState.New:
            {
                return(YarnApplicationAttemptState.New);
            }

            case RMAppAttemptState.Submitted:
            {
                return(YarnApplicationAttemptState.Submitted);
            }

            case RMAppAttemptState.Scheduled:
            {
                return(YarnApplicationAttemptState.Scheduled);
            }

            case RMAppAttemptState.Allocated:
            {
                return(YarnApplicationAttemptState.Allocated);
            }

            case RMAppAttemptState.Launched:
            {
                return(YarnApplicationAttemptState.Launched);
            }

            case RMAppAttemptState.AllocatedSaving:
            case RMAppAttemptState.LaunchedUnmanagedSaving:
            {
                return(YarnApplicationAttemptState.AllocatedSaving);
            }

            case RMAppAttemptState.Running:
            {
                return(YarnApplicationAttemptState.Running);
            }

            case RMAppAttemptState.Finishing:
            {
                return(YarnApplicationAttemptState.Finishing);
            }

            case RMAppAttemptState.Finished:
            {
                return(YarnApplicationAttemptState.Finished);
            }

            case RMAppAttemptState.Killed:
            {
                return(YarnApplicationAttemptState.Killed);
            }

            case RMAppAttemptState.Failed:
            {
                return(YarnApplicationAttemptState.Failed);
            }

            default:
            {
                throw new YarnRuntimeException("Unknown state passed!");
            }
            }
        }
Example #16
0
 /// <exception cref="System.Exception"/>
 public virtual void WaitForState(ApplicationAttemptId attemptId, RMAppAttemptState
                                  finalState)
 {
     WaitForState(attemptId, finalState, 40000);
 }