Updated Branches: refs/heads/trunk 80751f135 -> 0df2b1817
AMBARI-4223. Cluster topology is hard-coded (ncole) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/0df2b181 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/0df2b181 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/0df2b181 Branch: refs/heads/trunk Commit: 0df2b18171763d484c7fea35aff4de2522ded27e Parents: 80751f1 Author: Nate Cole <[email protected]> Authored: Fri Jan 3 12:54:13 2014 -0500 Committer: Nate Cole <[email protected]> Committed: Fri Jan 3 13:18:13 2014 -0500 ---------------------------------------------------------------------- .../apache/ambari/server/utils/StageUtils.java | 64 +++++++++----------- .../ambari/server/utils/TestStageUtils.java | 11 +++- .../HDP/1.3.1/services/NONAME/metainfo.xml | 30 +++++++++ 3 files changed, 69 insertions(+), 36 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/0df2b181/ambari-server/src/main/java/org/apache/ambari/server/utils/StageUtils.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/utils/StageUtils.java b/ambari-server/src/main/java/org/apache/ambari/server/utils/StageUtils.java index 4ea8fa6..1c0a66c 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/utils/StageUtils.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/utils/StageUtils.java @@ -109,20 +109,16 @@ public class StageUtils { componentToClusterInfoKeyMap.put("HBASE_REGIONSERVER", "hbase_rs_hosts"); componentToClusterInfoKeyMap.put("HIVE_SERVER", "hive_server_host"); componentToClusterInfoKeyMap.put("OOZIE_SERVER", "oozie_server"); - componentToClusterInfoKeyMap.put("WEBHCAT_SERVER", - "webhcat_server_host"); - componentToClusterInfoKeyMap.put(Role.MYSQL_SERVER.toString(), - "hive_mysql_host"); + componentToClusterInfoKeyMap.put("WEBHCAT_SERVER", "webhcat_server_host"); + componentToClusterInfoKeyMap.put("MYSQL_SERVER", "hive_mysql_host"); componentToClusterInfoKeyMap.put("DASHBOARD", "dashboard_host"); componentToClusterInfoKeyMap.put("NAGIOS_SERVER", "nagios_server_host"); - componentToClusterInfoKeyMap.put("GANGLIA_SERVER", - "ganglia_server_host"); + componentToClusterInfoKeyMap.put("GANGLIA_SERVER", "ganglia_server_host"); componentToClusterInfoKeyMap.put("DATANODE", "slave_hosts"); componentToClusterInfoKeyMap.put("TASKTRACKER", "mapred_tt_hosts"); componentToClusterInfoKeyMap.put("HBASE_REGIONSERVER", "hbase_rs_hosts"); componentToClusterInfoKeyMap.put("KERBEROS_SERVER", "kdc_host"); - componentToClusterInfoKeyMap.put("KERBEROS_ADMIN_CLIENT", - "kerberos_adminclient_host"); + componentToClusterInfoKeyMap.put("KERBEROS_ADMIN_CLIENT", "kerberos_adminclient_host"); } public static String getActionId(long requestId, long stageId) { @@ -233,38 +229,36 @@ public class StageUtils { ServiceComponent serviceComponent = serviceComponentEntry.getValue(); String componentName = serviceComponent.getName(); - - for (final String hostName:serviceComponent.getServiceComponentHosts().keySet()) { - - if (componentToClusterInfoKeyMap.containsKey(componentName)) { - - String roleName = componentToClusterInfoKeyMap.get(componentName); - SortedSet<Integer> hostsForComponentsHost = hostRolesInfo.get(roleName); - - if (hostsForComponentsHost == null) { - hostsForComponentsHost = new TreeSet<Integer>(); - hostRolesInfo.put(roleName, hostsForComponentsHost); - } - - int hostIndex = hostsList.indexOf(hostName); - //Add index of host to current host role - hostsForComponentsHost.add(hostIndex); + + String roleName = componentToClusterInfoKeyMap.get(componentName); + if (null == roleName && !serviceComponent.isClientComponent()) + roleName = componentName.toLowerCase() + "_hosts"; + + if (null == roleName) + continue; + + for (String hostName : serviceComponent.getServiceComponentHosts().keySet()) { + + SortedSet<Integer> hostsForComponentsHost = hostRolesInfo.get(roleName); + + if (hostsForComponentsHost == null) { + hostsForComponentsHost = new TreeSet<Integer>(); + hostRolesInfo.put(roleName, hostsForComponentsHost); } + + int hostIndex = hostsList.indexOf(hostName); + //Add index of host to current host role + hostsForComponentsHost.add(hostIndex); } } } - for (String roleName : componentToClusterInfoKeyMap.values()) { - if (hostRolesInfo.containsKey(roleName)) { - - TreeSet<Integer> sortedSet = - new TreeSet<Integer>(hostRolesInfo.get(roleName)); - - Set<String> replacedRangesSet = replaceRanges(sortedSet); - - clusterHostInfo.put(roleName, replacedRangesSet); - - } + for (Entry<String, SortedSet<Integer>> entry : hostRolesInfo.entrySet()) { + TreeSet<Integer> sortedSet = new TreeSet<Integer>(entry.getValue()); + + Set<String> replacedRangesSet = replaceRanges(sortedSet); + + clusterHostInfo.put(entry.getKey(), replacedRangesSet); } clusterHostInfo.put(HOSTS_LIST, hostsSet); http://git-wip-us.apache.org/repos/asf/ambari/blob/0df2b181/ambari-server/src/test/java/org/apache/ambari/server/utils/TestStageUtils.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/utils/TestStageUtils.java b/ambari-server/src/test/java/org/apache/ambari/server/utils/TestStageUtils.java index 5c2d315..5452681 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/utils/TestStageUtils.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/utils/TestStageUtils.java @@ -210,6 +210,13 @@ public class TestStageUtils { mrTopology.put("TASKTRACKER", taskTrackerIndexes); addService(fsm.getCluster("c1"), hostList, mrTopology , "MAPREDUCE", injector); + + //Add NONAME service + Map<String, List<Integer>> nonameTopology = new HashMap<String, List<Integer>>(); + nonameTopology.put("NONAME_SERVER", Collections.singletonList(7)); + addService(fsm.getCluster("c1"), hostList, nonameTopology , "NONAME", injector); + + //Get cluster host info Map<String, Set<String>> info = StageUtils.getClusterHostInfo(fsm.getHostsForCluster("c1"), fsm.getCluster("c1"), new HostsMap(injector.getInstance(Configuration.class)), @@ -244,7 +251,6 @@ public class TestStageUtils { Set<String> actualPingPorts = info.get("all_ping_ports"); - if (pingPorts.contains(null)) assertEquals(new HashSet<Integer>(pingPorts).size(), actualPingPorts.size() + 1); else @@ -262,6 +268,9 @@ public class TestStageUtils { } assertEquals(pingPorts, reindexedPorts); + + // check for no-name in the list + assertTrue(info.containsKey("noname_server_hosts")); } http://git-wip-us.apache.org/repos/asf/ambari/blob/0df2b181/ambari-server/src/test/resources/stacks/HDP/1.3.1/services/NONAME/metainfo.xml ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/resources/stacks/HDP/1.3.1/services/NONAME/metainfo.xml b/ambari-server/src/test/resources/stacks/HDP/1.3.1/services/NONAME/metainfo.xml new file mode 100644 index 0000000..47e7291 --- /dev/null +++ b/ambari-server/src/test/resources/stacks/HDP/1.3.1/services/NONAME/metainfo.xml @@ -0,0 +1,30 @@ +<?xml version="1.0"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<metainfo> + <user>root</user> + <comment>No-name service</comment> + <version>1.0.0</version> + <components> + <component> + <name>NONAME_SERVER</name> + <category>MASTER</category> + </component> + </components> + + +</metainfo>
