You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by rn...@apache.org on 2015/12/01 23:35:49 UTC

ambari git commit: AMBARI-12688. HDFS check fails after move NameNode on NN HA cluster. (Oliver Szabo via rnettleton)

Repository: ambari
Updated Branches:
  refs/heads/trunk a74bc730f -> 4fb40440b


AMBARI-12688. HDFS check fails after move NameNode on NN HA cluster. (Oliver Szabo via rnettleton)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/4fb40440
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/4fb40440
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/4fb40440

Branch: refs/heads/trunk
Commit: 4fb40440b77e2c5302d386fff2092a6d1fa6ff3b
Parents: a74bc73
Author: Bob Nettleton <rn...@hortonworks.com>
Authored: Tue Dec 1 17:35:42 2015 -0500
Committer: Bob Nettleton <rn...@hortonworks.com>
Committed: Tue Dec 1 17:35:58 2015 -0500

----------------------------------------------------------------------
 .../apache/ambari/server/utils/StageUtils.java  | 30 +++++++++++++++++---
 .../ambari/server/utils/StageUtilsTest.java     | 11 +++++++
 2 files changed, 37 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/4fb40440/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 e51cfb2..30843a4 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
@@ -351,6 +351,8 @@ public class StageUtils {
     }
 
     // add components from topology manager
+
+    Map<String, SortedSet<Integer>> hostRolesInfoFromTopology = new HashMap<String, SortedSet<Integer>>();
     for (Map.Entry<String, Collection<String>> entry : pendingHostComponents.entrySet()) {
       String hostname = entry.getKey();
       Collection<String> hostComponents = entry.getValue();
@@ -374,11 +376,11 @@ public class StageUtils {
         }
 
         if (roleName != null) {
-          SortedSet<Integer> hostsForComponentsHost = hostRolesInfo.get(roleName);
+          SortedSet<Integer> hostsForComponentsHost = hostRolesInfoFromTopology.get(roleName);
 
           if (hostsForComponentsHost == null) {
             hostsForComponentsHost = new TreeSet<Integer>();
-            hostRolesInfo.put(roleName, hostsForComponentsHost);
+            hostRolesInfoFromTopology.put(roleName, hostsForComponentsHost);
           }
 
           int hostIndex = hostsList.indexOf(hostname);
@@ -396,6 +398,13 @@ public class StageUtils {
       }
     }
 
+    // merge host roles
+    for (Map.Entry<String, SortedSet<Integer>> entry : hostRolesInfoFromTopology.entrySet()) {
+      if (isOverrideHostRoleNeeded(entry, hostRolesInfo, allHosts, pendingHostComponents)) {
+        hostRolesInfo.put(entry.getKey(), entry.getValue());
+      }
+    }
+
     Map<String, Set<String>> clusterHostInfo = new HashMap<String, Set<String>>();
 
     for (Map.Entry<String, SortedSet<Integer>> entry : hostRolesInfo.entrySet()) {
@@ -541,6 +550,10 @@ public class StageUtils {
     return result;
   }
 
+  public static String getHostName() {
+    return server_hostname;
+  }
+
   /**
    * Splits a range to its explicit set of values.
    * <p/>
@@ -578,7 +591,16 @@ public class StageUtils {
     return rangeItem;
   }
 
-  public static String getHostName() {
-    return server_hostname;
+  /**
+   * It determines to replace host roles if the number of components lower in the cluster than in the blueprint
+   * or when all of the hosts are not available from {@link Cluster} object.
+   */
+  private static boolean isOverrideHostRoleNeeded(Entry<String, SortedSet<Integer>> hostRoleEntry,
+                                                  Map<String, SortedSet<Integer>> hostRolesInfo,
+                                                  Collection<Host> allHosts,
+                                                  Map<String, Collection<String>> pendingHostComponents) {
+    Set<Integer> hostRole = hostRolesInfo.get(hostRoleEntry.getKey());
+    return (allHosts.size() != pendingHostComponents.size() || (hostRole == null ||
+      (!hostRole.isEmpty() && hostRole.size() < hostRoleEntry.getValue().size())));
   }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/4fb40440/ambari-server/src/test/java/org/apache/ambari/server/utils/StageUtilsTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/utils/StageUtilsTest.java b/ambari-server/src/test/java/org/apache/ambari/server/utils/StageUtilsTest.java
index c78648d..e1c47b9 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/utils/StageUtilsTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/utils/StageUtilsTest.java
@@ -17,8 +17,10 @@
  */
 package org.apache.ambari.server.utils;
 
+import com.google.common.base.Predicate;
 import com.google.common.collect.ContiguousSet;
 import com.google.common.collect.DiscreteDomain;
+import com.google.common.collect.Maps;
 import com.google.common.collect.Range;
 import com.google.gson.Gson;
 import com.google.inject.AbstractModule;
@@ -446,6 +448,12 @@ public class StageUtilsTest extends EasyMockSupport {
             return hbrsServiceComponentHosts.get((String) args[0]);
           }
         }).anyTimes();
+    Map<String, ServiceComponentHost> hbrsHosts = Maps.filterKeys(hbrsServiceComponentHosts, new Predicate<String>() {
+      @Override
+      public boolean apply(String s) {
+        return s.equals("h1");
+      }
+    });
     expect(hbrsComponent.getServiceComponentHosts()).andReturn(hbrsServiceComponentHosts).anyTimes();
     expect(hbrsComponent.isClientComponent()).andReturn(false).anyTimes();
 
@@ -586,6 +594,9 @@ public class StageUtilsTest extends EasyMockSupport {
     assertEquals(1, serverHost.size());
     assertEquals(StageUtils.getHostName(), serverHost.iterator().next());
 
+    // check host role replacing by the projected topology
+    assertTrue(getDecompressedSet(info.get("hbase_rs_hosts")).contains(9));
+
     // Validate substitutions...
     info = StageUtils.substituteHostIndexes(info);