浏览代码

YARN-6219. Fix conf usage in NMWebServer unit tests. Contributed by Jason Lowe.

Nathan Roberts 7 年之前
父节点
当前提交
b3a478832a

+ 6 - 6
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/webapp/TestNMWebServer.java

@@ -86,8 +86,9 @@ public class TestNMWebServer {
   }
   }
 
 
   private int startNMWebAppServer(String webAddr) {
   private int startNMWebAppServer(String webAddr) {
+    Configuration conf = new Configuration();
     Context nmContext = new NodeManager.NMContext(null, null, null, null,
     Context nmContext = new NodeManager.NMContext(null, null, null, null,
-        null, false, null);
+        null, false, conf);
     ResourceView resourceView = new ResourceView() {
     ResourceView resourceView = new ResourceView() {
       @Override
       @Override
       public long getVmemAllocatedForContainers() {
       public long getVmemAllocatedForContainers() {
@@ -110,7 +111,6 @@ public class TestNMWebServer {
         return true;
         return true;
       }
       }
     };
     };
-    Configuration conf = new Configuration();
     conf.set(YarnConfiguration.NM_LOCAL_DIRS, testRootDir.getAbsolutePath());
     conf.set(YarnConfiguration.NM_LOCAL_DIRS, testRootDir.getAbsolutePath());
     conf.set(YarnConfiguration.NM_LOG_DIRS, testLogDir.getAbsolutePath());
     conf.set(YarnConfiguration.NM_LOG_DIRS, testLogDir.getAbsolutePath());
     NodeHealthCheckerService healthChecker = createNodeHealthCheckerService(conf);
     NodeHealthCheckerService healthChecker = createNodeHealthCheckerService(conf);
@@ -149,8 +149,9 @@ public class TestNMWebServer {
 
 
   @Test
   @Test
   public void testNMWebApp() throws IOException, YarnException {
   public void testNMWebApp() throws IOException, YarnException {
+    Configuration conf = new Configuration();
     Context nmContext = new NodeManager.NMContext(null, null, null, null,
     Context nmContext = new NodeManager.NMContext(null, null, null, null,
-        null, false, null);
+        null, false, conf);
     ResourceView resourceView = new ResourceView() {
     ResourceView resourceView = new ResourceView() {
       @Override
       @Override
       public long getVmemAllocatedForContainers() {
       public long getVmemAllocatedForContainers() {
@@ -173,7 +174,6 @@ public class TestNMWebServer {
         return true;
         return true;
       }
       }
     };
     };
-    Configuration conf = new Configuration();
     conf.set(YarnConfiguration.NM_LOCAL_DIRS, testRootDir.getAbsolutePath());
     conf.set(YarnConfiguration.NM_LOCAL_DIRS, testRootDir.getAbsolutePath());
     conf.set(YarnConfiguration.NM_LOG_DIRS, testLogDir.getAbsolutePath());
     conf.set(YarnConfiguration.NM_LOG_DIRS, testLogDir.getAbsolutePath());
     NodeHealthCheckerService healthChecker = createNodeHealthCheckerService(conf);
     NodeHealthCheckerService healthChecker = createNodeHealthCheckerService(conf);
@@ -218,8 +218,8 @@ public class TestNMWebServer {
       Context context = mock(Context.class);
       Context context = mock(Context.class);
       Container container =
       Container container =
           new ContainerImpl(conf, dispatcher, launchContext,
           new ContainerImpl(conf, dispatcher, launchContext,
-            null, metrics,
-            BuilderUtils.newContainerTokenIdentifier(containerToken), context) {
+            null, metrics, BuilderUtils.newContainerTokenIdentifier(
+                containerToken), context) {
 
 
             @Override
             @Override
             public ContainerState getContainerState() {
             public ContainerState getContainerState() {