You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by dm...@apache.org on 2014/09/22 19:04:46 UTC
git commit: AMBARI-7434. Unable to download client configs
(dlysnichenko)
Repository: ambari
Updated Branches:
refs/heads/trunk fc89a92df -> 57030a4d1
AMBARI-7434. Unable to download client configs (dlysnichenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/57030a4d
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/57030a4d
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/57030a4d
Branch: refs/heads/trunk
Commit: 57030a4d1915ea3d219c66ca2a65840b3e078481
Parents: fc89a92
Author: Lisnichenko Dmitro <dl...@hortonworks.com>
Authored: Mon Sep 22 20:03:04 2014 +0300
Committer: Lisnichenko Dmitro <dl...@hortonworks.com>
Committed: Mon Sep 22 20:04:35 2014 +0300
----------------------------------------------------------------------
.../internal/ClientConfigResourceProvider.java | 33 +++++++++++++++++---
.../ClientConfigResourceProviderTest.java | 9 ++++--
2 files changed, 35 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/57030a4d/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClientConfigResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClientConfigResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClientConfigResourceProvider.java
index 34f4d6f..1caae37e 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClientConfigResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClientConfigResourceProvider.java
@@ -341,11 +341,13 @@ public class ClientConfigResourceProvider extends AbstractControllerResourceProv
if (currentHostsIndexes == null) {
continue;
}
- for (String hostIndex : currentHostsIndexes) {
- try {
- hosts.add(allHosts[Integer.parseInt(hostIndex)]);
- } catch (ArrayIndexOutOfBoundsException ex) {
- throw new SystemException("Failed to fill cluster host info ", ex);
+ for (String hostIndexRange : currentHostsIndexes) {
+ for (Integer hostIndex : rangeToSet(hostIndexRange)) {
+ try {
+ hosts.add(allHosts[hostIndex]);
+ } catch (ArrayIndexOutOfBoundsException ex) {
+ throw new SystemException("Failed to fill cluster host info ", ex);
+ }
}
}
clusterHostInfo.put(key, hosts);
@@ -353,6 +355,27 @@ public class ClientConfigResourceProvider extends AbstractControllerResourceProv
return clusterHostInfo;
}
+ private static Set<Integer> rangeToSet(String range) {
+ Set<Integer> indexSet = new HashSet<Integer>();
+ int startIndex;
+ int endIndex;
+ if (range.contains("-")) {
+ startIndex = Integer.parseInt(range.split("-")[0]);
+ endIndex = Integer.parseInt(range.split("-")[1]);
+ }
+ else if (range.contains(",")) {
+ startIndex = Integer.parseInt(range.split(",")[0]);
+ endIndex = Integer.parseInt(range.split(",")[1]);
+ }
+ else {
+ startIndex = endIndex = Integer.parseInt(range);
+ }
+ for (int i=startIndex; i<=endIndex; i++) {
+ indexSet.add(i);
+ }
+ return indexSet;
+ }
+
@Override
public RequestStatus updateResources(final Request request, Predicate predicate)
throws SystemException, UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException {
http://git-wip-us.apache.org/repos/asf/ambari/blob/57030a4d/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClientConfigResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClientConfigResourceProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClientConfigResourceProviderTest.java
index 916e0de..ef094b5 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClientConfigResourceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClientConfigResourceProviderTest.java
@@ -232,11 +232,16 @@ public class ClientConfigResourceProviderTest {
PowerMock.mockStaticPartial(StageUtils.class, "getClusterHostInfo");
Map<String, Set<String>> clusterHostInfo = new HashMap<String, Set<String>>();
Set<String> all_hosts = new HashSet<String>(Arrays.asList("Host100","Host101","Host102"));
- Set<String> some_hosts = new HashSet<String>(Arrays.asList("0","2"));
+ Set<String> some_hosts = new HashSet<String>(Arrays.asList("0-1","2"));
+ Set<String> ohter_hosts = new HashSet<String>(Arrays.asList("0,1"));
Set<String> clusterHostTypes = new HashSet<String>(Arrays.asList("nm_hosts", "hs_host",
"namenode_host", "rm_host", "snamenode_host", "slave_hosts", "zookeeper_hosts"));
for (String hostTypes: clusterHostTypes) {
- clusterHostInfo.put(hostTypes,some_hosts);
+ if (hostTypes.equals("slave_hosts")) {
+ clusterHostInfo.put(hostTypes, ohter_hosts);
+ } else {
+ clusterHostInfo.put(hostTypes, some_hosts);
+ }
}
Map<String, Host> stringHostMap = new HashMap<String, Host>();
stringHostMap.put(hostName, host);