diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/NodesPage.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/NodesPage.java index 446a81098f..169cfea6e9 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/NodesPage.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/NodesPage.java @@ -175,7 +175,8 @@ protected void render(Block html) { .get(ResourceInformation.GPU_URI); long usedGPUs = 0; long availableGPUs = 0; - if (gpuIndex != null) { + if (gpuIndex != null && info.getUsedResource() != null + && info.getAvailableResource() != null) { usedGPUs = info.getUsedResource().getResource() .getResourceValue(ResourceInformation.GPU_URI); availableGPUs = info.getAvailableResource().getResource() diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestNodesPage.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestNodesPage.java index 1f6a8c0899..00ca6970dd 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestNodesPage.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestNodesPage.java @@ -19,12 +19,16 @@ import java.io.IOException; import java.io.PrintWriter; +import java.util.Map; import org.apache.hadoop.yarn.api.records.NodeState; +import org.apache.hadoop.yarn.api.records.ResourceInformation; import org.apache.hadoop.yarn.conf.YarnConfiguration; import org.apache.hadoop.yarn.server.resourcemanager.RMContext; import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager; import org.apache.hadoop.yarn.server.resourcemanager.webapp.NodesPage.NodesBlock; +import org.apache.hadoop.yarn.util.resource.CustomResourceTypesConfigurationProvider; +import org.apache.hadoop.yarn.util.resource.ResourceUtils; import org.apache.hadoop.yarn.webapp.test.WebAppTests; import org.junit.Before; import org.junit.Test; @@ -56,6 +60,10 @@ public class TestNodesPage { @Before public void setUp() throws Exception { + setUpInternal(false); + } + + private void setUpInternal(final boolean useDRC) throws Exception { final RMContext mockRMContext = TestRMWebApp.mockRMContext(3, numberOfRacks, numberOfNodesPerRack, 8 * TestRMWebApp.GiB); @@ -66,7 +74,7 @@ public void setUp() throws Exception { public void configure(Binder binder) { try { binder.bind(ResourceManager.class).toInstance( - TestRMWebApp.mockRm(mockRMContext)); + TestRMWebApp.mockRm(mockRMContext, useDRC)); } catch (IOException e) { throw new IllegalStateException(e); } @@ -101,7 +109,22 @@ public void testNodesBlockRenderForLostNodes() { Mockito.verify(writer, Mockito.times(numberOfThInMetricsTable)) .print("