> table = div.table("#containers");
+ table.
+ tr().
+ th(containerString)._().
+ tr().
+ th(_TH, "Container Id").
+ th(_TH, "Node").
+ th(_TH, "Container Exit Status").
+ th(_TH, "Logs").
+ _();
+
+ boolean odd = false;
+ for (ContainerReport containerReport : containers) {
+ ContainerInfo container = new ContainerInfo(containerReport);
+ table
+ .tr((odd = !odd) ? _ODD : _EVEN)
+ .
+ td()
+ .a(url("container", container.getContainerId()),
+ container.getContainerId())
+ ._()
+ .
+ td(container.getAssignedNodeId())
+ .
+ td(String.valueOf(container.getContainerExitStatus()))
+ .
+ td()
+ .a(container.getLogUrl() == null ? "#" : url(container.getLogUrl()),
+ "Logs")._().
+ _();
+ }
+ table._();
+ div._();
+ }
+}
\ No newline at end of file
diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/webapp/AppBlock.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/webapp/AppBlock.java
new file mode 100644
index 0000000..5763cd6
--- /dev/null
+++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/webapp/AppBlock.java
@@ -0,0 +1,184 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.yarn.server.webapp;
+
+import static org.apache.hadoop.yarn.util.StringHelper.join;
+import static org.apache.hadoop.yarn.webapp.YarnWebParams.APPLICATION_ID;
+import static org.apache.hadoop.yarn.webapp.view.JQueryUI._EVEN;
+import static org.apache.hadoop.yarn.webapp.view.JQueryUI._INFO_WRAP;
+import static org.apache.hadoop.yarn.webapp.view.JQueryUI._ODD;
+import static org.apache.hadoop.yarn.webapp.view.JQueryUI._TH;
+
+import java.io.IOException;
+import java.util.Collection;
+
+import org.apache.hadoop.http.HttpConfig;
+import org.apache.hadoop.util.StringUtils;
+import org.apache.hadoop.yarn.api.records.ApplicationAttemptReport;
+import org.apache.hadoop.yarn.api.records.ApplicationId;
+import org.apache.hadoop.yarn.api.records.ApplicationReport;
+import org.apache.hadoop.yarn.api.records.ContainerReport;
+import org.apache.hadoop.yarn.server.api.ApplicationContext;
+import org.apache.hadoop.yarn.server.webapp.dao.AppAttemptInfo;
+import org.apache.hadoop.yarn.server.webapp.dao.AppInfo;
+import org.apache.hadoop.yarn.server.webapp.dao.ContainerInfo;
+import org.apache.hadoop.yarn.util.Apps;
+import org.apache.hadoop.yarn.util.Times;
+import org.apache.hadoop.yarn.webapp.hamlet.Hamlet;
+import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.DIV;
+import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TABLE;
+import org.apache.hadoop.yarn.webapp.view.HtmlBlock;
+import org.apache.hadoop.yarn.webapp.view.InfoBlock;
+
+import com.google.inject.Inject;
+
+public class AppBlock extends HtmlBlock {
+
+ protected ApplicationContext appContext;
+
+ @Inject
+ AppBlock(ApplicationContext appContext, ViewContext ctx) {
+ super(ctx);
+ this.appContext = appContext;
+ }
+
+ @Override
+ protected void render(Block html) {
+ String aid = $(APPLICATION_ID);
+ if (aid.isEmpty()) {
+ puts("Bad request: requires Application ID");
+ return;
+ }
+
+ ApplicationId appID = null;
+ try {
+ appID = Apps.toAppID(aid);
+ } catch (Exception e) {
+ puts("Invalid Application ID: " + aid);
+ return;
+ }
+
+ ApplicationReport appReport;
+ try {
+ appReport = appContext.getApplication(appID);
+ } catch (IOException e) {
+ String message =
+ "Failed to read the application " + appID + ".";
+ LOG.error(message, e);
+ html.p()._(message)._();
+ return;
+ }
+ if (appReport == null) {
+ puts("Application not found: " + aid);
+ return;
+ }
+ AppInfo app = new AppInfo(appReport);
+
+ setTitle(join("Application ", aid));
+
+ info("Application Overview")
+ .
+ _("User:", app.getUser())
+ .
+ _("Name:", app.getName())
+ .
+ _("Application Type:", app.getApplicationType())
+ .
+ _("State:", app.getAppState())
+ .
+ _("FinalStatus:", app.getFinalAppStatus())
+ .
+ _("Started:", Times.format(app.getStartedTime()))
+ .
+ _("Elapsed:", StringUtils.formatTime(
+ Times.elapsed(app.getStartedTime(), app.getFinishedTime())))
+ .
+ _("Tracking URL:",
+ app.getTrackingUrl() == null ? "#" : app.getTrackingUrl(),
+ "History").
+ _("Diagnostics:", app.getDiagnosticsInfo());
+
+ Collection
attempts;
+ try {
+ attempts = appContext.getApplicationAttempts(appID).values();
+ } catch (IOException e) {
+ String message =
+ "Failed to read the attempts of the application " + appID + ".";
+ LOG.error(message, e);
+ html.p()._(message)._();
+ return;
+ }
+ String amString =
+ attempts.size() == 1 ? "ApplicationMaster" : "ApplicationMasters";
+
+ DIV div = html._(InfoBlock.class).div(_INFO_WRAP);
+ // Application Attempt Table
+ TABLE> table = div.table("#app");
+ table.
+ tr().
+ th(amString).
+ _().
+ tr().
+ th(_TH, "Attempt ID").
+ th(_TH, "Started").
+ th(_TH, "Node").
+ th(_TH, "Logs").
+ _();
+
+ boolean odd = false;
+ for (ApplicationAttemptReport appAttemptReport : attempts) {
+ AppAttemptInfo appAttempt = new AppAttemptInfo(appAttemptReport);
+ ContainerReport containerReport;
+ try {
+ containerReport = appContext.getAMContainer(appAttemptReport
+ .getApplicationAttemptId());
+ } catch (IOException e) {
+ String message =
+ "Failed to read the AM container of the application attempt "
+ + appAttemptReport.getApplicationAttemptId() + ".";
+ LOG.error(message, e);
+ html.p()._(message)._();
+ return;
+ }
+ String startTime = "N/A";
+ String logsLink = null;
+ if (containerReport != null) {
+ ContainerInfo container = new ContainerInfo(containerReport);
+ startTime = Times.format(container.getStartedTime());
+ logsLink = container.getLogUrl();
+ }
+ String nodeLink = null;
+ if (appAttempt.getHost() != null && appAttempt.getRpcPort() >= 0
+ && appAttempt.getRpcPort() < 65536) {
+ nodeLink = appAttempt.getHost() + ":" + appAttempt.getRpcPort();
+ }
+ table.tr((odd = !odd) ? _ODD : _EVEN).
+ td().a(url("appattempt", appAttempt.getAppAttemptId()),
+ appAttempt.getAppAttemptId())._().
+ td(startTime).
+ td().a(".nodelink", nodeLink == null ? "#" : url(HttpConfig.getSchemePrefix(),
+ nodeLink), nodeLink == null ? "N/A" : nodeLink)._().
+ td().a(".logslink", logsLink == null ? "#" : url(logsLink), "Logs")._().
+ _();
+ }
+
+ table._();
+ div._();
+ }
+}
diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/webapp/AppsBlock.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/webapp/AppsBlock.java
new file mode 100644
index 0000000..9006de0
--- /dev/null
+++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/webapp/AppsBlock.java
@@ -0,0 +1,150 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.yarn.server.webapp;
+
+import static org.apache.hadoop.yarn.util.StringHelper.join;
+import static org.apache.hadoop.yarn.webapp.YarnWebParams.APP_STATE;
+import static org.apache.hadoop.yarn.webapp.view.JQueryUI.C_PROGRESSBAR;
+import static org.apache.hadoop.yarn.webapp.view.JQueryUI.C_PROGRESSBAR_VALUE;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.HashSet;
+
+import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.hadoop.yarn.api.records.ApplicationReport;
+import org.apache.hadoop.yarn.api.records.YarnApplicationState;
+import org.apache.hadoop.yarn.server.api.ApplicationContext;
+import org.apache.hadoop.yarn.server.webapp.dao.AppInfo;
+import org.apache.hadoop.yarn.webapp.hamlet.Hamlet;
+import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TABLE;
+import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TBODY;
+import org.apache.hadoop.yarn.webapp.view.HtmlBlock;
+
+import com.google.inject.Inject;
+
+public class AppsBlock extends HtmlBlock {
+
+ protected ApplicationContext appContext;
+
+ @Inject
+ AppsBlock(ApplicationContext appContext, ViewContext ctx) {
+ super(ctx);
+ this.appContext = appContext;
+ }
+
+ @Override
+ public void render(Block html) {
+ setTitle("Applications");
+
+ TBODY
> tbody = html.
+ table("#apps").
+ thead().
+ tr().
+ th(".id", "ID").
+ th(".user", "User").
+ th(".name", "Name").
+ th(".type", "Application Type").
+ th(".queue", "Queue").
+ th(".starttime", "StartTime").
+ th(".finishtime", "FinishTime").
+ th(".state", "State").
+ th(".finalstatus", "FinalStatus").
+ th(".progress", "Progress").
+ th(".ui", "Tracking UI")._()._().
+ tbody();
+ Collection reqAppStates = null;
+ String reqStateString = $(APP_STATE);
+ if (reqStateString != null && !reqStateString.isEmpty()) {
+ String[] appStateStrings = reqStateString.split(",");
+ reqAppStates = new HashSet(appStateStrings.length);
+ for (String stateString : appStateStrings) {
+ reqAppStates.add(YarnApplicationState.valueOf(stateString));
+ }
+ }
+
+ Collection appReports;
+ try {
+ appReports = appContext.getAllApplications().values();
+ } catch (IOException e) {
+ String message =
+ "Failed to read the applications.";
+ LOG.error(message, e);
+ html.p()._(message)._();
+ return;
+ }
+ StringBuilder appsTableData = new StringBuilder("[\n");
+ for (ApplicationReport appReport : appReports) {
+ if (reqAppStates != null
+ && !reqAppStates.contains(appReport.getYarnApplicationState())) {
+ continue;
+ }
+ AppInfo app = new AppInfo(appReport);
+ String percent = String.format("%.1f", app.getProgress());
+ // AppID numerical value parsed by parseHadoopID in yarn.dt.plugins.js
+ appsTableData
+ .append("[\"")
+ .append(app.getAppId())
+ .append("\",\"")
+ .append(
+ StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeHtml(
+ app.getUser())))
+ .append("\",\"")
+ .append(
+ StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeHtml(
+ app.getName())))
+ .append("\",\"")
+ .append(
+ StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeHtml(
+ app.getApplicationType())))
+ .append("\",\"")
+ .append(
+ StringEscapeUtils.escapeJavaScript(StringEscapeUtils.escapeHtml(
+ app.getQueue()))).append("\",\"")
+ .append(app.getStartedTime()).append("\",\"")
+ .append(app.getFinishedTime()).append("\",\"")
+ .append(app.getAppState()).append("\",\"")
+ .append(app.getFinalAppStatus()).append("\",\"")
+ // Progress bar
+ .append("
")
+ .append("\",\"")
+ .append("History").append("\"],\n");
+
+ }
+ if (appsTableData.charAt(appsTableData.length() - 2) == ',') {
+ appsTableData.delete(appsTableData.length() - 2,
+ appsTableData.length() - 1);
+ }
+ appsTableData.append("]");
+ html.script().$type("text/javascript").
+ _("var appsTableData=" + appsTableData)._();
+
+ tbody._()._();
+ }
+}
diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/webapp/ContainerBlock.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/webapp/ContainerBlock.java
new file mode 100644
index 0000000..8e3d4e4
--- /dev/null
+++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/webapp/ContainerBlock.java
@@ -0,0 +1,95 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.yarn.server.webapp;
+
+import static org.apache.hadoop.yarn.util.StringHelper.join;
+import static org.apache.hadoop.yarn.webapp.YarnWebParams.CONTAINER_ID;
+
+import java.io.IOException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.util.StringUtils;
+import org.apache.hadoop.yarn.api.records.ContainerId;
+import org.apache.hadoop.yarn.api.records.ContainerReport;
+import org.apache.hadoop.yarn.server.api.ApplicationContext;
+import org.apache.hadoop.yarn.server.webapp.dao.ContainerInfo;
+import org.apache.hadoop.yarn.util.ConverterUtils;
+import org.apache.hadoop.yarn.util.Times;
+import org.apache.hadoop.yarn.webapp.view.HtmlBlock;
+
+import com.google.inject.Inject;
+
+public class ContainerBlock extends HtmlBlock {
+
+ private static final Log LOG = LogFactory.getLog(ContainerBlock.class);
+ private final ApplicationContext appContext;
+
+ @Inject
+ public ContainerBlock(ApplicationContext appContext, ViewContext ctx) {
+ super(ctx);
+ this.appContext = appContext;
+ }
+
+ @Override
+ protected void render(Block html) {
+ String containerid = $(CONTAINER_ID);
+ if (containerid.isEmpty()) {
+ puts("Bad request: requires container ID");
+ return;
+ }
+
+ ContainerId containerId = null;
+ try {
+ containerId = ConverterUtils.toContainerId(containerid);
+ } catch (IllegalArgumentException e) {
+ puts("Invalid container ID: " + containerid);
+ return;
+ }
+
+ ContainerReport containerReport;
+ try {
+ containerReport = appContext.getContainer(containerId);
+ } catch (IOException e) {
+ String message = "Failed to read the container " + containerid + ".";
+ LOG.error(message, e);
+ html.p()._(message)._();
+ return;
+ }
+ if (containerReport == null) {
+ puts("Container not found: " + containerid);
+ return;
+ }
+ ContainerInfo container = new ContainerInfo(containerReport);
+
+ setTitle(join("Container ", containerid));
+
+ info("Container Overview").
+ _("Memory:", container.getAllocatedMB()).
+ _("Vcores:", container.getAllocatedVCores()).
+ _("Node:", container.getAssignedNodeId()).
+ _("Priority:", container.getPriority()).
+ _("Started:", Times.format(container.getStartedTime())).
+ _("Elapsed:", StringUtils.formatTime(
+ Times.elapsed(container.getStartedTime(), container.getFinishedTime()))).
+ _("Diagnostics:", container.getDiagnosticsInfo()).
+ _("Exit Status:", container.getContainerExitStatus()).
+ _("State:", container.getContainerState()).
+ _("Logs:", container.getLogUrl());
+ }
+}
\ No newline at end of file
diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/webapp/dao/AppAttemptInfo.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/webapp/dao/AppAttemptInfo.java
new file mode 100644
index 0000000..d535fd1
--- /dev/null
+++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/webapp/dao/AppAttemptInfo.java
@@ -0,0 +1,84 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.yarn.server.webapp.dao;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.apache.hadoop.yarn.api.records.ApplicationAttemptReport;
+import org.apache.hadoop.yarn.api.records.YarnApplicationAttemptState;
+
+@XmlRootElement(name = "appattempt")
+@XmlAccessorType(XmlAccessType.FIELD)
+public class AppAttemptInfo {
+
+ protected String appAttemptId;
+ protected String host;
+ protected int rpcPort;
+ protected String trackingUrl;
+ protected String diagnosticsInfo;
+ protected YarnApplicationAttemptState appAttemptState;
+ protected String amContainerId;
+
+ public AppAttemptInfo() {
+ // JAXB needs this
+ }
+
+ public AppAttemptInfo(ApplicationAttemptReport appAttempt) {
+ appAttemptId = appAttempt.getApplicationAttemptId().toString();
+ host = appAttempt.getHost();
+ rpcPort = appAttempt.getRpcPort();
+ trackingUrl = appAttempt.getTrackingUrl();
+ diagnosticsInfo = appAttempt.getDiagnostics();
+ appAttemptState = appAttempt.getYarnApplicationAttemptState();
+ if (appAttempt.getAMContainerId() != null) {
+ amContainerId = appAttempt.getAMContainerId().toString();
+ }
+ }
+
+ public String getAppAttemptId() {
+ return appAttemptId;
+ }
+
+ public String getHost() {
+ return host;
+ }
+
+ public int getRpcPort() {
+ return rpcPort;
+ }
+
+ public String getTrackingUrl() {
+ return trackingUrl;
+ }
+
+ public String getDiagnosticsInfo() {
+ return diagnosticsInfo;
+ }
+
+ public YarnApplicationAttemptState getAppAttemptState() {
+ return appAttemptState;
+ }
+
+ public String getAmContainerId() {
+ return amContainerId;
+ }
+
+}
diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/webapp/dao/AppInfo.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/webapp/dao/AppInfo.java
new file mode 100644
index 0000000..9cd4700
--- /dev/null
+++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/webapp/dao/AppInfo.java
@@ -0,0 +1,174 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.yarn.server.webapp.dao;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.apache.hadoop.yarn.api.records.ApplicationReport;
+import org.apache.hadoop.yarn.api.records.ApplicationResourceUsageReport;
+import org.apache.hadoop.yarn.api.records.FinalApplicationStatus;
+import org.apache.hadoop.yarn.api.records.YarnApplicationState;
+import org.apache.hadoop.yarn.util.Times;
+
+@XmlRootElement(name = "app")
+@XmlAccessorType(XmlAccessType.FIELD)
+public class AppInfo {
+
+ protected String appId;
+ protected String currentAppAttemptId;
+ protected String user;
+ protected String name;
+ protected String queue;
+ protected String type;
+ protected String host;
+ protected int rpcPort;
+ protected YarnApplicationState appState;
+ protected float progress;
+ protected String diagnosticsInfo;
+ protected String originalTrackingUrl;
+ protected String trackingUrl;
+ protected FinalApplicationStatus finalAppStatus;
+ protected String applicationType;
+ protected long submittedTime;
+ protected long startedTime;
+ protected long finishedTime;
+ protected long elapsedTime;
+ protected int allocatedMB;
+ protected int allocatedVCores;
+
+ public AppInfo() {
+ // JAXB needs this
+ }
+
+ public AppInfo(ApplicationReport app) {
+ 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();
+ ApplicationResourceUsageReport usage =
+ app.getApplicationResourceUsageReport();
+ if (usage != null) {
+ allocatedMB = usage.getUsedResources().getMemory();
+ allocatedVCores = usage.getUsedResources().getVirtualCores();
+ }
+ progress = app.getProgress();
+ }
+
+ public String getAppId() {
+ return appId;
+ }
+
+ public String getCurrentAppAttemptId() {
+ return currentAppAttemptId;
+ }
+
+ public String getUser() {
+ return user;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getQueue() {
+ return queue;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public String getHost() {
+ return host;
+ }
+
+ public int getRpcPort() {
+ return rpcPort;
+ }
+
+ public YarnApplicationState getAppState() {
+ return appState;
+ }
+
+ public float getProgress() {
+ return progress;
+ }
+
+ public String getDiagnosticsInfo() {
+ return diagnosticsInfo;
+ }
+
+ public String getOriginalTrackingUrl() {
+ return originalTrackingUrl;
+ }
+
+ public String getTrackingUrl() {
+ return trackingUrl;
+ }
+
+ public FinalApplicationStatus getFinalAppStatus() {
+ return finalAppStatus;
+ }
+
+ public String getApplicationType() {
+ return applicationType;
+ }
+
+ public long getSubmittedTime() {
+ return submittedTime;
+ }
+
+ public long getStartedTime() {
+ return startedTime;
+ }
+
+ public long getFinishedTime() {
+ return finishedTime;
+ }
+
+ public long getElapsedTime() {
+ return elapsedTime;
+ }
+
+ public int getAllocatedMB() {
+ return allocatedMB;
+ }
+
+ public int getAllocatedVCores() {
+ return allocatedVCores;
+ }
+
+}
diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/webapp/dao/ContainerInfo.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/webapp/dao/ContainerInfo.java
new file mode 100644
index 0000000..019c525
--- /dev/null
+++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/webapp/dao/ContainerInfo.java
@@ -0,0 +1,118 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.yarn.server.webapp.dao;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.apache.hadoop.yarn.api.records.ContainerReport;
+import org.apache.hadoop.yarn.api.records.ContainerState;
+import org.apache.hadoop.yarn.api.records.Priority;
+import org.apache.hadoop.yarn.util.Times;
+
+@XmlRootElement(name = "container")
+@XmlAccessorType(XmlAccessType.FIELD)
+public class ContainerInfo {
+
+ protected String containerId;
+ protected int allocatedMB;
+ protected int allocatedVCores;
+ protected String assignedNodeId;
+ protected Priority priority;
+ protected long startedTime;
+ protected long finishedTime;
+ protected long elapsedTime;
+ protected String diagnosticsInfo;
+ protected String logUrl;
+ protected int containerExitStatus;
+ protected ContainerState containerState;
+
+ public ContainerInfo() {
+ // JAXB needs this
+ }
+
+ public ContainerInfo(ContainerReport container) {
+ 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();
+ startedTime = container.getStartTime();
+ finishedTime = container.getFinishTime();
+ elapsedTime = Times.elapsed(startedTime, finishedTime);
+ diagnosticsInfo = container.getDiagnosticsInfo();
+ logUrl = container.getLogUrl();
+ containerExitStatus = container.getContainerExitStatus();
+ containerState = container.getContainerState();
+ }
+
+ public String getContainerId() {
+ return containerId;
+ }
+
+ public int getAllocatedMB() {
+ return allocatedMB;
+ }
+
+ public int getAllocatedVCores() {
+ return allocatedVCores;
+ }
+
+ public String getAssignedNodeId() {
+ return assignedNodeId;
+ }
+
+ public Priority getPriority() {
+ return priority;
+ }
+
+ public long getStartedTime() {
+ return startedTime;
+ }
+
+ public long getFinishedTime() {
+ return finishedTime;
+ }
+
+ public long getElapsedTime() {
+ return elapsedTime;
+ }
+
+ public String getDiagnosticsInfo() {
+ return diagnosticsInfo;
+ }
+
+ public String getLogUrl() {
+ return logUrl;
+ }
+
+ public int getContainerExitStatus() {
+ return containerExitStatus;
+ }
+
+ public ContainerState getContainerState() {
+ return containerState;
+ }
+
+}