/// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/> /// <exception cref="System.IO.IOException"/> public virtual IDictionary <ContainerId, ContainerReport> GetContainers(ApplicationAttemptId appAttemptId) { ApplicationHistoryManagerOnTimelineStore.ApplicationReportExt app = GetApplication (appAttemptId.GetApplicationId(), ApplicationHistoryManagerOnTimelineStore.ApplicationReportField .UserAndAcls); CheckAccess(app); TimelineEntities entities = timelineDataManager.GetEntities(ContainerMetricsConstants .EntityType, new NameValuePair(ContainerMetricsConstants.ParentPrimariyFilter, appAttemptId .ToString()), null, null, null, null, null, long.MaxValue, EnumSet.AllOf <TimelineReader.Field >(), UserGroupInformation.GetLoginUser()); IDictionary <ContainerId, ContainerReport> containers = new LinkedHashMap <ContainerId , ContainerReport>(); if (entities != null && entities.GetEntities() != null) { foreach (TimelineEntity entity in entities.GetEntities()) { ContainerReport container = ConvertToContainerReport(entity, serverHttpAddress, app .appReport.GetUser()); containers[container.GetContainerId()] = container; } } return(containers); }
/// <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); }
/// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/> /// <exception cref="System.IO.IOException"/> public virtual IDictionary <ApplicationAttemptId, ApplicationAttemptReport> GetApplicationAttempts (ApplicationId appId) { ApplicationHistoryManagerOnTimelineStore.ApplicationReportExt app = GetApplication (appId, ApplicationHistoryManagerOnTimelineStore.ApplicationReportField.UserAndAcls ); CheckAccess(app); TimelineEntities entities = timelineDataManager.GetEntities(AppAttemptMetricsConstants .EntityType, new NameValuePair(AppAttemptMetricsConstants.ParentPrimaryFilter, appId .ToString()), null, null, null, null, null, long.MaxValue, EnumSet.AllOf <TimelineReader.Field >(), UserGroupInformation.GetLoginUser()); IDictionary <ApplicationAttemptId, ApplicationAttemptReport> appAttempts = new LinkedHashMap <ApplicationAttemptId, ApplicationAttemptReport>(); foreach (TimelineEntity entity in entities.GetEntities()) { ApplicationAttemptReport appAttempt = ConvertToApplicationAttemptReport(entity); appAttempts[appAttempt.GetApplicationAttemptId()] = appAttempt; } return(appAttempts); }
/// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/> /// <exception cref="System.IO.IOException"/> public virtual ContainerReport GetContainer(ContainerId containerId) { ApplicationHistoryManagerOnTimelineStore.ApplicationReportExt app = GetApplication (containerId.GetApplicationAttemptId().GetApplicationId(), ApplicationHistoryManagerOnTimelineStore.ApplicationReportField .UserAndAcls); CheckAccess(app); TimelineEntity entity = timelineDataManager.GetEntity(ContainerMetricsConstants.EntityType , containerId.ToString(), EnumSet.AllOf <TimelineReader.Field>(), UserGroupInformation .GetLoginUser()); if (entity == null) { throw new ContainerNotFoundException("The entity for container " + containerId + " doesn't exist in the timeline store"); } else { return(ConvertToContainerReport(entity, serverHttpAddress, app.appReport.GetUser( ))); } }
/// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/> /// <exception cref="System.IO.IOException"/> private void CheckAccess(ApplicationHistoryManagerOnTimelineStore.ApplicationReportExt app) { if (app.appViewACLs != null) { aclsManager.AddApplication(app.appReport.GetApplicationId(), app.appViewACLs); try { if (!aclsManager.CheckAccess(UserGroupInformation.GetCurrentUser(), ApplicationAccessType .ViewApp, app.appReport.GetUser(), app.appReport.GetApplicationId())) { throw new AuthorizationException("User " + UserGroupInformation.GetCurrentUser(). GetShortUserName() + " does not have privilage to see this application " + app.appReport .GetApplicationId()); } } finally { aclsManager.RemoveApplication(app.appReport.GetApplicationId()); } } }
/// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/> /// <exception cref="System.IO.IOException"/> private ApplicationAttemptReport GetApplicationAttempt(ApplicationAttemptId appAttemptId , bool checkACLs) { if (checkACLs) { ApplicationHistoryManagerOnTimelineStore.ApplicationReportExt app = GetApplication (appAttemptId.GetApplicationId(), ApplicationHistoryManagerOnTimelineStore.ApplicationReportField .UserAndAcls); CheckAccess(app); } TimelineEntity entity = timelineDataManager.GetEntity(AppAttemptMetricsConstants. EntityType, appAttemptId.ToString(), EnumSet.AllOf <TimelineReader.Field>(), UserGroupInformation .GetLoginUser()); if (entity == null) { throw new ApplicationAttemptNotFoundException("The entity for application attempt " + appAttemptId + " doesn't exist in the timeline store"); } else { return(ConvertToApplicationAttemptReport(entity)); } }
/// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/> /// <exception cref="System.IO.IOException"/> public virtual IDictionary <ApplicationId, ApplicationReport> GetApplications(long appsNum) { TimelineEntities entities = timelineDataManager.GetEntities(ApplicationMetricsConstants .EntityType, null, null, null, null, null, null, appsNum == long.MaxValue ? this .maxLoadedApplications : appsNum, EnumSet.AllOf <TimelineReader.Field>(), UserGroupInformation .GetLoginUser()); IDictionary <ApplicationId, ApplicationReport> apps = new LinkedHashMap <ApplicationId , ApplicationReport>(); if (entities != null && entities.GetEntities() != null) { foreach (TimelineEntity entity in entities.GetEntities()) { try { ApplicationHistoryManagerOnTimelineStore.ApplicationReportExt app = GenerateApplicationReport (entity, ApplicationHistoryManagerOnTimelineStore.ApplicationReportField.All); apps[app.appReport.GetApplicationId()] = app.appReport; } catch (Exception e) { Log.Error("Error on generating application report for " + entity.GetEntityId(), e ); } } } return(apps); }