2121import static org .apache .hadoop .yarn .util .StringHelper .join ;
2222import static org .apache .hadoop .yarn .webapp .YarnWebParams .APPLICATION_ID ;
2323import static org .apache .hadoop .yarn .webapp .YarnWebParams .WEB_UI_TYPE ;
24- import static org .apache .hadoop .yarn .webapp .view .JQueryUI ._INFO_WRAP ;
2524import java .security .PrivilegedExceptionAction ;
2625import java .util .Collection ;
27- import java .util .List ;
28-
2926import org .apache .commons .lang .StringEscapeUtils ;
3027import org .apache .commons .logging .Log ;
3128import org .apache .commons .logging .LogFactory ;
3936import org .apache .hadoop .yarn .api .records .ApplicationAttemptReport ;
4037import org .apache .hadoop .yarn .api .records .ApplicationId ;
4138import org .apache .hadoop .yarn .api .records .ApplicationReport ;
42- import org .apache .hadoop .yarn .api .records .ApplicationResourceUsageReport ;
4339import org .apache .hadoop .yarn .api .records .ContainerId ;
4440import org .apache .hadoop .yarn .api .records .ContainerReport ;
4541import org .apache .hadoop .yarn .api .records .FinalApplicationStatus ;
46- import org .apache .hadoop .yarn .api .records .Resource ;
47- import org .apache .hadoop .yarn .api .records .ResourceRequest ;
4842import org .apache .hadoop .yarn .api .records .YarnApplicationState ;
4943import org .apache .hadoop .yarn .conf .YarnConfiguration ;
5044import org .apache .hadoop .yarn .exceptions .ContainerNotFoundException ;
5347import org .apache .hadoop .yarn .server .webapp .dao .ContainerInfo ;
5448import org .apache .hadoop .yarn .util .Apps ;
5549import org .apache .hadoop .yarn .util .Times ;
56- import org .apache .hadoop .yarn .util .resource .Resources ;
5750import org .apache .hadoop .yarn .webapp .YarnWebParams ;
5851import org .apache .hadoop .yarn .webapp .hamlet .Hamlet ;
59- import org .apache .hadoop .yarn .webapp .hamlet .Hamlet .DIV ;
6052import org .apache .hadoop .yarn .webapp .hamlet .Hamlet .TABLE ;
6153import org .apache .hadoop .yarn .webapp .hamlet .Hamlet .TBODY ;
6254import org .apache .hadoop .yarn .webapp .view .HtmlBlock ;
@@ -69,9 +61,11 @@ public class AppBlock extends HtmlBlock {
6961 private static final Log LOG = LogFactory .getLog (AppBlock .class );
7062 protected ApplicationBaseProtocol appBaseProt ;
7163 protected Configuration conf ;
64+ protected ApplicationId appID = null ;
7265
7366 @ Inject
74- AppBlock (ApplicationBaseProtocol appBaseProt , ViewContext ctx , Configuration conf ) {
67+ protected AppBlock (ApplicationBaseProtocol appBaseProt , ViewContext ctx ,
68+ Configuration conf ) {
7569 super (ctx );
7670 this .appBaseProt = appBaseProt ;
7771 this .conf = conf ;
@@ -86,7 +80,6 @@ protected void render(Block html) {
8680 return ;
8781 }
8882
89- ApplicationId appID = null ;
9083 try {
9184 appID = Apps .toAppID (aid );
9285 } catch (Exception e ) {
@@ -213,31 +206,7 @@ public Collection<ApplicationAttemptReport> run() throws Exception {
213206 return ;
214207 }
215208
216- //TODO:YARN-3284
217- //The preemption metrics will be exposed from ApplicationReport
218- // and ApplicationAttemptReport
219- ApplicationResourceUsageReport usageReport =
220- appReport .getApplicationResourceUsageReport ();
221- DIV <Hamlet > pdiv = html .
222- _ (InfoBlock .class ).
223- div (_INFO_WRAP );
224- info ("Application Overview" ).clear ();
225- info ("Application Metrics" )
226- ._ ("Total Resource Preempted:" ,
227- Resources .none ()) // TODO: YARN-3284
228- ._ ("Total Number of Non-AM Containers Preempted:" ,
229- String .valueOf (0 )) // TODO: YARN-3284
230- ._ ("Total Number of AM Containers Preempted:" ,
231- String .valueOf (0 )) // TODO: YARN-3284
232- ._ ("Resource Preempted from Current Attempt:" ,
233- Resources .none ()) // TODO: YARN-3284
234- ._ ("Number of Non-AM Containers Preempted from Current Attempt:" ,
235- 0 ) // TODO: YARN-3284
236- ._ ("Aggregate Resource Allocation:" ,
237- String .format ("%d MB-seconds, %d vcore-seconds" , usageReport == null
238- ? 0 : usageReport .getMemorySeconds (), usageReport == null ? 0
239- : usageReport .getVcoreSeconds ()));
240- pdiv ._ ();
209+ createApplicationMetricsTable (html );
241210
242211 html ._ (InfoBlock .class );
243212
@@ -319,49 +288,6 @@ public ContainerReport run() throws Exception {
319288 ._ ("var attemptsTableData=" + attemptsTableData )._ ();
320289
321290 tbody ._ ()._ ();
322-
323- if (webUiType != null && webUiType .equals (YarnWebParams .RM_WEB_UI )) {
324- createResourceRequestsTable (html , null ); // TODO:YARN-3284
325- }
326- }
327-
328- //TODO:YARN-3284
329- //The resource requests metrics will be exposed from attemptReport
330- private void createResourceRequestsTable (Block html , List <ResourceRequest > resouceRequests ) {
331- TBODY <TABLE <Hamlet >> tbody =
332- html .table ("#ResourceRequests" ).thead ().tr ()
333- .th (".priority" , "Priority" )
334- .th (".resourceName" , "ResourceName" )
335- .th (".totalResource" , "Capability" )
336- .th (".numContainers" , "NumContainers" )
337- .th (".relaxLocality" , "RelaxLocality" )
338- .th (".nodeLabelExpression" , "NodeLabelExpression" )._ ()._ ().tbody ();
339-
340- Resource totalResource = Resource .newInstance (0 , 0 );
341- if (resouceRequests != null ) {
342- for (ResourceRequest request : resouceRequests ) {
343- if (request .getNumContainers () == 0 ) {
344- continue ;
345- }
346-
347- tbody .tr ()
348- .td (String .valueOf (request .getPriority ()))
349- .td (request .getResourceName ())
350- .td (String .valueOf (request .getCapability ()))
351- .td (String .valueOf (request .getNumContainers ()))
352- .td (String .valueOf (request .getRelaxLocality ()))
353- .td (request .getNodeLabelExpression () == null ? "N/A" : request
354- .getNodeLabelExpression ())._ ();
355- if (request .getResourceName ().equals (ResourceRequest .ANY )) {
356- Resources .addTo (totalResource ,
357- Resources .multiply (request .getCapability (),
358- request .getNumContainers ()));
359- }
360- }
361- }
362- html .div ().$class ("totalResourceRequests" )
363- .h3 ("Total Outstanding Resource Requests: " + totalResource )._ ();
364- tbody ._ ()._ ();
365291 }
366292
367293 private String clarifyAppState (YarnApplicationState state ) {
@@ -389,4 +315,9 @@ private String clairfyAppFinalStatus(FinalApplicationStatus status) {
389315 }
390316 return status .toString ();
391317 }
318+
319+ // The preemption metrics only need to be shown in RM WebUI
320+ protected void createApplicationMetricsTable (Block html ) {
321+
322+ }
392323}
0 commit comments