Author: swagle
Date: Mon Apr 29 18:49:36 2013
New Revision: 1477266
URL: http://svn.apache.org/r1477266
Log:
AMBARI-2041. If a host that has a service client installed and the host is
down, service start will fail. (swagle)
Modified:
incubator/ambari/trunk/CHANGES.txt
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentHost.java
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImpl.java
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
Modified: incubator/ambari/trunk/CHANGES.txt
URL:
http://svn.apache.org/viewvc/incubator/ambari/trunk/CHANGES.txt?rev=1477266&r1=1477265&r2=1477266&view=diff
==============================================================================
--- incubator/ambari/trunk/CHANGES.txt (original)
+++ incubator/ambari/trunk/CHANGES.txt Mon Apr 29 18:49:36 2013
@@ -804,6 +804,9 @@ Trunk (unreleased changes):
BUG FIXES
+ AMBARI-2041. If a host that has a service client installed and the host is
down,
+ service start will fail. (swagle)
+
AMBARI-2039. Service check should be scheduled on a client that is on
a host in HEALTHY state - use correct state enum. (smohanty)
Modified:
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
URL:
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java?rev=1477266&r1=1477265&r2=1477266&view=diff
==============================================================================
---
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
(original)
+++
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
Mon Apr 29 18:49:36 2013
@@ -1882,13 +1882,16 @@ public class AmbariManagementControllerI
// Ignore the Sch if same service has changed on the same host
for (ServiceComponentHost existingSch : existingSchs) {
if (potentialSch.getHostName().equals(existingSch
- .getHostName()) && potentialSch.getServiceName().equals
- (existingSch.getServiceName())) {
+ .getHostName()) && potentialSch.getServiceName().equals
+ (existingSch.getServiceName())) {
addSch = false;
+ break;
}
}
- if (addSch)
+ if (addSch && !potentialSch.getHostState().equals(HostState
+ .HEARTBEAT_LOST)) {
potentialHosts.add(potentialSch);
+ }
}
}
}
Modified:
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentHost.java
URL:
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentHost.java?rev=1477266&r1=1477265&r2=1477266&view=diff
==============================================================================
---
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentHost.java
(original)
+++
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentHost.java
Mon Apr 29 18:49:36 2013
@@ -120,5 +120,6 @@ public interface ServiceComponentHost {
* @return the actual config map
*/
public Map<String, DesiredConfig> getActualConfigs();
-
+
+ public HostState getHostState();
}
Modified:
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImpl.java
URL:
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImpl.java?rev=1477266&r1=1477265&r2=1477266&view=diff
==============================================================================
---
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImpl.java
(original)
+++
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImpl.java
Mon Apr 29 18:49:36 2013
@@ -1348,4 +1348,8 @@ public class ServiceComponentHostImpl im
return actualConfigs;
}
+ @Override
+ public HostState getHostState() {
+ return host.getState();
+ }
}
Modified:
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
URL:
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java?rev=1477266&r1=1477265&r2=1477266&view=diff
==============================================================================
---
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
(original)
+++
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
Mon Apr 29 18:49:36 2013
@@ -4434,6 +4434,8 @@ public class AmbariManagementControllerT
host2, null);
createServiceComponentHost(clusterName, serviceName1, componentName3,
host3, null);
+ createServiceComponentHost(clusterName, serviceName2, componentName6,
+ host3, null);
// Create and attach config
Map<String, String> configs = new HashMap<String, String>();
@@ -4485,21 +4487,32 @@ public class AmbariManagementControllerT
stages = actionDB.getAllStages(requestId2);
stages.addAll(actionDB.getAllStages(requestId3));
- HostRoleCommand hdfsCmd = null;
- HostRoleCommand mapRedCmd = null;
+ HostRoleCommand hdfsCmdHost3 = null;
+ HostRoleCommand hdfsCmdHost2 = null;
+ HostRoleCommand mapRedCmdHost2 = null;
+ HostRoleCommand mapRedCmdHost3 = null;
for (Stage stage : stages) {
List<HostRoleCommand> hrcs = stage.getOrderedHostRoleCommands();
for (HostRoleCommand hrc : hrcs) {
LOG.debug("role: " + hrc.getRole());
- if (hrc.getRole().toString().equals("HDFS_CLIENT"))
- hdfsCmd = hrc;
- if (hrc.getRole().toString().equals("MAPREDUCE_CLIENT"))
- mapRedCmd = hrc;
+ if (hrc.getRole().toString().equals("HDFS_CLIENT")) {
+ if (hrc.getHostName().equals(host3))
+ hdfsCmdHost3 = hrc;
+ else if (hrc.getHostName().equals(host2))
+ hdfsCmdHost2 = hrc;
+ }
+ if (hrc.getRole().toString().equals("MAPREDUCE_CLIENT")) {
+ if (hrc.getHostName().equals(host2))
+ mapRedCmdHost2 = hrc;
+ else if (hrc.getHostName().equals(host3))
+ mapRedCmdHost3 = hrc;
+ }
}
}
- Assert.assertNotNull(hdfsCmd);
- ExecutionCommand execCmd = hdfsCmd.getExecutionCommandWrapper()
+ Assert.assertNotNull(hdfsCmdHost3);
+ Assert.assertNull(hdfsCmdHost2);
+ ExecutionCommand execCmd = hdfsCmdHost3.getExecutionCommandWrapper()
.getExecutionCommand();
Assert.assertEquals(2, execCmd.getConfigurationTags().size());
Assert.assertEquals("version122", execCmd.getConfigurationTags().get
@@ -4507,7 +4520,32 @@ public class AmbariManagementControllerT
Assert.assertEquals("d", execCmd.getConfigurations().get("core-site")
.get("c"));
// Check if MapReduce client is reinstalled
- Assert.assertNotNull(mapRedCmd);
+ Assert.assertNotNull(mapRedCmdHost2);
+ Assert.assertNotNull(mapRedCmdHost3);
+
+ /**
+ * Test for lost host
+ */
+ // Stop HDFS & MAPREDUCE
+ stopService(clusterName, serviceName1, false, false);
+ stopService(clusterName, serviceName2, false, false);
+
+ clusters.getHost(host2).setState(HostState.HEARTBEAT_LOST);
+
+ // Start
+ requestId2 = startService(clusterName, serviceName1, true, true);
+ requestId3 = startService(clusterName, serviceName2, true, true);
+ stages = actionDB.getAllStages(requestId2);
+ stages.addAll(actionDB.getAllStages(requestId3));
+ HostRoleCommand clientWithHostDown = null;
+ for (Stage stage : stages) {
+ for (HostRoleCommand hrc : stage.getOrderedHostRoleCommands()) {
+ if (hrc.getRole().toString().equals("MAPREDUCE_CLIENT") && hrc
+ .getHostName().equals(host2))
+ clientWithHostDown = hrc;
+ }
+ }
+ Assert.assertNull(clientWithHostDown);
}
@Test