|
@@ -21,12 +21,14 @@ import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.TreeMap;
|
|
|
+import java.util.HashMap;
|
|
|
|
|
|
import org.apache.ambari.server.AmbariException;
|
|
|
import org.apache.ambari.server.actionmanager.ActionManager;
|
|
|
import org.apache.ambari.server.state.Cluster;
|
|
|
import org.apache.ambari.server.state.Clusters;
|
|
|
import org.apache.ambari.server.state.Config;
|
|
|
+import org.apache.ambari.server.state.DesiredConfig;
|
|
|
import org.apache.ambari.server.state.Host;
|
|
|
import org.apache.ambari.server.state.HostState;
|
|
|
import org.apache.ambari.server.state.Service;
|
|
@@ -174,25 +176,53 @@ public class HeartbeatMonitor implements Runnable {
|
|
|
*/
|
|
|
public List<StatusCommand> generateStatusCommands(String hostname) throws AmbariException {
|
|
|
List<StatusCommand> cmds = new ArrayList<StatusCommand>();
|
|
|
+
|
|
|
for (Cluster cl : fsm.getClustersForHost(hostname)) {
|
|
|
- List<ServiceComponentHost> roleList = cl
|
|
|
- .getServiceComponentHosts(hostname);
|
|
|
- for (ServiceComponentHost sch : roleList) {
|
|
|
+
|
|
|
+ for (ServiceComponentHost sch : cl.getServiceComponentHosts(hostname)) {
|
|
|
String serviceName = sch.getServiceName();
|
|
|
if (LOG.isDebugEnabled()) {
|
|
|
- LOG.debug("Live status will include status of service " + serviceName +
|
|
|
- " of cluster " + cl.getClusterName());
|
|
|
+ LOG.debug("Live status will include status of service " + serviceName + " of cluster " + cl.getClusterName());
|
|
|
}
|
|
|
|
|
|
- Map<String, Config> configs = sch.getDesiredConfigs();
|
|
|
+ Map<String, Map<String, String>> configurations = new TreeMap<String, Map<String, String>>();
|
|
|
|
|
|
- Map<String, Map<String, String>> configurations =
|
|
|
- new TreeMap<String, Map<String, String>>();
|
|
|
+ // get the cluster config for type 'global'
|
|
|
+ // apply service overrides, if the tag is not the same
|
|
|
+ // apply host overrides, if any
|
|
|
|
|
|
- for (Config config : configs.values()) {
|
|
|
- if (config.getType().equals("global"))
|
|
|
- configurations.put(config.getType(),
|
|
|
- config.getProperties());
|
|
|
+ Config clusterConfig = cl.getDesiredConfigByType("global");
|
|
|
+ if (null != clusterConfig) {
|
|
|
+ // cluster config for 'global'
|
|
|
+ Map<String,String> props = new HashMap<String, String>(clusterConfig.getProperties());
|
|
|
+
|
|
|
+ // apply service overrides, only if the tag is not the same (for when service configs are overrides)
|
|
|
+ Service service = cl.getService(sch.getServiceName());
|
|
|
+ Config svcConfig = service.getDesiredConfigs().get("global");
|
|
|
+ if (null != svcConfig && !svcConfig.getVersionTag().equals(clusterConfig.getVersionTag())) {
|
|
|
+ props.putAll(svcConfig.getProperties());
|
|
|
+ }
|
|
|
+
|
|
|
+ // apply host overrides, if any
|
|
|
+ Host host = fsm.getHost(hostname);
|
|
|
+ DesiredConfig dc = host.getDesiredConfigs(cl.getClusterId()).get("global");
|
|
|
+ if (null != dc) {
|
|
|
+ Config hostConfig = cl.getConfig("global", dc.getVersion());
|
|
|
+ if (null != hostConfig) {
|
|
|
+ props.putAll(hostConfig.getProperties());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ configurations.put("global", props);
|
|
|
+ }
|
|
|
+
|
|
|
+ // HACK - if any service exists with global tag, and we have none, use
|
|
|
+ // that instead
|
|
|
+ if (configurations.isEmpty()) {
|
|
|
+ Service service = cl.getService(sch.getServiceName());
|
|
|
+ Config config = service.getDesiredConfigs().get("global");
|
|
|
+ if (null != config)
|
|
|
+ configurations.put("global", new HashMap<String,String>(config.getProperties()));
|
|
|
}
|
|
|
|
|
|
StatusCommand statusCmd = new StatusCommand();
|