|
@@ -18,9 +18,6 @@
|
|
|
|
|
|
package org.apache.ambari.server.state.svccomphost;
|
|
|
|
|
|
-import java.lang.reflect.Field;
|
|
|
-import java.lang.reflect.InvocationTargetException;
|
|
|
-import java.lang.reflect.Method;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Collections;
|
|
|
import java.util.HashMap;
|
|
@@ -28,8 +25,6 @@ import java.util.HashSet;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Set;
|
|
|
-import java.util.concurrent.ExecutorService;
|
|
|
-import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
import javax.persistence.EntityManager;
|
|
|
|
|
@@ -795,7 +790,6 @@ public class ServiceComponentHostTest {
|
|
|
|
|
|
makeConfig(cluster, "foo", "version1",
|
|
|
new HashMap<String,String>() {{ put("a", "c"); }}, new HashMap<String, Map<String,String>>());
|
|
|
- waitToStaleConfigsCacheClear();
|
|
|
|
|
|
// HDP-x/HDFS does not define type 'foo', so changes do not count to stale
|
|
|
Assert.assertFalse(sch1.convertToResponse(null).isStaleConfig());
|
|
@@ -803,7 +797,6 @@ public class ServiceComponentHostTest {
|
|
|
|
|
|
makeConfig(cluster, "hdfs-site", "version1",
|
|
|
new HashMap<String,String>() {{ put("a", "b"); }}, new HashMap<String, Map<String,String>>());
|
|
|
- waitToStaleConfigsCacheClear();
|
|
|
|
|
|
// HDP-x/HDFS/hdfs-site is not on the actual, but it is defined, so it is stale
|
|
|
Assert.assertTrue(sch1.convertToResponse(null).isStaleConfig());
|
|
@@ -812,23 +805,11 @@ public class ServiceComponentHostTest {
|
|
|
actual.put("hdfs-site", new HashMap<String, String>() {{ put ("tag", "version1"); }});
|
|
|
|
|
|
sch1.updateActualConfigs(actual);
|
|
|
- // previous value from cache
|
|
|
- Assert.assertTrue(sch1.convertToResponse(null).isStaleConfig());
|
|
|
- //reset restartRequired flag + invalidating isStale cache
|
|
|
- // after start/restart command execution completed
|
|
|
- sch1.setRestartRequired(false);
|
|
|
- waitToStaleConfigsCacheClear();
|
|
|
// HDP-x/HDFS/hdfs-site up to date, only for sch1
|
|
|
Assert.assertFalse(sch1.convertToResponse(null).isStaleConfig());
|
|
|
Assert.assertTrue(sch2.convertToResponse(null).isStaleConfig());
|
|
|
|
|
|
sch2.updateActualConfigs(actual);
|
|
|
- // previous value from cache
|
|
|
- Assert.assertTrue(sch2.convertToResponse(null).isStaleConfig());
|
|
|
- //reset restartRequired flag + invalidating isStale cache(
|
|
|
- // after start/restart command execution completed)
|
|
|
- sch2.setRestartRequired(false);
|
|
|
- waitToStaleConfigsCacheClear();
|
|
|
// HDP-x/HDFS/hdfs-site up to date for both
|
|
|
Assert.assertFalse(sch1.convertToResponse(null).isStaleConfig());
|
|
|
Assert.assertFalse(sch2.convertToResponse(null).isStaleConfig());
|
|
@@ -836,7 +817,6 @@ public class ServiceComponentHostTest {
|
|
|
makeConfig(cluster, "hdfs-site", "version2",
|
|
|
new HashMap<String, String>() {{ put("dfs.journalnode.http-address", "http://foo"); }},
|
|
|
new HashMap<String, Map<String,String>>());
|
|
|
- waitToStaleConfigsCacheClear();
|
|
|
|
|
|
// HDP-x/HDFS/hdfs-site updated to changed property
|
|
|
Assert.assertTrue(sch1.convertToResponse(null).isStaleConfig());
|
|
@@ -849,7 +829,6 @@ public class ServiceComponentHostTest {
|
|
|
// after start/restart command execution completed
|
|
|
sch1.setRestartRequired(false);
|
|
|
sch2.setRestartRequired(false);
|
|
|
- waitToStaleConfigsCacheClear();
|
|
|
// HDP-x/HDFS/hdfs-site updated to changed property
|
|
|
Assert.assertFalse(sch1.convertToResponse(null).isStaleConfig());
|
|
|
Assert.assertFalse(sch2.convertToResponse(null).isStaleConfig());
|
|
@@ -870,7 +849,6 @@ public class ServiceComponentHostTest {
|
|
|
new HashMap<Long, Host>() {{ put(hostEntity.getHostId(), host); }});
|
|
|
configGroup.persist();
|
|
|
cluster.addConfigGroup(configGroup);
|
|
|
- waitToStaleConfigsCacheClear();
|
|
|
|
|
|
// HDP-x/HDFS/hdfs-site updated host to changed property
|
|
|
Assert.assertTrue(sch1.convertToResponse(null).isStaleConfig());
|
|
@@ -878,23 +856,11 @@ public class ServiceComponentHostTest {
|
|
|
|
|
|
actual.get("hdfs-site").put(configGroup.getId().toString(), "version3");
|
|
|
sch2.updateActualConfigs(actual);
|
|
|
- // previous value from cache
|
|
|
- Assert.assertTrue(sch2.convertToResponse(null).isStaleConfig());
|
|
|
- //reset restartRequired flag + invalidating isStale cache
|
|
|
- // after start/restart command execution completed
|
|
|
- sch2.setRestartRequired(false);
|
|
|
- waitToStaleConfigsCacheClear();
|
|
|
// HDP-x/HDFS/hdfs-site updated host to changed property
|
|
|
Assert.assertTrue(sch1.convertToResponse(null).isStaleConfig());
|
|
|
Assert.assertFalse(sch2.convertToResponse(null).isStaleConfig());
|
|
|
|
|
|
sch1.updateActualConfigs(actual);
|
|
|
- // previous value from cache
|
|
|
- Assert.assertTrue(sch1.convertToResponse(null).isStaleConfig());
|
|
|
- //reset restartRequired flag + invalidating isStale cache
|
|
|
- // after start/restart command execution completed
|
|
|
- sch1.setRestartRequired(false);
|
|
|
- waitToStaleConfigsCacheClear();
|
|
|
// HDP-x/HDFS/hdfs-site updated host to changed property
|
|
|
Assert.assertFalse(sch1.convertToResponse(null).isStaleConfig());
|
|
|
Assert.assertFalse(sch2.convertToResponse(null).isStaleConfig());
|
|
@@ -906,7 +872,6 @@ public class ServiceComponentHostTest {
|
|
|
put("dfs_namenode_name_dir", "/foo3"); // HDFS only
|
|
|
put("mapred_log_dir_prefix", "/foo2"); // MR2 only
|
|
|
}}, new HashMap<String, Map<String,String>>());
|
|
|
- waitToStaleConfigsCacheClear();
|
|
|
|
|
|
Assert.assertTrue(sch1.convertToResponse(null).isStaleConfig());
|
|
|
Assert.assertTrue(sch2.convertToResponse(null).isStaleConfig());
|
|
@@ -918,7 +883,6 @@ public class ServiceComponentHostTest {
|
|
|
put("a", "b");
|
|
|
put("fs.trash.interval", "360"); // HDFS only
|
|
|
}}, new HashMap<String, Map<String,String>>());
|
|
|
- waitToStaleConfigsCacheClear();
|
|
|
|
|
|
Assert.assertTrue(sch1.convertToResponse(null).isStaleConfig());
|
|
|
Assert.assertTrue(sch2.convertToResponse(null).isStaleConfig());
|
|
@@ -953,17 +917,10 @@ public class ServiceComponentHostTest {
|
|
|
tags.put(id.toString(), "version2");
|
|
|
actual.put("core-site", tags);
|
|
|
sch3.updateActualConfigs(actual);
|
|
|
- // previous value from cache
|
|
|
- Assert.assertTrue(sch3.convertToResponse(null).isStaleConfig());
|
|
|
- //reset restartRequired flag + invalidating isStale cache
|
|
|
- // after start/restart command execution completed
|
|
|
- sch3.setRestartRequired(false);
|
|
|
- waitToStaleConfigsCacheClear();
|
|
|
|
|
|
Assert.assertFalse(sch3.convertToResponse(null).isStaleConfig());
|
|
|
|
|
|
cluster.deleteConfigGroup(id);
|
|
|
- waitToStaleConfigsCacheClear();
|
|
|
Assert.assertNull(cluster.getConfigGroups().get(id));
|
|
|
|
|
|
sch3.updateActualConfigs(actual);
|
|
@@ -971,12 +928,6 @@ public class ServiceComponentHostTest {
|
|
|
|
|
|
tags.remove(id.toString());
|
|
|
sch3.updateActualConfigs(actual);
|
|
|
- // previous value from cache
|
|
|
- Assert.assertTrue(sch3.convertToResponse(null).isStaleConfig());
|
|
|
- //reset restartRequired flag + invalidating isStale cache
|
|
|
- // after start/restart command execution completed
|
|
|
- sch3.setRestartRequired(false);
|
|
|
- waitToStaleConfigsCacheClear();
|
|
|
Assert.assertFalse(sch3.convertToResponse(null).isStaleConfig());
|
|
|
}
|
|
|
|
|
@@ -1042,7 +993,6 @@ public class ServiceComponentHostTest {
|
|
|
put("a", "true");
|
|
|
}});
|
|
|
}});
|
|
|
- waitToStaleConfigsCacheClear();
|
|
|
// HDP-x/HDFS does not define type 'foo', so changes do not count to stale
|
|
|
Assert.assertFalse(sch1.convertToResponse(null).isStaleConfig());
|
|
|
Assert.assertFalse(sch2.convertToResponse(null).isStaleConfig());
|
|
@@ -1052,7 +1002,6 @@ public class ServiceComponentHostTest {
|
|
|
put("mapred-site", new HashMap<String,String>() {{ put("tag", "version1"); }});
|
|
|
}};
|
|
|
sch3.setRestartRequired(false);
|
|
|
- waitToStaleConfigsCacheClear();
|
|
|
sch3.updateActualConfigs(actual);
|
|
|
Assert.assertFalse(sch3.convertToResponse(null).isStaleConfig());
|
|
|
|
|
@@ -1067,7 +1016,6 @@ public class ServiceComponentHostTest {
|
|
|
sch1.setRestartRequired(false);
|
|
|
sch2.setRestartRequired(false);
|
|
|
sch3.setRestartRequired(false);
|
|
|
- waitToStaleConfigsCacheClear();
|
|
|
Assert.assertTrue(sch1.convertToResponse(null).isStaleConfig());
|
|
|
Assert.assertTrue(sch2.convertToResponse(null).isStaleConfig());
|
|
|
Assert.assertFalse(sch3.convertToResponse(null).isStaleConfig());
|
|
@@ -1083,7 +1031,6 @@ public class ServiceComponentHostTest {
|
|
|
sch1.setRestartRequired(false);
|
|
|
sch2.setRestartRequired(false);
|
|
|
sch3.setRestartRequired(false);
|
|
|
- waitToStaleConfigsCacheClear();
|
|
|
Assert.assertTrue(sch1.convertToResponse(null).isStaleConfig());
|
|
|
Assert.assertTrue(sch2.convertToResponse(null).isStaleConfig());
|
|
|
Assert.assertFalse(sch3.convertToResponse(null).isStaleConfig());
|
|
@@ -1096,7 +1043,6 @@ public class ServiceComponentHostTest {
|
|
|
sch1.setRestartRequired(false);
|
|
|
sch2.setRestartRequired(false);
|
|
|
sch3.setRestartRequired(false);
|
|
|
- waitToStaleConfigsCacheClear();
|
|
|
Assert.assertTrue(sch1.convertToResponse(null).isStaleConfig());
|
|
|
Assert.assertTrue(sch2.convertToResponse(null).isStaleConfig());
|
|
|
Assert.assertFalse(sch3.convertToResponse(null).isStaleConfig());
|
|
@@ -1212,20 +1158,4 @@ public class ServiceComponentHostTest {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- /*
|
|
|
- Stale configs cache invalidating in separate thread, so sometimes it can not be cleared in time before check.
|
|
|
- So it is needed to wait until thread with cache invalidating complete his work.
|
|
|
- */
|
|
|
- private void waitToStaleConfigsCacheClear() throws NoSuchFieldException, InterruptedException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
|
|
|
- Field f = ConfigHelper.class.getDeclaredField("cacheInvalidationExecutor");
|
|
|
- f.setAccessible(true);
|
|
|
- ExecutorService configHelperExecutor = (ExecutorService) f.get(configHelper);
|
|
|
- configHelperExecutor.shutdown();
|
|
|
- configHelperExecutor.awaitTermination(10, TimeUnit.SECONDS);
|
|
|
-
|
|
|
- Method m = ConfigHelper.class.getDeclaredMethod("createCacheInvalidationExecutor");
|
|
|
- m.setAccessible(true);
|
|
|
- f.set(configHelper, m.invoke(configHelper));
|
|
|
- }
|
|
|
}
|