public ContainerInfo(ContainerReport container) { // JAXB needs this containerId = container.GetContainerId().ToString(); if (container.GetAllocatedResource() != null) { allocatedMB = container.GetAllocatedResource().GetMemory(); allocatedVCores = container.GetAllocatedResource().GetVirtualCores(); } if (container.GetAssignedNode() != null) { assignedNodeId = container.GetAssignedNode().ToString(); } priority = container.GetPriority().GetPriority(); startedTime = container.GetCreationTime(); finishedTime = container.GetFinishTime(); elapsedTime = Times.Elapsed(startedTime, finishedTime); diagnosticsInfo = container.GetDiagnosticsInfo(); logUrl = container.GetLogUrl(); containerExitStatus = container.GetContainerExitStatus(); containerState = container.GetContainerState(); nodeHttpAddress = container.GetNodeHttpAddress(); }
/// <summary>Prints the container report for an container id.</summary> /// <param name="containerId"/> /// <returns>exitCode</returns> /// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/> /// <exception cref="System.IO.IOException"/> private int PrintContainerReport(string containerId) { ContainerReport containerReport = null; try { containerReport = client.GetContainerReport((ConverterUtils.ToContainerId(containerId ))); } catch (ApplicationNotFoundException) { sysout.WriteLine("Application for Container with id '" + containerId + "' doesn't exist in RM or Timeline Server." ); return(-1); } catch (ApplicationAttemptNotFoundException) { sysout.WriteLine("Application Attempt for Container with id '" + containerId + "' doesn't exist in RM or Timeline Server." ); return(-1); } catch (ContainerNotFoundException) { sysout.WriteLine("Container with id '" + containerId + "' doesn't exist in RM or Timeline Server." ); return(-1); } // Use PrintWriter.println, which uses correct platform line ending. ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintWriter containerReportStr = new PrintWriter(new OutputStreamWriter(baos, Sharpen.Extensions.GetEncoding ("UTF-8"))); if (containerReport != null) { containerReportStr.WriteLine("Container Report : "); containerReportStr.Write("\tContainer-Id : "); containerReportStr.WriteLine(containerReport.GetContainerId()); containerReportStr.Write("\tStart-Time : "); containerReportStr.WriteLine(containerReport.GetCreationTime()); containerReportStr.Write("\tFinish-Time : "); containerReportStr.WriteLine(containerReport.GetFinishTime()); containerReportStr.Write("\tState : "); containerReportStr.WriteLine(containerReport.GetContainerState()); containerReportStr.Write("\tLOG-URL : "); containerReportStr.WriteLine(containerReport.GetLogUrl()); containerReportStr.Write("\tHost : "); containerReportStr.WriteLine(containerReport.GetAssignedNode()); containerReportStr.Write("\tNodeHttpAddress : "); containerReportStr.WriteLine(containerReport.GetNodeHttpAddress() == null ? "N/A" : containerReport.GetNodeHttpAddress()); containerReportStr.Write("\tDiagnostics : "); containerReportStr.Write(containerReport.GetDiagnosticsInfo()); } else { containerReportStr.Write("Container with id '" + containerId + "' doesn't exist in Timeline Server." ); containerReportStr.Close(); sysout.WriteLine(baos.ToString("UTF-8")); return(-1); } containerReportStr.Close(); sysout.WriteLine(baos.ToString("UTF-8")); return(0); }