new HashMap<String, String>() {{ put("dfs.journalnode.http-address", "http://goo"); }});
c.setVersionTag("version3");
c.persist();
cluster.addConfig(c);
//host.addDesiredConfig(cluster.getClusterId(), true, "user", c);
ConfigGroup configGroup = configGroupFactory.createNew(cluster, "g1",
"t1", "", new HashMap<String, Config>() {{ put("hdfs-site", c); }},
new HashMap<String, Host>() {{ put("h3", host); }});
configGroup.persist();
cluster.addConfigGroup(configGroup);
// HDP-x/HDFS/hdfs-site updated host to changed property
Assert.assertTrue(sch1.convertToResponse().isStaleConfig());
Assert.assertTrue(sch2.convertToResponse().isStaleConfig());
actual.get("hdfs-site").put(configGroup.getId().toString(), "version3");
sch2.updateActualConfigs(actual);
// previous value from cache
Assert.assertTrue(sch2.convertToResponse().isStaleConfig());
//reset restartRequired flag + invalidating isStale cache
// after start/restart command execution completed
sch2.setRestartRequired(false);
// HDP-x/HDFS/hdfs-site updated host to changed property
Assert.assertTrue(sch1.convertToResponse().isStaleConfig());
Assert.assertFalse(sch2.convertToResponse().isStaleConfig());
sch1.updateActualConfigs(actual);
// previous value from cache
Assert.assertTrue(sch1.convertToResponse().isStaleConfig());
//reset restartRequired flag + invalidating isStale cache
// after start/restart command execution completed
sch1.setRestartRequired(false);
// HDP-x/HDFS/hdfs-site updated host to changed property
Assert.assertFalse(sch1.convertToResponse().isStaleConfig());
Assert.assertFalse(sch2.convertToResponse().isStaleConfig());
// change 'global' property only affecting global/HDFS
makeConfig(cluster, "global", "version2",
new HashMap<String,String>() {{
put("a", "b");
put("dfs_namenode_name_dir", "/foo3"); // HDFS only
put("mapred_log_dir_prefix", "/foo2"); // MR2 only
}});
Assert.assertTrue(sch1.convertToResponse().isStaleConfig());
Assert.assertTrue(sch2.convertToResponse().isStaleConfig());
Assert.assertFalse(sch3.convertToResponse().isStaleConfig());
// Change core-site property, only HDFS property
makeConfig(cluster, "core-site", "version1",
new HashMap<String,String>() {{
put("a", "b");
put("fs.trash.interval", "360"); // HDFS only
}});
Assert.assertTrue(sch1.convertToResponse().isStaleConfig());
Assert.assertTrue(sch2.convertToResponse().isStaleConfig());
Assert.assertTrue(sch3.convertToResponse().isStaleConfig());
actual.put("core-site", new HashMap<String, String>() {{
put("tag", "version1");
}});
sch1.updateActualConfigs(actual);
final Config c1 = configFactory.createNew(cluster, "core-site",
new HashMap<String, String>() {{ put("fs.trash.interval", "400"); }});
c1.setVersionTag("version2");
c1.persist();
cluster.addConfig(c1);
configGroup = configGroupFactory.createNew(cluster, "g2",
"t2", "", new HashMap<String, Config>() {{ put("core-site", c1); }},
new HashMap<String, Host>() {{ put("h3", host); }});
configGroup.persist();
cluster.addConfigGroup(configGroup);
Assert.assertTrue(sch1.convertToResponse().isStaleConfig());
Assert.assertTrue(sch2.convertToResponse().isStaleConfig());
Assert.assertTrue(sch3.convertToResponse().isStaleConfig());
// Test actual configs are updated for deleted config group
Long id = configGroup.getId();
HashMap<String, String> tags = new HashMap<String, String>(2);
tags.put("tag", "version1");
tags.put(id.toString(), "version2");
actual.put("core-site", tags);
sch3.updateActualConfigs(actual);