diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/AuxServices.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/AuxServices.java index 3fe3cfd16ef..77c4dd9a6cb 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/AuxServices.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/AuxServices.java @@ -262,7 +262,7 @@ public class AuxServices extends AbstractService } } s = AuxiliaryServiceWithCustomClassLoader.getInstance( - conf, className, dest.toString()); + new Configuration(conf), className, dest.toString()); } LOG.info("The aux service:" + sName + " are using the custom classloader"); @@ -273,7 +273,7 @@ public class AuxServices extends AbstractService if (sClass == null) { throw new RuntimeException("No class defined for " + sName); } - s = ReflectionUtils.newInstance(sClass, conf); + s = ReflectionUtils.newInstance(sClass, new Configuration(conf)); } if (s == null) { throw new RuntimeException("No object created for " + sName); @@ -294,7 +294,7 @@ public class AuxServices extends AbstractService stateStoreFs.mkdirs(storePath, storeDirPerms); s.setRecoveryPath(storePath); } - s.init(conf); + s.init(new Configuration(conf)); } catch (RuntimeException e) { LOG.error("Failed to initialize " + sName, e); throw e; diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/TestAuxServices.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/TestAuxServices.java index fcf92b509e0..ca0b32a7521 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/TestAuxServices.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/TestAuxServices.java @@ -678,4 +678,52 @@ public class TestAuxServices { super("RecoverableServiceB", "Bsrv"); } } + + static class ConfChangeAuxService extends AuxiliaryService + implements Service { + + ConfChangeAuxService() { + super("ConfChangeAuxService"); + } + + @Override + protected void serviceInit(Configuration conf) throws Exception { + conf.set("dummyConfig", "changedTestValue"); + super.serviceInit(conf); + } + + @Override + public void initializeApplication( + ApplicationInitializationContext initAppContext) { + } + + @Override + public void stopApplication(ApplicationTerminationContext stopAppContext) { + } + + @Override + public ByteBuffer getMetaData() { + return null; + } + } + + @Test + public void testAuxServicesConfChange() { + Configuration conf = new Configuration(); + conf.setStrings(YarnConfiguration.NM_AUX_SERVICES, + new String[]{"ConfChangeAuxService"}); + conf.setClass(String.format(YarnConfiguration.NM_AUX_SERVICE_FMT, + "ConfChangeAuxService"), ConfChangeAuxService.class, Service.class); + AuxServices aux = new AuxServices(MOCK_AUX_PATH_HANDLER, MOCK_CONTEXT, + MOCK_DEL_SERVICE); + conf.set("dummyConfig", "testValue"); + aux.init(conf); + aux.start(); + for (AuxiliaryService s : aux.getServices()) { + assertEquals(STARTED, s.getServiceState()); + assertEquals(conf.get("dummyConfig"), "testValue"); + } + + aux.stop(); + } }