Map<String, String> configs = new HashMap<String, String>();
configs.put(NAMENODE_PORT_V1, "localhost:${ambari.dfs.datanode.http.port}");
configs.put(DATANODE_PORT, "localhost:70075");
configs.put("ambari.dfs.datanode.http.port", "70070");
ConfigurationRequest cr = new ConfigurationRequest(clusterName,
"hdfs-site", "version1", configs);
ClusterRequest crequest = new ClusterRequest(null, clusterName, null, null);
crequest.setDesiredConfig(cr);
controller.updateClusters(Collections.singleton(crequest), new HashMap<String,String>());
} else {
Map<String, String> configs = new HashMap<String, String>();
configs.put(NAMENODE_PORT_V2, "localhost:70071");
configs.put(DATANODE_PORT, "localhost:70075");
ConfigurationRequest cr = new ConfigurationRequest(clusterName,
"hdfs-site", "version2", configs);
ClusterRequest crequest = new ClusterRequest(null, clusterName, null, null);
crequest.setDesiredConfig(cr);
controller.updateClusters(Collections.singleton(crequest), new HashMap<String,String>());