/// <summary>Kills the application with the application id as appId</summary> /// <param name="applicationId"/> /// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/> /// <exception cref="System.IO.IOException"/> private void KillApplication(string applicationId) { ApplicationId appId = ConverterUtils.ToApplicationId(applicationId); ApplicationReport appReport = null; try { appReport = client.GetApplicationReport(appId); } catch (ApplicationNotFoundException e) { sysout.WriteLine("Application with id '" + applicationId + "' doesn't exist in RM." ); throw; } if (appReport.GetYarnApplicationState() == YarnApplicationState.Finished || appReport .GetYarnApplicationState() == YarnApplicationState.Killed || appReport.GetYarnApplicationState () == YarnApplicationState.Failed) { sysout.WriteLine("Application " + applicationId + " has already finished "); } else { sysout.WriteLine("Killing application " + applicationId); client.KillApplication(appId); } }
/// <exception cref="System.IO.IOException"/> public virtual IDictionary <ApplicationId, ApplicationHistoryData> GetAllApplications () { IDictionary <ApplicationId, ApplicationHistoryData> historyDataMap = new Dictionary <ApplicationId, ApplicationHistoryData>(); FileStatus[] files = fs.ListStatus(rootDirPath); foreach (FileStatus file in files) { ApplicationId appId = ConverterUtils.ToApplicationId(file.GetPath().GetName()); try { ApplicationHistoryData historyData = GetApplication(appId); if (historyData != null) { historyDataMap[appId] = historyData; } } catch (IOException e) { // Eat the exception not to disturb the getting the next // ApplicationHistoryData Log.Error("History information of application " + appId + " is not included into the result due to the exception" , e); } } return(historyDataMap); }
private static void DeleteOldLogDirsFrom(Path dir, long cutoffMillis, FileSystem fs, ApplicationClientProtocol rmClient) { try { foreach (FileStatus appDir in fs.ListStatus(dir)) { if (appDir.IsDirectory() && appDir.GetModificationTime() < cutoffMillis) { bool appTerminated = IsApplicationTerminated(ConverterUtils.ToApplicationId(appDir .GetPath().GetName()), rmClient); if (appTerminated && ShouldDeleteLogDir(appDir, cutoffMillis, fs)) { try { Log.Info("Deleting aggregated logs in " + appDir.GetPath()); fs.Delete(appDir.GetPath(), true); } catch (IOException e) { LogIOException("Could not delete " + appDir.GetPath(), e); } } else { if (!appTerminated) { try { foreach (FileStatus node in fs.ListStatus(appDir.GetPath())) { if (node.GetModificationTime() < cutoffMillis) { try { fs.Delete(node.GetPath(), true); } catch (IOException ex) { LogIOException("Could not delete " + appDir.GetPath(), ex); } } } } catch (IOException e) { LogIOException("Error reading the contents of " + appDir.GetPath(), e); } } } } } } catch (IOException e) { LogIOException("Could not read the contents of " + dir, e); } }
public virtual void TestDelegationTokenAuth() { string token = GetDelegationToken("test"); ApplicationSubmissionContextInfo app = new ApplicationSubmissionContextInfo(); string appid = "application_123_0"; app.SetApplicationId(appid); string requestBody = GetMarshalledAppInfo(app); Uri url = new Uri("http://localhost:8088/ws/v1/cluster/apps"); HttpURLConnection conn = (HttpURLConnection)url.OpenConnection(); SetupConn(conn, "POST", "application/xml", requestBody); // this should fail with unauthorized because only // auth is kerberos or delegation token try { conn.GetInputStream(); NUnit.Framework.Assert.Fail("we should not be here"); } catch (IOException) { NUnit.Framework.Assert.AreEqual(ClientResponse.Status.Unauthorized.GetStatusCode( ), conn.GetResponseCode()); } conn = (HttpURLConnection)url.OpenConnection(); conn.SetRequestProperty(delegationTokenHeader, token); SetupConn(conn, "POST", MediaType.ApplicationXml, requestBody); // this should not fail try { conn.GetInputStream(); } catch (IOException) { InputStream errorStream = conn.GetErrorStream(); string error = string.Empty; BufferedReader reader = null; reader = new BufferedReader(new InputStreamReader(errorStream, "UTF8")); for (string line; (line = reader.ReadLine()) != null;) { error += line; } reader.Close(); errorStream.Close(); NUnit.Framework.Assert.Fail("Response " + conn.GetResponseCode() + "; " + error); } bool appExists = rm.GetRMContext().GetRMApps().Contains(ConverterUtils.ToApplicationId (appid)); NUnit.Framework.Assert.IsTrue(appExists); RMApp actualApp = rm.GetRMContext().GetRMApps()[ConverterUtils.ToApplicationId(appid )]; string owner = actualApp.GetUser(); NUnit.Framework.Assert.AreEqual("client", owner); }
/// <exception cref="System.IO.IOException"/> public override NMStateStoreService.RecoveredApplicationsState LoadApplicationsState () { NMStateStoreService.RecoveredApplicationsState state = new NMStateStoreService.RecoveredApplicationsState (); state.applications = new AList <YarnServerNodemanagerRecoveryProtos.ContainerManagerApplicationProto >(); string keyPrefix = ApplicationsKeyPrefix; LeveldbIterator iter = null; try { iter = new LeveldbIterator(db); iter.Seek(JniDBFactory.Bytes(keyPrefix)); while (iter.HasNext()) { KeyValuePair <byte[], byte[]> entry = iter.Next(); string key = JniDBFactory.AsString(entry.Key); if (!key.StartsWith(keyPrefix)) { break; } state.applications.AddItem(YarnServerNodemanagerRecoveryProtos.ContainerManagerApplicationProto .ParseFrom(entry.Value)); } state.finishedApplications = new AList <ApplicationId>(); keyPrefix = FinishedAppsKeyPrefix; iter.Seek(JniDBFactory.Bytes(keyPrefix)); while (iter.HasNext()) { KeyValuePair <byte[], byte[]> entry = iter.Next(); string key = JniDBFactory.AsString(entry.Key); if (!key.StartsWith(keyPrefix)) { break; } ApplicationId appId = ConverterUtils.ToApplicationId(Sharpen.Runtime.Substring(key , keyPrefix.Length)); state.finishedApplications.AddItem(appId); } } catch (DBException e) { throw new IOException(e); } finally { if (iter != null) { iter.Close(); } } return(state); }
/// <exception cref="System.IO.IOException"/> private ApplicationStateData CreateApplicationState(string appIdStr, byte[] data) { ApplicationId appId = ConverterUtils.ToApplicationId(appIdStr); ApplicationStateDataPBImpl appState = new ApplicationStateDataPBImpl(YarnServerResourceManagerRecoveryProtos.ApplicationStateDataProto .ParseFrom(data)); if (!appId.Equals(appState.GetApplicationSubmissionContext().GetApplicationId())) { throw new YarnRuntimeException("The database entry for " + appId + " contains data for " + appState.GetApplicationSubmissionContext().GetApplicationId()); } return(appState); }
/// <exception cref="System.IO.IOException"/> public override NMStateStoreService.RecoveredLogDeleterState LoadLogDeleterState( ) { NMStateStoreService.RecoveredLogDeleterState state = new NMStateStoreService.RecoveredLogDeleterState (); state.logDeleterMap = new Dictionary <ApplicationId, YarnServerNodemanagerRecoveryProtos.LogDeleterProto >(); LeveldbIterator iter = null; try { iter = new LeveldbIterator(db); iter.Seek(JniDBFactory.Bytes(LogDeleterKeyPrefix)); int logDeleterKeyPrefixLength = LogDeleterKeyPrefix.Length; while (iter.HasNext()) { KeyValuePair <byte[], byte[]> entry = iter.Next(); string fullKey = JniDBFactory.AsString(entry.Key); if (!fullKey.StartsWith(LogDeleterKeyPrefix)) { break; } string appIdStr = Sharpen.Runtime.Substring(fullKey, logDeleterKeyPrefixLength); ApplicationId appId = null; try { appId = ConverterUtils.ToApplicationId(appIdStr); } catch (ArgumentException) { Log.Warn("Skipping unknown log deleter key " + fullKey); continue; } YarnServerNodemanagerRecoveryProtos.LogDeleterProto proto = YarnServerNodemanagerRecoveryProtos.LogDeleterProto .ParseFrom(entry.Value); state.logDeleterMap[appId] = proto; } } catch (DBException e) { throw new IOException(e); } finally { if (iter != null) { iter.Close(); } } return(state); }
protected internal static ApplicationId ParseApplicationId(string appId) { if (appId == null || appId.IsEmpty()) { throw new NotFoundException("appId, " + appId + ", is empty or null"); } ApplicationId aid = ConverterUtils.ToApplicationId(appId); if (aid == null) { throw new NotFoundException("appId is null"); } return(aid); }
public virtual AppInfo GetNodeApp(string appId) { Init(); ApplicationId id = ConverterUtils.ToApplicationId(recordFactory, appId); if (id == null) { throw new NotFoundException("app with id " + appId + " not found"); } Org.Apache.Hadoop.Yarn.Server.Nodemanager.Containermanager.Application.Application app = this.nmContext.GetApplications()[id]; if (app == null) { throw new NotFoundException("app with id " + appId + " not found"); } return(new AppInfo(app)); }
/// <summary>Moves the application with the given ID to the given queue.</summary> /// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/> /// <exception cref="System.IO.IOException"/> private void MoveApplicationAcrossQueues(string applicationId, string queue) { ApplicationId appId = ConverterUtils.ToApplicationId(applicationId); ApplicationReport appReport = client.GetApplicationReport(appId); if (appReport.GetYarnApplicationState() == YarnApplicationState.Finished || appReport .GetYarnApplicationState() == YarnApplicationState.Killed || appReport.GetYarnApplicationState () == YarnApplicationState.Failed) { sysout.WriteLine("Application " + applicationId + " has already finished "); } else { sysout.WriteLine("Moving application " + applicationId + " to queue " + queue); client.MoveApplicationAcrossQueues(appId, queue); sysout.WriteLine("Successfully completed move."); } }
/// <summary>Lists the application attempts matching the given applicationid</summary> /// <param name="applicationId"/> /// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/> /// <exception cref="System.IO.IOException"/> private void ListApplicationAttempts(string applicationId) { PrintWriter writer = new PrintWriter(new OutputStreamWriter(sysout, Sharpen.Extensions.GetEncoding ("UTF-8"))); IList <ApplicationAttemptReport> appAttemptsReport = client.GetApplicationAttempts (ConverterUtils.ToApplicationId(applicationId)); writer.WriteLine("Total number of application attempts " + ":" + appAttemptsReport .Count); writer.Printf(ApplicationAttemptsPattern, "ApplicationAttempt-Id", "State", "AM-Container-Id" , "Tracking-URL"); foreach (ApplicationAttemptReport appAttemptReport in appAttemptsReport) { writer.Printf(ApplicationAttemptsPattern, appAttemptReport.GetApplicationAttemptId (), appAttemptReport.GetYarnApplicationAttemptState(), appAttemptReport.GetAMContainerId ().ToString(), appAttemptReport.GetTrackingUrl()); } writer.Flush(); }
/// <exception cref="System.Exception"/> private void TestAnonymousSimpleUser() { ApplicationSubmissionContextInfo app = new ApplicationSubmissionContextInfo(); string appid = "application_123_0"; app.SetApplicationId(appid); string requestBody = TestRMWebServicesDelegationTokenAuthentication.GetMarshalledAppInfo (app); Uri url = new Uri("http://localhost:8088/ws/v1/cluster/apps"); HttpURLConnection conn = (HttpURLConnection)url.OpenConnection(); TestRMWebServicesDelegationTokenAuthentication.SetupConn(conn, "POST", "application/xml" , requestBody); conn.GetInputStream(); NUnit.Framework.Assert.AreEqual(ClientResponse.Status.Accepted.GetStatusCode(), conn .GetResponseCode()); bool appExists = rm.GetRMContext().GetRMApps().Contains(ConverterUtils.ToApplicationId (appid)); NUnit.Framework.Assert.IsTrue(appExists); RMApp actualApp = rm.GetRMContext().GetRMApps()[ConverterUtils.ToApplicationId(appid )]; string owner = actualApp.GetUser(); NUnit.Framework.Assert.AreEqual(rm.GetConfig().Get(CommonConfigurationKeys.HadoopHttpStaticUser , CommonConfigurationKeys.DefaultHadoopHttpStaticUser), owner); appid = "application_123_1"; app.SetApplicationId(appid); requestBody = TestRMWebServicesDelegationTokenAuthentication.GetMarshalledAppInfo (app); url = new Uri("http://localhost:8088/ws/v1/cluster/apps?user.name=client"); conn = (HttpURLConnection)url.OpenConnection(); TestRMWebServicesDelegationTokenAuthentication.SetupConn(conn, "POST", MediaType. ApplicationXml, requestBody); conn.GetInputStream(); appExists = rm.GetRMContext().GetRMApps().Contains(ConverterUtils.ToApplicationId (appid)); NUnit.Framework.Assert.IsTrue(appExists); actualApp = rm.GetRMContext().GetRMApps()[ConverterUtils.ToApplicationId(appid)]; owner = actualApp.GetUser(); NUnit.Framework.Assert.AreEqual("client", owner); }
protected override void Render(HtmlBlock.Block html) { ApplicationId applicationID = ConverterUtils.ToApplicationId(this.recordFactory, $(ApplicationId)); Org.Apache.Hadoop.Yarn.Server.Nodemanager.Containermanager.Application.Application app = this.nmContext.GetApplications()[applicationID]; AppInfo info = new AppInfo(app); Info("Application's information").("ApplicationId", info.GetId()).("ApplicationState" , info.GetState()).("User", info.GetUser()); Hamlet.TABLE <Org.Apache.Hadoop.Yarn.Webapp.Hamlet.Hamlet> containersListBody = html .(typeof(InfoBlock)).Table("#containers"); foreach (string containerIdStr in info.GetContainers()) { containersListBody.Tr().Td().A(Url("container", containerIdStr), containerIdStr). ().(); } containersListBody.(); }
/// <exception cref="System.IO.IOException"/> private NMStateStoreService.RecoveredUserResources LoadUserLocalizedResources(LeveldbIterator iter, string keyPrefix) { NMStateStoreService.RecoveredUserResources userResources = new NMStateStoreService.RecoveredUserResources (); while (iter.HasNext()) { KeyValuePair <byte[], byte[]> entry = iter.PeekNext(); string key = JniDBFactory.AsString(entry.Key); if (!key.StartsWith(keyPrefix)) { break; } if (key.StartsWith(LocalizationFilecacheSuffix, keyPrefix.Length)) { userResources.privateTrackerState = LoadResourceTrackerState(iter, keyPrefix + LocalizationFilecacheSuffix ); } else { if (key.StartsWith(LocalizationAppcacheSuffix, keyPrefix.Length)) { int appIdStartPos = keyPrefix.Length + LocalizationAppcacheSuffix.Length; int appIdEndPos = key.IndexOf('/', appIdStartPos); if (appIdEndPos < 0) { throw new IOException("Unable to determine appID in resource key: " + key); } ApplicationId appId = ConverterUtils.ToApplicationId(Sharpen.Runtime.Substring(key , appIdStartPos, appIdEndPos)); userResources.appTrackerStates[appId] = LoadResourceTrackerState(iter, Sharpen.Runtime.Substring (key, 0, appIdEndPos + 1)); } else { throw new IOException("Unexpected user resource key " + key); } } } return(userResources); }
/// <exception cref="System.Exception"/> public virtual int Run(string[] args) { Options opts = new Options(); opts.AddOption(HelpCmd, false, "Displays help for all commands."); Option appIdOpt = new Option(ApplicationIdOption, true, "ApplicationId (required)" ); appIdOpt.SetRequired(true); opts.AddOption(appIdOpt); opts.AddOption(ContainerIdOption, true, "ContainerId (must be specified if node address is specified)" ); opts.AddOption(NodeAddressOption, true, "NodeAddress in the format " + "nodename:port (must be specified if container id is specified)" ); opts.AddOption(AppOwnerOption, true, "AppOwner (assumed to be current user if not specified)" ); opts.GetOption(ApplicationIdOption).SetArgName("Application ID"); opts.GetOption(ContainerIdOption).SetArgName("Container ID"); opts.GetOption(NodeAddressOption).SetArgName("Node Address"); opts.GetOption(AppOwnerOption).SetArgName("Application Owner"); Options printOpts = new Options(); printOpts.AddOption(opts.GetOption(HelpCmd)); printOpts.AddOption(opts.GetOption(ContainerIdOption)); printOpts.AddOption(opts.GetOption(NodeAddressOption)); printOpts.AddOption(opts.GetOption(AppOwnerOption)); if (args.Length < 1) { PrintHelpMessage(printOpts); return(-1); } if (args[0].Equals("-help")) { PrintHelpMessage(printOpts); return(0); } CommandLineParser parser = new GnuParser(); string appIdStr = null; string containerIdStr = null; string nodeAddress = null; string appOwner = null; try { CommandLine commandLine = parser.Parse(opts, args, true); appIdStr = commandLine.GetOptionValue(ApplicationIdOption); containerIdStr = commandLine.GetOptionValue(ContainerIdOption); nodeAddress = commandLine.GetOptionValue(NodeAddressOption); appOwner = commandLine.GetOptionValue(AppOwnerOption); } catch (ParseException e) { System.Console.Error.WriteLine("options parsing failed: " + e.Message); PrintHelpMessage(printOpts); return(-1); } if (appIdStr == null) { System.Console.Error.WriteLine("ApplicationId cannot be null!"); PrintHelpMessage(printOpts); return(-1); } ApplicationId appId = null; try { appId = ConverterUtils.ToApplicationId(appIdStr); } catch (Exception) { System.Console.Error.WriteLine("Invalid ApplicationId specified"); return(-1); } try { int resultCode = VerifyApplicationState(appId); if (resultCode != 0) { System.Console.Out.WriteLine("Logs are not avaiable right now."); return(resultCode); } } catch (Exception) { System.Console.Error.WriteLine("Unable to get ApplicationState." + " Attempting to fetch logs directly from the filesystem." ); } LogCLIHelpers logCliHelper = new LogCLIHelpers(); logCliHelper.SetConf(GetConf()); if (appOwner == null || appOwner.IsEmpty()) { appOwner = UserGroupInformation.GetCurrentUser().GetShortUserName(); } int resultCode_1 = 0; if (containerIdStr == null && nodeAddress == null) { resultCode_1 = logCliHelper.DumpAllContainersLogs(appId, appOwner, System.Console.Out ); } else { if ((containerIdStr == null && nodeAddress != null) || (containerIdStr != null && nodeAddress == null)) { System.Console.Out.WriteLine("ContainerId or NodeAddress cannot be null!"); PrintHelpMessage(printOpts); resultCode_1 = -1; } else { resultCode_1 = logCliHelper.DumpAContainersLogs(appIdStr, containerIdStr, nodeAddress , appOwner); } } return(resultCode_1); }
public virtual int DumpAContainersLogs(string appId, string containerId, string nodeId , string jobOwner) { Path remoteRootLogDir = new Path(GetConf().Get(YarnConfiguration.NmRemoteAppLogDir , YarnConfiguration.DefaultNmRemoteAppLogDir)); string suffix = LogAggregationUtils.GetRemoteNodeLogDirSuffix(GetConf()); Path remoteAppLogDir = LogAggregationUtils.GetRemoteAppLogDir(remoteRootLogDir, ConverterUtils .ToApplicationId(appId), jobOwner, suffix); RemoteIterator <FileStatus> nodeFiles; try { Path qualifiedLogDir = FileContext.GetFileContext(GetConf()).MakeQualified(remoteAppLogDir ); nodeFiles = FileContext.GetFileContext(qualifiedLogDir.ToUri(), GetConf()).ListStatus (remoteAppLogDir); } catch (FileNotFoundException) { LogDirNotExist(remoteAppLogDir.ToString()); return(-1); } bool foundContainerLogs = false; while (nodeFiles.HasNext()) { FileStatus thisNodeFile = nodeFiles.Next(); string fileName = thisNodeFile.GetPath().GetName(); if (fileName.Contains(LogAggregationUtils.GetNodeString(nodeId)) && !fileName.EndsWith (LogAggregationUtils.TmpFileSuffix)) { AggregatedLogFormat.LogReader reader = null; try { reader = new AggregatedLogFormat.LogReader(GetConf(), thisNodeFile.GetPath()); if (DumpAContainerLogs(containerId, reader, System.Console.Out, thisNodeFile.GetModificationTime ()) > -1) { foundContainerLogs = true; } } finally { if (reader != null) { reader.Close(); } } } } if (!foundContainerLogs) { ContainerLogNotFound(containerId); return(-1); } return(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); }
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)); }