ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject ambari git commit: AMBARI-17760 Ambari should perform service check only healthy hosts (dsen)
Date Mon, 18 Jul 2016 12:25:50 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 83cb06a76 -> 1b7cc137d


AMBARI-17760 Ambari should perform service check only healthy hosts (dsen)


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

Branch: refs/heads/trunk
Commit: 1b7cc137dc70f264be8dfe535014443ad2c56205
Parents: 83cb06a
Author: Dmytro Sen <dsen@apache.org>
Authored: Mon Jul 18 15:25:36 2016 +0300
Committer: Dmytro Sen <dsen@apache.org>
Committed: Mon Jul 18 15:25:36 2016 +0300

----------------------------------------------------------------------
 .../AmbariCustomCommandExecutionHelper.java     | 14 ++++---
 .../AmbariCustomCommandExecutionHelperTest.java | 39 +++++++++++++++++---
 2 files changed, 42 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/1b7cc137/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelper.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelper.java
index e09630d..2174a64 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelper.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelper.java
@@ -520,17 +520,21 @@ public class AmbariCustomCommandExecutionHelper {
       Map<String, ServiceComponent> serviceComponents =
               cluster.getService(serviceName).getServiceComponents();
 
+      // Filter components without any HOST
+      Iterator<String> serviceComponentNameIterator = serviceComponents.keySet().iterator();
+      while (serviceComponentNameIterator.hasNext()){
+        String componentToCheck = serviceComponentNameIterator.next();
+         if (serviceComponents.get(componentToCheck).getServiceComponentHosts().isEmpty()){
+           serviceComponentNameIterator.remove();
+         }
+      }
+
       if (serviceComponents.isEmpty()) {
         throw new AmbariException("Components not found, service = "
             + serviceName + ", cluster = " + clusterName);
       }
 
       ServiceComponent serviceComponent = serviceComponents.values().iterator().next();
-      if (serviceComponent.getServiceComponentHosts().isEmpty()) {
-        throw new AmbariException("Hosts not found, component="
-            + serviceComponent.getName() + ", service = "
-            + serviceName + ", cluster = " + clusterName);
-      }
 
       serviceHostComponents = serviceComponent.getServiceComponentHosts();
       candidateHosts = serviceHostComponents.keySet();

http://git-wip-us.apache.org/repos/asf/ambari/blob/1b7cc137/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelperTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelperTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelperTest.java
index a43667e..7a5f377 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelperTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelperTest.java
@@ -17,6 +17,7 @@
  */
 package org.apache.ambari.server.controller;
 
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashMap;
@@ -376,6 +377,23 @@ public class AmbariCustomCommandExecutionHelperTest {
     Assert.fail("Expected an exception since there are no hosts which can run the ZK service
check");
   }
 
+  @Test(expected = AmbariException.class)
+  public void testServiceCheckComponentWithEmptyHosts() throws Exception {
+
+    AmbariCustomCommandExecutionHelper ambariCustomCommandExecutionHelper = injector.getInstance(AmbariCustomCommandExecutionHelper.class);
+
+    List<RequestResourceFilter> requestResourceFilter = new ArrayList<RequestResourceFilter>()
{{
+      add(new RequestResourceFilter("FLUME", null, null));
+    }};
+    ActionExecutionContext actionExecutionContext = new ActionExecutionContext("c1", "SERVICE_CHECK",
requestResourceFilter);
+    Stage stage = EasyMock.niceMock(Stage.class);
+
+    ambariCustomCommandExecutionHelper.addExecutionCommandsToStage(actionExecutionContext,
stage, new HashMap<String, String>());
+
+    Assert.fail("Expected an exception since there are no hosts which can run the Flume service
check");
+  }
+
+
   @Test
   public void testIsTopologyRefreshRequired() throws Exception {
     AmbariCustomCommandExecutionHelper helper = injector.getInstance(AmbariCustomCommandExecutionHelper.class);
@@ -418,14 +436,19 @@ public class AmbariCustomCommandExecutionHelperTest {
   }
 
   private void createClusterFixture(String clusterName, String stackVersion, String hostPrefix)
throws AmbariException, AuthorizationException {
+    String hostC6401 = hostPrefix + "-c6401";
+    String hostC6402 = hostPrefix + "-c6402";
+
     createCluster(clusterName, stackVersion);
-    addHost(hostPrefix + "-c6401", clusterName);
-    addHost(hostPrefix + "-c6402", clusterName);
+
+    addHost(hostC6401, clusterName);
+    addHost(hostC6402, clusterName);
 
     clusters.getCluster(clusterName);
     createService(clusterName, "YARN", null);
     createService(clusterName, "GANGLIA", null);
     createService(clusterName, "ZOOKEEPER", null);
+    createService(clusterName, "FLUME", null);
 
     createServiceComponent(clusterName, "YARN", "RESOURCEMANAGER", State.INIT);
     createServiceComponent(clusterName, "YARN", "NODEMANAGER", State.INIT);
@@ -433,10 +456,14 @@ public class AmbariCustomCommandExecutionHelperTest {
     createServiceComponent(clusterName, "GANGLIA", "GANGLIA_MONITOR", State.INIT);
     createServiceComponent(clusterName, "ZOOKEEPER", "ZOOKEEPER_CLIENT", State.INIT);
 
-    createServiceComponentHost(clusterName, "YARN", "RESOURCEMANAGER", hostPrefix + "-c6401",
null);
-    createServiceComponentHost(clusterName, "YARN", "NODEMANAGER", hostPrefix + "-c6401",
null);
-    createServiceComponentHost(clusterName, "GANGLIA", "GANGLIA_SERVER", hostPrefix + "-c6401",
State.INIT);
-    createServiceComponentHost(clusterName, "GANGLIA", "GANGLIA_MONITOR", hostPrefix + "-c6401",
State.INIT);
+    // this component should be not installed on any host
+    createServiceComponent(clusterName, "FLUME", "FLUME_HANDLER", State.INIT);
+
+
+    createServiceComponentHost(clusterName, "YARN", "RESOURCEMANAGER", hostC6401, null);
+    createServiceComponentHost(clusterName, "YARN", "NODEMANAGER", hostC6401, null);
+    createServiceComponentHost(clusterName, "GANGLIA", "GANGLIA_SERVER", hostC6401, State.INIT);
+    createServiceComponentHost(clusterName, "GANGLIA", "GANGLIA_MONITOR", hostC6401, State.INIT);
 
     createServiceComponentHost(clusterName, "YARN", "NODEMANAGER", hostPrefix + "-c6402",
null);
     createServiceComponentHost(clusterName, "GANGLIA", "GANGLIA_MONITOR", hostPrefix + "-c6402",
State.INIT);


Mime
View raw message