You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ao...@apache.org on 2016/03/11 18:18:06 UTC
[2/2] ambari git commit: AMBARI-15372. Zookeeper service check fails
after removing a host (aonishuk)
AMBARI-15372. Zookeeper service check fails after removing a host (aonishuk)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/94f5bb7d
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/94f5bb7d
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/94f5bb7d
Branch: refs/heads/branch-2.2
Commit: 94f5bb7d52d887989792c67bf51b8c645436379e
Parents: 77dc81f
Author: Andrew Onishuk <ao...@hortonworks.com>
Authored: Fri Mar 11 19:18:02 2016 +0200
Committer: Andrew Onishuk <ao...@hortonworks.com>
Committed: Fri Mar 11 19:18:02 2016 +0200
----------------------------------------------------------------------
.../AmbariManagementControllerImpl.java | 25 ++++++++++----------
.../AmbariManagementControllerTest.java | 13 +++++++++-
2 files changed, 24 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/94f5bb7d/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
index 0461a0d..ac2fb22 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
@@ -516,7 +516,7 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
ServiceComponent sc = s.getServiceComponent(
request.getComponentName());
- setRestartRequiredServices(s, request.getHostname());
+ setRestartRequiredServices(s, request.getComponentName());
Host host;
try {
@@ -657,10 +657,12 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
}
private void setRestartRequiredServices(
- Service service, String hostName) throws AmbariException {
-
+ Service service, String componentName) throws AmbariException {
Cluster cluster = service.getCluster();
StackId stackId = cluster.getCurrentStackVersion();
+ if (service.getServiceComponent(componentName).isClientComponent()) {
+ return;
+ }
Set<String> needRestartServices = ambariMetaInfo.getRestartRequiredServicesNames(
stackId.getStackName(), stackId.getStackVersion());
@@ -668,16 +670,13 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
Map<String, ServiceComponent> m = service.getServiceComponents();
for (Entry<String, ServiceComponent> entry : m.entrySet()) {
ServiceComponent serviceComponent = entry.getValue();
- if (serviceComponent.isMasterComponent()) {
- Map<String, ServiceComponentHost> schMap = serviceComponent.getServiceComponentHosts();
- //schMap will only contain hostName when deleting a host; when adding a host the test skips the loop
- if(schMap.containsKey(hostName)) {
- for (Entry<String, ServiceComponentHost> sch : schMap.entrySet()) {
- ServiceComponentHost serviceComponentHost = sch.getValue();
- serviceComponentHost.setRestartRequired(true);
- }
+ Map<String, ServiceComponentHost> schMap = serviceComponent.getServiceComponentHosts();
+
+ for (Entry<String, ServiceComponentHost> sch : schMap.entrySet()) {
+ ServiceComponentHost serviceComponentHost = sch.getValue();
+ serviceComponentHost.setRestartRequired(true);
}
- }
+
}
}
}
@@ -2907,7 +2906,7 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
"DISABLED/INIT/INSTALLED/INSTALL_FAILED/UNKNOWN state. Current=" + componentHost.getState() + ".");
}
- setRestartRequiredServices(service, request.getHostname());
+ setRestartRequiredServices(service, request.getComponentName());
if (!safeToRemoveSCHs.containsKey(component)) {
safeToRemoveSCHs.put(component, new HashSet<ServiceComponentHost>());
http://git-wip-us.apache.org/repos/asf/ambari/blob/94f5bb7d/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
index 809ee88..3e43ef1 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
@@ -9797,12 +9797,16 @@ public class AmbariManagementControllerTest {
String datanode = "DATANODE";
String hdfsClient = "HDFS_CLIENT";
String zookeeperServer = "ZOOKEEPER_SERVER";
+ String zookeeperClient = "ZOOKEEPER_CLIENT";
+
createServiceComponent(clusterName, hdfsService, namenode,
State.INIT);
createServiceComponent(clusterName, hdfsService, datanode,
State.INIT);
createServiceComponent(clusterName, zookeeperService, zookeeperServer,
State.INIT);
+ createServiceComponent(clusterName, zookeeperService, zookeeperClient,
+ State.INIT);
String host1 = "h1";
String host2 = "h2";
@@ -9812,6 +9816,8 @@ public class AmbariManagementControllerTest {
createServiceComponentHost(clusterName, hdfsService, datanode, host1, null);
createServiceComponentHost(clusterName, zookeeperService, zookeeperServer, host1,
null);
+ createServiceComponentHost(clusterName, zookeeperService, zookeeperClient, host1,
+ null);
ServiceComponentHost zookeeperSch = null;
for (ServiceComponentHost sch : cluster.getServiceComponentHosts(host1)) {
@@ -9822,11 +9828,16 @@ public class AmbariManagementControllerTest {
assertFalse(zookeeperSch.isRestartRequired());
addHostToCluster(host2, clusterName);
- createServiceComponentHost(clusterName, zookeeperService, zookeeperServer, host2, null);
+ createServiceComponentHost(clusterName, zookeeperService, zookeeperClient, host2, null);
assertFalse(zookeeperSch.isRestartRequired()); //No restart required if adding host
+ createServiceComponentHost(clusterName, zookeeperService, zookeeperServer, host2, null);
+
+ assertTrue(zookeeperSch.isRestartRequired()); //Add zk server required restart
+
deleteServiceComponentHost(clusterName, zookeeperService, zookeeperServer, host2, null);
+ deleteServiceComponentHost(clusterName, zookeeperService, zookeeperClient, host2, null);
deleteHost(host2);
assertTrue(zookeeperSch.isRestartRequired()); //Restart if removing host!