Example #1
0
        /// <summary>Prints the application attempt report for an application attempt id.</summary>
        /// <param name="applicationAttemptId"/>
        /// <returns>exitCode</returns>
        /// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/>
        /// <exception cref="System.IO.IOException"/>
        private int PrintApplicationAttemptReport(string applicationAttemptId)
        {
            ApplicationAttemptReport appAttemptReport = null;

            try
            {
                appAttemptReport = client.GetApplicationAttemptReport(ConverterUtils.ToApplicationAttemptId
                                                                          (applicationAttemptId));
            }
            catch (ApplicationNotFoundException)
            {
                sysout.WriteLine("Application for AppAttempt with id '" + applicationAttemptId +
                                 "' doesn't exist in RM or Timeline Server.");
                return(-1);
            }
            catch (ApplicationAttemptNotFoundException)
            {
                sysout.WriteLine("Application Attempt with id '" + applicationAttemptId + "' doesn't exist in RM or Timeline Server."
                                 );
                return(-1);
            }
            // Use PrintWriter.println, which uses correct platform line ending.
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            PrintWriter           appAttemptReportStr = new PrintWriter(new OutputStreamWriter(baos, Sharpen.Extensions.GetEncoding
                                                                                                   ("UTF-8")));

            if (appAttemptReport != null)
            {
                appAttemptReportStr.WriteLine("Application Attempt Report : ");
                appAttemptReportStr.Write("\tApplicationAttempt-Id : ");
                appAttemptReportStr.WriteLine(appAttemptReport.GetApplicationAttemptId());
                appAttemptReportStr.Write("\tState : ");
                appAttemptReportStr.WriteLine(appAttemptReport.GetYarnApplicationAttemptState());
                appAttemptReportStr.Write("\tAMContainer : ");
                appAttemptReportStr.WriteLine(appAttemptReport.GetAMContainerId().ToString());
                appAttemptReportStr.Write("\tTracking-URL : ");
                appAttemptReportStr.WriteLine(appAttemptReport.GetTrackingUrl());
                appAttemptReportStr.Write("\tRPC Port : ");
                appAttemptReportStr.WriteLine(appAttemptReport.GetRpcPort());
                appAttemptReportStr.Write("\tAM Host : ");
                appAttemptReportStr.WriteLine(appAttemptReport.GetHost());
                appAttemptReportStr.Write("\tDiagnostics : ");
                appAttemptReportStr.Write(appAttemptReport.GetDiagnostics());
            }
            else
            {
                appAttemptReportStr.Write("Application Attempt with id '" + applicationAttemptId
                                          + "' doesn't exist in Timeline Server.");
                appAttemptReportStr.Close();
                sysout.WriteLine(baos.ToString("UTF-8"));
                return(-1);
            }
            appAttemptReportStr.Close();
            sysout.WriteLine(baos.ToString("UTF-8"));
            return(0);
        }
Example #2
0
        /// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/>
        /// <exception cref="System.IO.IOException"/>
        private ApplicationAttemptReport MonitorCurrentAppAttempt(ApplicationId appId, YarnApplicationAttemptState
                                                                  attemptState)
        {
            long startTime = Runtime.CurrentTimeMillis();
            ApplicationAttemptId attemptId = null;

            while (true)
            {
                if (attemptId == null)
                {
                    attemptId = rmClient.GetApplicationReport(appId).GetCurrentApplicationAttemptId();
                }
                ApplicationAttemptReport attemptReport = null;
                if (attemptId != null)
                {
                    attemptReport = rmClient.GetApplicationAttemptReport(attemptId);
                    if (attemptState.Equals(attemptReport.GetYarnApplicationAttemptState()))
                    {
                        return(attemptReport);
                    }
                }
                Log.Info("Current attempt state of " + appId + " is " + (attemptReport == null ?
                                                                         " N/A " : attemptReport.GetYarnApplicationAttemptState()) + ", waiting for current attempt to reach "
                         + attemptState);
                try
                {
                    Sharpen.Thread.Sleep(1000);
                }
                catch (Exception)
                {
                    Log.Warn("Interrupted while waiting for current attempt of " + appId + " to reach "
                             + attemptState);
                }
                if (Runtime.CurrentTimeMillis() - startTime > AmStateWaitTimeoutMs)
                {
                    string errmsg = "Timeout for waiting current attempt of " + appId + " to reach "
                                    + attemptState;
                    Log.Error(errmsg);
                    throw new RuntimeException(errmsg);
                }
            }
        }
Example #3
0
 public AppAttemptInfo(ApplicationAttemptReport appAttempt)
 {
     // JAXB needs this
     appAttemptId        = appAttempt.GetApplicationAttemptId().ToString();
     host                = appAttempt.GetHost();
     rpcPort             = appAttempt.GetRpcPort();
     trackingUrl         = appAttempt.GetTrackingUrl();
     originalTrackingUrl = appAttempt.GetOriginalTrackingUrl();
     diagnosticsInfo     = appAttempt.GetDiagnostics();
     appAttemptState     = appAttempt.GetYarnApplicationAttemptState();
     if (appAttempt.GetAMContainerId() != null)
     {
         amContainerId = appAttempt.GetAMContainerId().ToString();
     }
 }