3939import org .apache .hadoop .yarn .webapp .view .HtmlBlock ;
4040
4141import java .util .Collection ;
42+ import java .util .Map ;
4243
4344import static org .apache .hadoop .yarn .webapp .YarnWebParams .NODE_LABEL ;
4445import static org .apache .hadoop .yarn .webapp .YarnWebParams .NODE_STATE ;
@@ -90,9 +91,7 @@ protected void render(Block html) {
9091 .th (".mem" , "Phys Mem Used %" )
9192 .th (".vcores" , "VCores Used" )
9293 .th (".vcores" , "VCores Avail" )
93- .th (".vcores" , "Phys VCores Used %" )
94- .th (".gpus" , "GPUs Used" )
95- .th (".gpus" , "GPUs Avail" );
94+ .th (".vcores" , "Phys VCores Used %" );
9695 } else {
9796 trbody .th (".containers" , "Running Containers (G)" )
9897 .th (".allocationTags" , "Allocation Tags" )
@@ -102,14 +101,26 @@ protected void render(Block html) {
102101 .th (".vcores" , "VCores Used (G)" )
103102 .th (".vcores" , "VCores Avail (G)" )
104103 .th (".vcores" , "Phys VCores Used %" )
105- .th (".gpus" , "GPUs Used (G)" )
106- .th (".gpus" , "GPUs Avail (G)" )
107104 .th (".containers" , "Running Containers (O)" )
108105 .th (".mem" , "Mem Used (O)" )
109106 .th (".vcores" , "VCores Used (O)" )
110107 .th (".containers" , "Queued Containers" );
111108 }
112109
110+ for (Map .Entry <String , Integer > integerEntry :
111+ ResourceUtils .getResourceTypeIndex ().entrySet ()) {
112+ if (integerEntry .getKey ().equals (ResourceInformation .MEMORY_URI )
113+ || integerEntry .getKey ().equals (ResourceInformation .VCORES_URI )) {
114+ continue ;
115+ }
116+
117+ trbody .th ("." + integerEntry .getKey (),
118+ integerEntry .getKey () + " " + "Used" );
119+
120+ trbody .th ("." + integerEntry .getKey (),
121+ integerEntry .getKey () + " " + "Avail" );
122+ }
123+
113124 TBODY <TABLE <Hamlet >> tbody =
114125 trbody .th (".nodeManagerVersion" , "Version" ).__ ().__ ().tbody ();
115126
@@ -175,17 +186,7 @@ protected void render(Block html) {
175186 nodeTableData .append ("\" ,\" <a " ).append ("href='" + "//" + httpAddress )
176187 .append ("'>" ).append (httpAddress ).append ("</a>\" ," ).append ("\" " );
177188 }
178- Integer gpuIndex = ResourceUtils .getResourceTypeIndex ()
179- .get (ResourceInformation .GPU_URI );
180- long usedGPUs = 0 ;
181- long availableGPUs = 0 ;
182- if (gpuIndex != null && info .getUsedResource () != null
183- && info .getAvailableResource () != null ) {
184- usedGPUs = info .getUsedResource ().getResource ()
185- .getResourceValue (ResourceInformation .GPU_URI );
186- availableGPUs = info .getAvailableResource ().getResource ()
187- .getResourceValue (ResourceInformation .GPU_URI );
188- }
189+
189190 nodeTableData .append ("<br title='" )
190191 .append (String .valueOf (info .getLastHealthUpdate ())).append ("'>" )
191192 .append (Times .format (info .getLastHealthUpdate ())).append ("\" ,\" " )
@@ -205,10 +206,6 @@ protected void render(Block html) {
205206 .append (String .valueOf (info .getAvailableVirtualCores ()))
206207 .append ("\" ,\" " )
207208 .append (String .valueOf ((int ) info .getVcoreUtilization ()))
208- .append ("\" ,\" " )
209- .append (String .valueOf (usedGPUs ))
210- .append ("\" ,\" " )
211- .append (String .valueOf (availableGPUs ))
212209 .append ("\" ,\" " );
213210
214211 // If opportunistic containers are enabled, add extra fields.
@@ -226,6 +223,34 @@ protected void render(Block html) {
226223 .append ("\" ,\" " );
227224 }
228225
226+ for (Map .Entry <String , Integer > integerEntry :
227+ ResourceUtils .getResourceTypeIndex ().entrySet ()) {
228+ if (integerEntry .getKey ().equals (ResourceInformation .MEMORY_URI )
229+ || integerEntry .getKey ().equals (ResourceInformation .VCORES_URI )) {
230+ continue ;
231+ }
232+
233+ long usedCustomResource = 0 ;
234+ long availableCustomResource = 0 ;
235+
236+ String resourceName = integerEntry .getKey ();
237+ Integer index = integerEntry .getValue ();
238+
239+ if (index != null && info .getUsedResource () != null
240+ && info .getAvailableResource () != null ) {
241+ usedCustomResource = info .getUsedResource ().getResource ()
242+ .getResourceValue (resourceName );
243+ availableCustomResource = info .getAvailableResource ().getResource ()
244+ .getResourceValue (resourceName );
245+
246+ nodeTableData
247+ .append (usedCustomResource )
248+ .append ("\" ,\" " )
249+ .append (availableCustomResource )
250+ .append ("\" ,\" " );
251+ }
252+ }
253+
229254 nodeTableData .append (ni .getNodeManagerVersion ())
230255 .append ("\" ],\n " );
231256 }
0 commit comments