Quellcode durchsuchen

AMBARI-2039. Service check should be scheduled on a client that is on a host in HEALTHY state. (smohanty)

git-svn-id: https://svn.apache.org/repos/asf/incubator/ambari/trunk@1476611 13f79535-47bb-0310-9956-ffa450edef68
Sumit Mohanty vor 12 Jahren
Ursprung
Commit
6fd6a93676

+ 3 - 0
CHANGES.txt

@@ -802,6 +802,9 @@ Trunk (unreleased changes):
 
  BUG FIXES
 
+ AMBARI-2039. Service check should be scheduled on a client that is on
+ a host in HEALTHY state - use correct state enum. (smohanty)
+
  AMBARI-2035. "Add local user" button is enabled but nothing happens upon
  clicking it under certain conditions. (yusaku)
 

+ 2 - 3
ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java

@@ -65,7 +65,7 @@ import org.apache.ambari.server.state.Config;
 import org.apache.ambari.server.state.ConfigFactory;
 import org.apache.ambari.server.state.DesiredConfig;
 import org.apache.ambari.server.state.Host;
-import org.apache.ambari.server.state.HostHealthStatus;
+import org.apache.ambari.server.state.HostState;
 import org.apache.ambari.server.state.OperatingSystemInfo;
 import org.apache.ambari.server.state.PropertyInfo;
 import org.apache.ambari.server.state.RepositoryInfo;
@@ -3952,8 +3952,7 @@ public class AmbariManagementControllerImpl implements
     for (String candidateHostName : hostList) {
       hostName = candidateHostName;
       Host candidateHost = clusters.getHost(hostName);
-      if (candidateHost.getHealthStatus().getHealthStatus()
-          == HostHealthStatus.HealthStatus.HEALTHY) {
+      if (candidateHost.getState() == HostState.HEALTHY) {
         break;
       }
     }

+ 7 - 9
ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java

@@ -60,7 +60,7 @@ import org.apache.ambari.server.state.Config;
 import org.apache.ambari.server.state.ConfigFactory;
 import org.apache.ambari.server.state.ConfigImpl;
 import org.apache.ambari.server.state.Host;
-import org.apache.ambari.server.state.HostHealthStatus;
+import org.apache.ambari.server.state.HostState;
 import org.apache.ambari.server.state.Service;
 import org.apache.ambari.server.state.ServiceComponent;
 import org.apache.ambari.server.state.ServiceComponentFactory;
@@ -4656,11 +4656,9 @@ public class AmbariManagementControllerTest {
         host3, null);
 
     // Install
-    HostHealthStatus healthy = new HostHealthStatus(HostHealthStatus.HealthStatus.HEALTHY, "");
-    HostHealthStatus unhealthy = new HostHealthStatus(HostHealthStatus.HealthStatus.UNHEALTHY, "");
     installService(clusterName, serviceName, false, false);
-    clusters.getHost("h3").setHealthStatus(unhealthy);
-    clusters.getHost("h2").setHealthStatus(healthy);
+    clusters.getHost("h3").setState(HostState.UNHEALTHY);
+    clusters.getHost("h2").setState(HostState.HEALTHY);
 
     // Start
     long requestId = startService(clusterName, serviceName, true, false);
@@ -4677,8 +4675,8 @@ public class AmbariManagementControllerTest {
 
     stopService(clusterName, serviceName, false, false);
 
-    clusters.getHost("h3").setHealthStatus(healthy);
-    clusters.getHost("h2").setHealthStatus(unhealthy);
+    clusters.getHost("h3").setState(HostState.HEALTHY);
+    clusters.getHost("h2").setState(HostState.HEARTBEAT_LOST);
 
     requestId = startService(clusterName, serviceName, true, false);
     commands = actionDB.getRequestTasks(requestId);
@@ -4710,8 +4708,8 @@ public class AmbariManagementControllerTest {
     Assert.assertEquals("Expect only one service check.", 1, commandCount);
 
     // When both are unhealthy then just pick one
-    clusters.getHost("h3").setHealthStatus(unhealthy);
-    clusters.getHost("h2").setHealthStatus(unhealthy);
+    clusters.getHost("h3").setState(HostState.WAITING_FOR_HOST_STATUS_UPDATES);
+    clusters.getHost("h2").setState(HostState.INIT);
     response = controller.createActions(actionRequests, requestProperties);
     commands = actionDB.getRequestTasks(response.getRequestId());
     commandCount = 0;