You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ds...@apache.org on 2017/07/19 15:38:14 UTC

ambari git commit: AMBARI-21521 Include/exclude files update is triggered when master is not started if cluster is deployed via BP (dsen)

Repository: ambari
Updated Branches:
  refs/heads/trunk 30cd71579 -> 0a42f5354


AMBARI-21521 Include/exclude files update is triggered when master is not started if cluster is deployed via BP (dsen)


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

Branch: refs/heads/trunk
Commit: 0a42f535447b8a09f57bac3fc354feebeb1750c8
Parents: 30cd715
Author: Dmytro Sen <ds...@apache.org>
Authored: Wed Jul 19 18:38:00 2017 +0300
Committer: Dmytro Sen <ds...@apache.org>
Committed: Wed Jul 19 18:38:00 2017 +0300

----------------------------------------------------------------------
 .../controller/AmbariManagementControllerImpl.java   | 15 +++++++++++++--
 .../AmbariManagementControllerImplTest.java          |  1 -
 2 files changed, 13 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/0a42f535/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 fac7b94..4229d34 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
@@ -3358,9 +3358,8 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
               }
             }
             try {
-              Service s = cluster.getService(serviceName);
               //Filter services whose masters are not started
-              if (s.getServiceComponent(masterComponentName).getDesiredState() == State.STARTED) {
+              if (isServiceComponentStartedOnAnyHost(cluster, serviceName, masterComponentName)) {
                 serviceMasterForDecommissionMap.put(serviceName, masterComponentName);
               } else {
                 LOG.info(String.format("Not adding %s service from include/exclude files refresh map because it's master is not started", serviceName));
@@ -3389,6 +3388,18 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
     }
   }
 
+  private boolean isServiceComponentStartedOnAnyHost(Cluster cluster, String serviceName, String masterComponentName) throws AmbariException {
+    Service service = cluster.getService(serviceName);
+    ServiceComponent serviceComponent = service.getServiceComponent(masterComponentName);
+    Map<String, ServiceComponentHost> schMap = serviceComponent.getServiceComponentHosts();
+    for (ServiceComponentHost sch : schMap.values()) {
+       if (sch.getState() == State.STARTED) {
+         return true;
+       }
+    }
+    return false;
+  }
+
   @Override
   public RequestStatusResponse createAndPersistStages(Cluster cluster, Map<String, String> requestProperties,
                                                       Map<String, String> requestParameters,

http://git-wip-us.apache.org/repos/asf/ambari/blob/0a42f535/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerImplTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerImplTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerImplTest.java
index 1f2c332..4024f05 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerImplTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerImplTest.java
@@ -2405,5 +2405,4 @@ public class AmbariManagementControllerImplTest {
     verify(injector, clusters, ambariMetaInfo, stackInfo, cluster, repoVersionDAO, repoVersion);
   }
 
-
 }