|
@@ -38,10 +38,10 @@ import org.apache.hadoop.yarn.util.resource.Resources;
|
|
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet;
|
|
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.DIV;
|
|
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TABLE;
|
|
import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TABLE;
|
|
-import org.apache.hadoop.yarn.webapp.hamlet.Hamlet.TBODY;
|
|
|
|
import org.apache.hadoop.yarn.webapp.util.WebAppUtils;
|
|
import org.apache.hadoop.yarn.webapp.util.WebAppUtils;
|
|
import org.apache.hadoop.yarn.webapp.view.InfoBlock;
|
|
import org.apache.hadoop.yarn.webapp.view.InfoBlock;
|
|
import com.google.inject.Inject;
|
|
import com.google.inject.Inject;
|
|
|
|
+import java.util.List;
|
|
|
|
|
|
public class RMAppAttemptBlock extends AppAttemptBlock{
|
|
public class RMAppAttemptBlock extends AppAttemptBlock{
|
|
|
|
|
|
@@ -55,52 +55,67 @@ public class RMAppAttemptBlock extends AppAttemptBlock{
|
|
this.conf = conf;
|
|
this.conf = conf;
|
|
}
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
|
- protected void render(Block html) {
|
|
|
|
- super.render(html);
|
|
|
|
- createContainerLocalityTable(html);
|
|
|
|
- createResourceRequestsTable(html);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
private void createResourceRequestsTable(Block html) {
|
|
private void createResourceRequestsTable(Block html) {
|
|
AppInfo app =
|
|
AppInfo app =
|
|
new AppInfo(rm, rm.getRMContext().getRMApps()
|
|
new AppInfo(rm, rm.getRMContext().getRMApps()
|
|
.get(this.appAttemptId.getApplicationId()), true,
|
|
.get(this.appAttemptId.getApplicationId()), true,
|
|
WebAppUtils.getHttpSchemePrefix(conf));
|
|
WebAppUtils.getHttpSchemePrefix(conf));
|
|
- TBODY<TABLE<Hamlet>> tbody =
|
|
|
|
- html.table("#ResourceRequests").thead().tr()
|
|
|
|
- .th(".priority", "Priority")
|
|
|
|
- .th(".resourceName", "ResourceName")
|
|
|
|
- .th(".totalResource", "Capability")
|
|
|
|
- .th(".numContainers", "NumContainers")
|
|
|
|
- .th(".relaxLocality", "RelaxLocality")
|
|
|
|
- .th(".nodeLabelExpression", "NodeLabelExpression")._()._().tbody();
|
|
|
|
|
|
|
|
|
|
+ List<ResourceRequest> resourceRequests = app.getResourceRequests();
|
|
|
|
+ if (resourceRequests == null || resourceRequests.isEmpty()) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ DIV<Hamlet> div = html.div(_INFO_WRAP);
|
|
|
|
+ TABLE<DIV<Hamlet>> table =
|
|
|
|
+ div.h3("Total Outstanding Resource Requests: "
|
|
|
|
+ + getTotalResource(resourceRequests)).table(
|
|
|
|
+ "#ResourceRequests");
|
|
|
|
+
|
|
|
|
+ table.tr().
|
|
|
|
+ th(_TH, "Priority").
|
|
|
|
+ th(_TH, "ResourceName").
|
|
|
|
+ th(_TH, "Capability").
|
|
|
|
+ th(_TH, "NumContainers").
|
|
|
|
+ th(_TH, "RelaxLocality").
|
|
|
|
+ th(_TH, "NodeLabelExpression").
|
|
|
|
+ _();
|
|
|
|
+
|
|
|
|
+ boolean odd = false;
|
|
|
|
+ for (ResourceRequest request : resourceRequests) {
|
|
|
|
+ if (request.getNumContainers() == 0) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ table.tr((odd = !odd) ? _ODD : _EVEN)
|
|
|
|
+ .td(String.valueOf(request.getPriority()))
|
|
|
|
+ .td(request.getResourceName())
|
|
|
|
+ .td(String.valueOf(request.getCapability()))
|
|
|
|
+ .td(String.valueOf(request.getNumContainers()))
|
|
|
|
+ .td(String.valueOf(request.getRelaxLocality()))
|
|
|
|
+ .td(request.getNodeLabelExpression() == null ? "N/A" : request
|
|
|
|
+ .getNodeLabelExpression())._();
|
|
|
|
+ }
|
|
|
|
+ table._();
|
|
|
|
+ div._();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private Resource getTotalResource(List<ResourceRequest> requests) {
|
|
Resource totalResource = Resource.newInstance(0, 0);
|
|
Resource totalResource = Resource.newInstance(0, 0);
|
|
- if (app.getResourceRequests() != null) {
|
|
|
|
- for (ResourceRequest request : app.getResourceRequests()) {
|
|
|
|
- if (request.getNumContainers() == 0) {
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- tbody.tr()
|
|
|
|
- .td(String.valueOf(request.getPriority()))
|
|
|
|
- .td(request.getResourceName())
|
|
|
|
- .td(String.valueOf(request.getCapability()))
|
|
|
|
- .td(String.valueOf(request.getNumContainers()))
|
|
|
|
- .td(String.valueOf(request.getRelaxLocality()))
|
|
|
|
- .td(request.getNodeLabelExpression() == null ? "N/A" : request
|
|
|
|
- .getNodeLabelExpression())._();
|
|
|
|
- if (request.getResourceName().equals(ResourceRequest.ANY)) {
|
|
|
|
- Resources.addTo(totalResource,
|
|
|
|
- Resources.multiply(request.getCapability(),
|
|
|
|
- request.getNumContainers()));
|
|
|
|
- }
|
|
|
|
|
|
+ if (requests == null) {
|
|
|
|
+ return totalResource;
|
|
|
|
+ }
|
|
|
|
+ for (ResourceRequest request : requests) {
|
|
|
|
+ if (request.getNumContainers() == 0) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ if (request.getResourceName().equals(ResourceRequest.ANY)) {
|
|
|
|
+ Resources.addTo(
|
|
|
|
+ totalResource,
|
|
|
|
+ Resources.multiply(request.getCapability(),
|
|
|
|
+ request.getNumContainers()));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- html.div().$class("totalResourceRequests")
|
|
|
|
- .h3("Total Outstanding Resource Requests: " + totalResource)._();
|
|
|
|
- tbody._()._();
|
|
|
|
|
|
+ return totalResource;
|
|
}
|
|
}
|
|
|
|
|
|
private void createContainerLocalityTable(Block html) {
|
|
private void createContainerLocalityTable(Block html) {
|
|
@@ -176,4 +191,10 @@ public class RMAppAttemptBlock extends AppAttemptBlock{
|
|
}
|
|
}
|
|
return attempt;
|
|
return attempt;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ protected void createTablesForAttemptMetrics(Block html) {
|
|
|
|
+ createContainerLocalityTable(html);
|
|
|
|
+ createResourceRequestsTable(html);
|
|
|
|
+ }
|
|
}
|
|
}
|