コード例 #1
0
ファイル: AppInfo.cs プロジェクト: orf53975/hadoop.net
 public AppInfo(ApplicationReport app)
 {
     // JAXB needs this
     appId = app.GetApplicationId().ToString();
     if (app.GetCurrentApplicationAttemptId() != null)
     {
         currentAppAttemptId = app.GetCurrentApplicationAttemptId().ToString();
     }
     user                = app.GetUser();
     queue               = app.GetQueue();
     name                = app.GetName();
     type                = app.GetApplicationType();
     host                = app.GetHost();
     rpcPort             = app.GetRpcPort();
     appState            = app.GetYarnApplicationState();
     diagnosticsInfo     = app.GetDiagnostics();
     trackingUrl         = app.GetTrackingUrl();
     originalTrackingUrl = app.GetOriginalTrackingUrl();
     submittedTime       = app.GetStartTime();
     startedTime         = app.GetStartTime();
     finishedTime        = app.GetFinishTime();
     elapsedTime         = Times.Elapsed(startedTime, finishedTime);
     finalAppStatus      = app.GetFinalApplicationStatus();
     progress            = app.GetProgress() * 100;
     // in percent
     if (app.GetApplicationTags() != null && !app.GetApplicationTags().IsEmpty())
     {
         this.applicationTags = StringHelper.CsvJoiner.Join(app.GetApplicationTags());
     }
 }
コード例 #2
0
ファイル: TypeConverter.cs プロジェクト: orf53975/hadoop.net
        public static JobStatus FromYarn(ApplicationReport application, string jobFile)
        {
            string trackingUrl = application.GetTrackingUrl();

            trackingUrl = trackingUrl == null ? string.Empty : trackingUrl;
            JobStatus jobStatus = new JobStatus(TypeConverter.FromYarn(application.GetApplicationId
                                                                           ()), 0.0f, 0.0f, 0.0f, 0.0f, TypeConverter.FromYarn(application.GetYarnApplicationState
                                                                                                                                   (), application.GetFinalApplicationStatus()), JobPriority.Normal, application.GetUser
                                                    (), application.GetName(), application.GetQueue(), jobFile, trackingUrl, false);

            jobStatus.SetSchedulingInfo(trackingUrl);
            // Set AM tracking url
            jobStatus.SetStartTime(application.GetStartTime());
            jobStatus.SetFinishTime(application.GetFinishTime());
            jobStatus.SetFailureInfo(application.GetDiagnostics());
            ApplicationResourceUsageReport resourceUsageReport = application.GetApplicationResourceUsageReport
                                                                     ();

            if (resourceUsageReport != null)
            {
                jobStatus.SetNeededMem(resourceUsageReport.GetNeededResources().GetMemory());
                jobStatus.SetNumReservedSlots(resourceUsageReport.GetNumReservedContainers());
                jobStatus.SetNumUsedSlots(resourceUsageReport.GetNumUsedContainers());
                jobStatus.SetReservedMem(resourceUsageReport.GetReservedResources().GetMemory());
                jobStatus.SetUsedMem(resourceUsageReport.GetUsedResources().GetMemory());
            }
            return(jobStatus);
        }
コード例 #3
0
 /// <summary>Monitor the submitted application for completion.</summary>
 /// <remarks>
 /// Monitor the submitted application for completion.
 /// Kill application if time expires.
 /// </remarks>
 /// <param name="appId">Application Id of application to be monitored</param>
 /// <returns>true if application completed successfully</returns>
 /// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/>
 /// <exception cref="System.IO.IOException"/>
 private bool MonitorApplication(ApplicationId appId)
 {
     while (true)
     {
         // Check app status every 1 second.
         try
         {
             Sharpen.Thread.Sleep(1000);
         }
         catch (Exception)
         {
             Log.Debug("Thread sleep in monitoring loop interrupted");
         }
         // Get application report for the appId we are interested in
         ApplicationReport report = yarnClient.GetApplicationReport(appId);
         Log.Info("Got application report from ASM for" + ", appId=" + appId.GetId() + ", clientToAMToken="
                  + report.GetClientToAMToken() + ", appDiagnostics=" + report.GetDiagnostics() +
                  ", appMasterHost=" + report.GetHost() + ", appQueue=" + report.GetQueue() + ", appMasterRpcPort="
                  + report.GetRpcPort() + ", appStartTime=" + report.GetStartTime() + ", yarnAppState="
                  + report.GetYarnApplicationState().ToString() + ", distributedFinalState=" + report
                  .GetFinalApplicationStatus().ToString() + ", appTrackingUrl=" + report.GetTrackingUrl
                      () + ", appUser="******"Application has completed successfully. Breaking monitoring loop");
                 return(true);
             }
             else
             {
                 Log.Info("Application did finished unsuccessfully." + " YarnState=" + state.ToString
                              () + ", DSFinalStatus=" + dsStatus.ToString() + ". Breaking monitoring loop");
                 return(false);
             }
         }
         else
         {
             if (YarnApplicationState.Killed == state || YarnApplicationState.Failed == state)
             {
                 Log.Info("Application did not finish." + " YarnState=" + state.ToString() + ", DSFinalStatus="
                          + dsStatus.ToString() + ". Breaking monitoring loop");
                 return(false);
             }
         }
         if (Runtime.CurrentTimeMillis() > (clientStartTime + clientTimeout))
         {
             Log.Info("Reached client specified timeout for application. Killing application");
             ForceKillApplication(appId);
             return(false);
         }
     }
 }
コード例 #4
0
        /// <exception cref="System.IO.IOException"/>
        public virtual GetJobReportResponse GetJobReport(GetJobReportRequest request)
        {
            JobReport jobReport = recordFactory.NewRecordInstance <JobReport>();

            jobReport.SetJobId(request.GetJobId());
            jobReport.SetJobState(jobState);
            jobReport.SetUser(applicationReport.GetUser());
            jobReport.SetStartTime(applicationReport.GetStartTime());
            jobReport.SetDiagnostics(applicationReport.GetDiagnostics());
            jobReport.SetJobName(applicationReport.GetName());
            jobReport.SetTrackingUrl(applicationReport.GetTrackingUrl());
            jobReport.SetFinishTime(applicationReport.GetFinishTime());
            GetJobReportResponse resp = recordFactory.NewRecordInstance <GetJobReportResponse>
                                            ();

            resp.SetJobReport(jobReport);
            return(resp);
        }
コード例 #5
0
        /// <summary>Monitor the submitted application for completion.</summary>
        /// <remarks>
        /// Monitor the submitted application for completion. Kill application if time
        /// expires.
        /// </remarks>
        /// <param name="appId">Application Id of application to be monitored</param>
        /// <returns>true if application completed successfully</returns>
        /// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/>
        /// <exception cref="System.IO.IOException"/>
        private ApplicationReport MonitorApplication(ApplicationId appId, ICollection <YarnApplicationState
                                                                                       > finalState)
        {
            long          foundAMCompletedTime = 0;
            StringBuilder expectedFinalState   = new StringBuilder();
            bool          first = true;

            foreach (YarnApplicationState state in finalState)
            {
                if (first)
                {
                    first = false;
                    expectedFinalState.Append(state.ToString());
                }
                else
                {
                    expectedFinalState.Append("," + state.ToString());
                }
            }
            while (true)
            {
                // Check app status every 1 second.
                try
                {
                    Sharpen.Thread.Sleep(1000);
                }
                catch (Exception)
                {
                    Log.Debug("Thread sleep in monitoring loop interrupted");
                }
                // Get application report for the appId we are interested in
                ApplicationReport report = rmClient.GetApplicationReport(appId);
                Log.Info("Got application report from ASM for" + ", appId=" + appId.GetId() + ", appAttemptId="
                         + report.GetCurrentApplicationAttemptId() + ", clientToAMToken=" + report.GetClientToAMToken
                             () + ", appDiagnostics=" + report.GetDiagnostics() + ", appMasterHost=" + report
                         .GetHost() + ", appQueue=" + report.GetQueue() + ", appMasterRpcPort=" + report.
                         GetRpcPort() + ", appStartTime=" + report.GetStartTime() + ", yarnAppState=" + report
                         .GetYarnApplicationState().ToString() + ", distributedFinalState=" + report.GetFinalApplicationStatus
                             ().ToString() + ", appTrackingUrl=" + report.GetTrackingUrl() + ", appUser="******"Waited " + AmStateWaitTimeoutMs / 1000 + " seconds after process completed for AppReport"
                                     + " to reach desired final state. Not waiting anymore." + "CurrentState = " + state_1
                                     + ", ExpectedStates = " + expectedFinalState.ToString());
                            throw new RuntimeException("Failed to receive final expected state" + " in ApplicationReport"
                                                       + ", CurrentState=" + state_1 + ", ExpectedStates=" + expectedFinalState.ToString
                                                           ());
                        }
                    }
                }
            }
        }
コード例 #6
0
        /// <summary>Prints the application report for an application id.</summary>
        /// <param name="applicationId"/>
        /// <returns>exitCode</returns>
        /// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/>
        /// <exception cref="System.IO.IOException"/>
        private int PrintApplicationReport(string applicationId)
        {
            ApplicationReport appReport = null;

            try
            {
                appReport = client.GetApplicationReport(ConverterUtils.ToApplicationId(applicationId
                                                                                       ));
            }
            catch (ApplicationNotFoundException)
            {
                sysout.WriteLine("Application with id '" + applicationId + "' doesn't exist in RM or Timeline Server."
                                 );
                return(-1);
            }
            // Use PrintWriter.println, which uses correct platform line ending.
            ByteArrayOutputStream baos         = new ByteArrayOutputStream();
            PrintWriter           appReportStr = new PrintWriter(new OutputStreamWriter(baos, Sharpen.Extensions.GetEncoding
                                                                                            ("UTF-8")));

            if (appReport != null)
            {
                appReportStr.WriteLine("Application Report : ");
                appReportStr.Write("\tApplication-Id : ");
                appReportStr.WriteLine(appReport.GetApplicationId());
                appReportStr.Write("\tApplication-Name : ");
                appReportStr.WriteLine(appReport.GetName());
                appReportStr.Write("\tApplication-Type : ");
                appReportStr.WriteLine(appReport.GetApplicationType());
                appReportStr.Write("\tUser : "******"\tQueue : ");
                appReportStr.WriteLine(appReport.GetQueue());
                appReportStr.Write("\tStart-Time : ");
                appReportStr.WriteLine(appReport.GetStartTime());
                appReportStr.Write("\tFinish-Time : ");
                appReportStr.WriteLine(appReport.GetFinishTime());
                appReportStr.Write("\tProgress : ");
                DecimalFormat formatter = new DecimalFormat("###.##%");
                string        progress  = formatter.Format(appReport.GetProgress());
                appReportStr.WriteLine(progress);
                appReportStr.Write("\tState : ");
                appReportStr.WriteLine(appReport.GetYarnApplicationState());
                appReportStr.Write("\tFinal-State : ");
                appReportStr.WriteLine(appReport.GetFinalApplicationStatus());
                appReportStr.Write("\tTracking-URL : ");
                appReportStr.WriteLine(appReport.GetOriginalTrackingUrl());
                appReportStr.Write("\tRPC Port : ");
                appReportStr.WriteLine(appReport.GetRpcPort());
                appReportStr.Write("\tAM Host : ");
                appReportStr.WriteLine(appReport.GetHost());
                appReportStr.Write("\tAggregate Resource Allocation : ");
                ApplicationResourceUsageReport usageReport = appReport.GetApplicationResourceUsageReport
                                                                 ();
                if (usageReport != null)
                {
                    //completed app report in the timeline server doesn't have usage report
                    appReportStr.Write(usageReport.GetMemorySeconds() + " MB-seconds, ");
                    appReportStr.WriteLine(usageReport.GetVcoreSeconds() + " vcore-seconds");
                }
                else
                {
                    appReportStr.WriteLine("N/A");
                }
                appReportStr.Write("\tDiagnostics : ");
                appReportStr.Write(appReport.GetDiagnostics());
            }
            else
            {
                appReportStr.Write("Application with id '" + applicationId + "' doesn't exist in RM."
                                   );
                appReportStr.Close();
                sysout.WriteLine(baos.ToString("UTF-8"));
                return(-1);
            }
            appReportStr.Close();
            sysout.WriteLine(baos.ToString("UTF-8"));
            return(0);
        }