AMBARI-7327. After NameNode HA is enabled UI doesn't load (aonishuk)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/ceee5bfe Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/ceee5bfe Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/ceee5bfe Branch: refs/heads/branch-alerts-dev Commit: ceee5bfedd4a861594f74002ba7228e60803c7a6 Parents: db62322 Author: Andrew Onishuk <aonis...@hortonworks.com> Authored: Tue Sep 16 22:10:40 2014 +0300 Committer: Andrew Onishuk <aonis...@hortonworks.com> Committed: Tue Sep 16 22:10:40 2014 +0300 ---------------------------------------------------------------------- .../server/api/util/StackExtensionHelper.java | 31 +- .../api/util/StackExtensionHelperTest.java | 20 + .../stacks/HDP/2.0.7/services/HDFS/metrics.json | 7840 ------------------ 3 files changed, 44 insertions(+), 7847 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/ceee5bfe/ambari-server/src/main/java/org/apache/ambari/server/api/util/StackExtensionHelper.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/util/StackExtensionHelper.java b/ambari-server/src/main/java/org/apache/ambari/server/api/util/StackExtensionHelper.java index d5d816e..a63be38 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/api/util/StackExtensionHelper.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/api/util/StackExtensionHelper.java @@ -220,12 +220,16 @@ public class StackExtensionHelper { mergedServiceInfo.setCustomCommands(mergedCustomCommands); // metrics - if (null == childService.getMetricsFile() && null != parentService.getMetricsFile()) + if (null != childService.getMetricsFile()) + mergedServiceInfo.setMetricsFile(childService.getMetricsFile()); + else if (null != parentService.getMetricsFile()) mergedServiceInfo.setMetricsFile(parentService.getMetricsFile()); // alerts - if (null == childService.getAlertsFile() && null != parentService.getAlertsFile()) - mergedServiceInfo.setAlertsFile(parentService.getAlertsFile()); + if (null != childService.getAlertsFile()) + mergedServiceInfo.setAlertsFile(childService.getAlertsFile()); + else if (null != parentService.getAlertsFile()) + mergedServiceInfo.setAlertsFile(parentService.getAlertsFile()); populateComponents(mergedServiceInfo, parentService, childService); @@ -425,12 +429,24 @@ public class StackExtensionHelper { // Map services with unique names Map<String, ServiceInfo> serviceInfoMap = new HashMap<String, ServiceInfo>(); + List<ServiceInfo> serviceInfoList = null; // Iterate with oldest parent first - all stacks are populated + StackInfo parentStack = null; while(lt.hasPrevious()) { - StackInfo parentStack = lt.previous(); - List<ServiceInfo> serviceInfoList = parentStack.getServices(); + if (parentStack == null) { + parentStack = lt.previous(); + serviceInfoList = parentStack.getServices(); + for (ServiceInfo service : serviceInfoList){ + if (!service.isDeleted()) { + serviceInfoMap.put(service.getName(), service); + } + } + continue; + } + StackInfo currentStackInfo = lt.previous(); + serviceInfoList = currentStackInfo.getServices(); - mergeStacks(parentStack, stackInfo); + mergeStacks(parentStack, currentStackInfo); for (ServiceInfo service : serviceInfoList) { ServiceInfo existingService = serviceInfoMap.get(service.getName()); @@ -439,7 +455,7 @@ public class StackExtensionHelper { continue; } - if (existingService == null) { + if (existingService == null && !service.isDeleted()) { serviceInfoMap.put(service.getName(), service); } else { // Redefined service - merge with parent @@ -467,6 +483,7 @@ public class StackExtensionHelper { } } + parentStack = currentStackInfo; } return new ArrayList<ServiceInfo>(serviceInfoMap.values()); } http://git-wip-us.apache.org/repos/asf/ambari/blob/ceee5bfe/ambari-server/src/test/java/org/apache/ambari/server/api/util/StackExtensionHelperTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/api/util/StackExtensionHelperTest.java b/ambari-server/src/test/java/org/apache/ambari/server/api/util/StackExtensionHelperTest.java index 346202e..2219b6f 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/api/util/StackExtensionHelperTest.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/api/util/StackExtensionHelperTest.java @@ -649,6 +649,26 @@ public class StackExtensionHelperTest { } @Test + public void testServiceInheritance() throws Exception { + File stackRoot = new File(stackRootStr); + StackInfo stackInfo = new StackInfo(); + stackInfo.setName("HDP"); + stackInfo.setVersion("2.0.6"); + StackExtensionHelper helper = new StackExtensionHelper(injector, stackRoot); + helper.populateServicesForStack(stackInfo); + helper.fillInfo(); + List<ServiceInfo> allServices = helper.getAllApplicableServices(stackInfo); + for (ServiceInfo serviceInfo : allServices) { + if (serviceInfo.getName().equals("HDFS")){ + assertEquals("HDFS", serviceInfo.getName()); + assertNotNull(serviceInfo.getMetricsFile()); + } + } + + } + + + @Test public void testMergeComponentInfo() throws Exception { File stackRoot = new File(stackRootStr); StackExtensionHelper helper = new StackExtensionHelper(injector, stackRoot);