コード例 #1
0
 /// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/>
 /// <exception cref="System.IO.IOException"/>
 private ApplicationHistoryManagerOnTimelineStore.ApplicationReportExt GenerateApplicationReport
     (TimelineEntity entity, ApplicationHistoryManagerOnTimelineStore.ApplicationReportField
     field)
 {
     ApplicationHistoryManagerOnTimelineStore.ApplicationReportExt app = ConvertToApplicationReport
                                                                             (entity, field);
     // If only user and acls are pulled to check attempt(s)/container(s) access
     // control, we can return immediately
     if (field == ApplicationHistoryManagerOnTimelineStore.ApplicationReportField.UserAndAcls)
     {
         return(app);
     }
     try
     {
         CheckAccess(app);
         if (app.appReport.GetCurrentApplicationAttemptId() != null)
         {
             ApplicationAttemptReport appAttempt = GetApplicationAttempt(app.appReport.GetCurrentApplicationAttemptId
                                                                             (), false);
             app.appReport.SetHost(appAttempt.GetHost());
             app.appReport.SetRpcPort(appAttempt.GetRpcPort());
             app.appReport.SetTrackingUrl(appAttempt.GetTrackingUrl());
             app.appReport.SetOriginalTrackingUrl(appAttempt.GetOriginalTrackingUrl());
         }
     }
     catch (Exception)
     {
         // AuthorizationException is thrown because the user doesn't have access
         // It's possible that the app is finished before the first attempt is created.
         app.appReport.SetDiagnostics(null);
         app.appReport.SetCurrentApplicationAttemptId(null);
     }
     if (app.appReport.GetCurrentApplicationAttemptId() == null)
     {
         app.appReport.SetCurrentApplicationAttemptId(ApplicationAttemptId.NewInstance(app
                                                                                       .appReport.GetApplicationId(), -1));
     }
     if (app.appReport.GetHost() == null)
     {
         app.appReport.SetHost(Unavailable);
     }
     if (app.appReport.GetRpcPort() < 0)
     {
         app.appReport.SetRpcPort(-1);
     }
     if (app.appReport.GetTrackingUrl() == null)
     {
         app.appReport.SetTrackingUrl(Unavailable);
     }
     if (app.appReport.GetOriginalTrackingUrl() == null)
     {
         app.appReport.SetOriginalTrackingUrl(Unavailable);
     }
     if (app.appReport.GetDiagnostics() == null)
     {
         app.appReport.SetDiagnostics(string.Empty);
     }
     return(app);
 }
コード例 #2
0
        /// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/>
        /// <exception cref="System.IO.IOException"/>
        private ApplicationHistoryManagerOnTimelineStore.ApplicationReportExt GetApplication
            (ApplicationId appId, ApplicationHistoryManagerOnTimelineStore.ApplicationReportField
            field)
        {
            TimelineEntity entity = timelineDataManager.GetEntity(ApplicationMetricsConstants
                                                                  .EntityType, appId.ToString(), EnumSet.AllOf <TimelineReader.Field>(), UserGroupInformation
                                                                  .GetLoginUser());

            if (entity == null)
            {
                throw new ApplicationNotFoundException("The entity for application " + appId + " doesn't exist in the timeline store"
                                                       );
            }
            else
            {
                return(GenerateApplicationReport(entity, field));
            }
        }
コード例 #3
0
        private static ApplicationHistoryManagerOnTimelineStore.ApplicationReportExt ConvertToApplicationReport
            (TimelineEntity entity, ApplicationHistoryManagerOnTimelineStore.ApplicationReportField
            field)
        {
            string user         = null;
            string queue        = null;
            string name         = null;
            string type         = null;
            long   createdTime  = 0;
            long   finishedTime = 0;
            ApplicationAttemptId latestApplicationAttemptId = null;
            string diagnosticsInfo = null;
            FinalApplicationStatus         finalStatus              = FinalApplicationStatus.Undefined;
            YarnApplicationState           state                    = null;
            ApplicationResourceUsageReport appResources             = null;
            IDictionary <ApplicationAccessType, string> appViewACLs = new Dictionary <ApplicationAccessType
                                                                                      , string>();
            IDictionary <string, object> entityInfo = entity.GetOtherInfo();

            if (entityInfo != null)
            {
                if (entityInfo.Contains(ApplicationMetricsConstants.UserEntityInfo))
                {
                    user = entityInfo[ApplicationMetricsConstants.UserEntityInfo].ToString();
                }
                if (entityInfo.Contains(ApplicationMetricsConstants.AppViewAclsEntityInfo))
                {
                    string appViewACLsStr = entityInfo[ApplicationMetricsConstants.AppViewAclsEntityInfo
                                            ].ToString();
                    if (appViewACLsStr.Length > 0)
                    {
                        appViewACLs[ApplicationAccessType.ViewApp] = appViewACLsStr;
                    }
                }
                if (field == ApplicationHistoryManagerOnTimelineStore.ApplicationReportField.UserAndAcls)
                {
                    return(new ApplicationHistoryManagerOnTimelineStore.ApplicationReportExt(ApplicationReport
                                                                                             .NewInstance(ConverterUtils.ToApplicationId(entity.GetEntityId()), latestApplicationAttemptId
                                                                                                          , user, queue, name, null, -1, null, state, diagnosticsInfo, null, createdTime,
                                                                                                          finishedTime, finalStatus, null, null, 1.0F, type, null), appViewACLs));
                }
                if (entityInfo.Contains(ApplicationMetricsConstants.QueueEntityInfo))
                {
                    queue = entityInfo[ApplicationMetricsConstants.QueueEntityInfo].ToString();
                }
                if (entityInfo.Contains(ApplicationMetricsConstants.NameEntityInfo))
                {
                    name = entityInfo[ApplicationMetricsConstants.NameEntityInfo].ToString();
                }
                if (entityInfo.Contains(ApplicationMetricsConstants.TypeEntityInfo))
                {
                    type = entityInfo[ApplicationMetricsConstants.TypeEntityInfo].ToString();
                }
                if (entityInfo.Contains(ApplicationMetricsConstants.AppCpuMetrics))
                {
                    long vcoreSeconds = long.Parse(entityInfo[ApplicationMetricsConstants.AppCpuMetrics
                                                   ].ToString());
                    long memorySeconds = long.Parse(entityInfo[ApplicationMetricsConstants.AppMemMetrics
                                                    ].ToString());
                    appResources = ApplicationResourceUsageReport.NewInstance(0, 0, null, null, null,
                                                                              memorySeconds, vcoreSeconds);
                }
            }
            IList <TimelineEvent> events = entity.GetEvents();

            if (events != null)
            {
                foreach (TimelineEvent @event in events)
                {
                    if (@event.GetEventType().Equals(ApplicationMetricsConstants.CreatedEventType))
                    {
                        createdTime = @event.GetTimestamp();
                    }
                    else
                    {
                        if (@event.GetEventType().Equals(ApplicationMetricsConstants.FinishedEventType))
                        {
                            finishedTime = @event.GetTimestamp();
                            IDictionary <string, object> eventInfo = @event.GetEventInfo();
                            if (eventInfo == null)
                            {
                                continue;
                            }
                            if (eventInfo.Contains(ApplicationMetricsConstants.LatestAppAttemptEventInfo))
                            {
                                latestApplicationAttemptId = ConverterUtils.ToApplicationAttemptId(eventInfo[ApplicationMetricsConstants
                                                                                                             .LatestAppAttemptEventInfo].ToString());
                            }
                            if (eventInfo.Contains(ApplicationMetricsConstants.DiagnosticsInfoEventInfo))
                            {
                                diagnosticsInfo = eventInfo[ApplicationMetricsConstants.DiagnosticsInfoEventInfo]
                                                  .ToString();
                            }
                            if (eventInfo.Contains(ApplicationMetricsConstants.FinalStatusEventInfo))
                            {
                                finalStatus = FinalApplicationStatus.ValueOf(eventInfo[ApplicationMetricsConstants
                                                                                       .FinalStatusEventInfo].ToString());
                            }
                            if (eventInfo.Contains(ApplicationMetricsConstants.StateEventInfo))
                            {
                                state = YarnApplicationState.ValueOf(eventInfo[ApplicationMetricsConstants.StateEventInfo
                                                                     ].ToString());
                            }
                        }
                    }
                }
            }
            return(new ApplicationHistoryManagerOnTimelineStore.ApplicationReportExt(ApplicationReport
                                                                                     .NewInstance(ConverterUtils.ToApplicationId(entity.GetEntityId()), latestApplicationAttemptId
                                                                                                  , user, queue, name, null, -1, null, state, diagnosticsInfo, null, createdTime,
                                                                                                  finishedTime, finalStatus, appResources, null, 1.0F, type, null), appViewACLs));
        }