Repository: ambari Updated Branches: refs/heads/branch-feature-AMBARI-21450 abd645907 -> 00712125d
AMBARI-21611 Failed to install packages before EU on powerpc (dili) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/85ba03b9 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/85ba03b9 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/85ba03b9 Branch: refs/heads/branch-feature-AMBARI-21450 Commit: 85ba03b9152b51e85d8afc990638db7b1e1dabfc Parents: 9e0a7fb Author: Di Li <[email protected]> Authored: Mon Jul 31 17:09:24 2017 -0400 Committer: Di Li <[email protected]> Committed: Mon Jul 31 17:09:24 2017 -0400 ---------------------------------------------------------------------- .../ClusterStackVersionResourceProvider.java | 50 ++++++++++++++++++-- ...ClusterStackVersionResourceProviderTest.java | 11 +++-- 2 files changed, 53 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/85ba03b9/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterStackVersionResourceProvider.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterStackVersionResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterStackVersionResourceProvider.java index 633fe8c..b489d7f 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterStackVersionResourceProvider.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterStackVersionResourceProvider.java @@ -506,15 +506,16 @@ public class ClusterStackVersionResourceProvider extends AbstractControllerResou final AmbariManagementController managementController = getManagementController(); final AmbariMetaInfo ami = managementController.getAmbariMetaInfo(); + String osFamily = getPowerPCOsFamily(hosts); // build the list of OS repos List<OperatingSystemEntity> operatingSystems = repoVersionEnt.getOperatingSystems(); Map<String, List<RepositoryEntity>> perOsRepos = new HashMap<>(); for (OperatingSystemEntity operatingSystem : operatingSystems) { - + String osType = getOsTypeForRepo(operatingSystem, osFamily); if (operatingSystem.isAmbariManagedRepos()) { - perOsRepos.put(operatingSystem.getOsType(), operatingSystem.getRepositories()); + perOsRepos.put(osType, operatingSystem.getRepositories()); } else { - perOsRepos.put(operatingSystem.getOsType(), Collections.<RepositoryEntity> emptyList()); + perOsRepos.put(osType, Collections.<RepositoryEntity> emptyList()); } } @@ -1088,4 +1089,47 @@ public class ClusterStackVersionResourceProvider extends AbstractControllerResou amc.getAuthName(), serviceNote); } } + + /** + * Check one host is enough to tell the arch + * because all hosts should have the same arch. + * @param hosts List<Host> + * @return osFamily, null if hosts is empty or is X86_64 + + */ + private String getPowerPCOsFamily(List<Host> hosts) { + if (hosts.isEmpty()){ + return null; + } else { + Host host = hosts.get(0); + String osFamily = host.getHostAttributes().get("os_family"); + if (null != osFamily && osFamily.endsWith("-ppc")){ + return osFamily; + } else { + return null; + } + } + } + + /** + * Use os type with -ppc post fix for powerpc + * in order to have it consistent with the os information + * stored in the Hosts table + * No need to apply the change if os is x86_64 + * */ + private String getOsTypeForRepo(OperatingSystemEntity operatingSystem, String osFamily) { + if (null != osFamily){ + String osType = operatingSystem.getOsType(); + int pos = osFamily.indexOf("-ppc"); + if (pos > 0){ + String os = osType.substring(0, pos); + String majorVersion = osType.substring(os.length()); + return String.format("%s-ppc%s", os, majorVersion); + } else { + return operatingSystem.getOsType(); + } + } else { + return operatingSystem.getOsType(); + } + } } http://git-wip-us.apache.org/repos/asf/ambari/blob/85ba03b9/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterStackVersionResourceProviderTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterStackVersionResourceProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterStackVersionResourceProviderTest.java index 7018245..68596e0 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterStackVersionResourceProviderTest.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterStackVersionResourceProviderTest.java @@ -233,7 +233,7 @@ public class ClusterStackVersionResourceProviderTest { MaintenanceState.OFF).anyTimes(); expect(host.getAllHostVersions()).andReturn( Collections.<HostVersionEntity>emptyList()).anyTimes(); - + expect(host.getHostAttributes()).andReturn(new HashMap<String, String>()).anyTimes(); replay(host); hostsForCluster.put(hostname, host); } @@ -424,7 +424,7 @@ public class ClusterStackVersionResourceProviderTest { MaintenanceState.OFF).anyTimes(); expect(host.getAllHostVersions()).andReturn( Collections.<HostVersionEntity>emptyList()).anyTimes(); - + expect(host.getHostAttributes()).andReturn(new HashMap<String, String>()).anyTimes(); replay(host); hostsForCluster.put(hostname, host); } @@ -657,7 +657,7 @@ public class ClusterStackVersionResourceProviderTest { MaintenanceState.OFF).anyTimes(); expect(host.getAllHostVersions()).andReturn( Collections.<HostVersionEntity>emptyList()).anyTimes(); - + expect(host.getHostAttributes()).andReturn(new HashMap<String, String>()).anyTimes(); replay(host); hostsForCluster.put(hostname, host); } @@ -888,7 +888,7 @@ public class ClusterStackVersionResourceProviderTest { MaintenanceState.OFF).anyTimes(); expect(host.getAllHostVersions()).andReturn( Collections.<HostVersionEntity>emptyList()).anyTimes(); - + expect(host.getHostAttributes()).andReturn(new HashMap<String, String>()).anyTimes(); replay(host); hostsForCluster.put(hostname, host); } @@ -1435,7 +1435,7 @@ public class ClusterStackVersionResourceProviderTest { MaintenanceState.OFF).anyTimes(); expect(host.getAllHostVersions()).andReturn( Collections.<HostVersionEntity>emptyList()).anyTimes(); - + expect(host.getHostAttributes()).andReturn(new HashMap<String, String>()).anyTimes(); replay(host); hostsForCluster.put(hostname, host); } @@ -1662,6 +1662,7 @@ public class ClusterStackVersionResourceProviderTest { hostVersionEntitiesMergedWithNotRequired.add(hostVersionEntity); expect(host.getAllHostVersions()).andReturn(hostVersionEntitiesMergedWithNotRequired).anyTimes(); + expect(host.getHostAttributes()).andReturn(new HashMap<String, String>()).anyTimes(); } replay(host);
