This is an automated email from the ASF dual-hosted git repository.

jgolieb pushed a commit to branch branch-feature-AMBARI-14714
in repository https://gitbox.apache.org/repos/asf/ambari.git


The following commit(s) were added to refs/heads/branch-feature-AMBARI-14714 by 
this push:
     new b8d4d0d  [AMBARI-24756] Fix Restart All services on host function 
(#2435)
b8d4d0d is described below

commit b8d4d0d0d69ee36bf25b9100aebf2fd85890d7a1
Author: Jason Golieb <j...@golieb.net>
AuthorDate: Wed Oct 10 13:19:39 2018 -0400

    [AMBARI-24756] Fix Restart All services on host function (#2435)
    
    * Fix Restart All services on host function
    
    * Fix indentation
---
 .../AmbariCustomCommandExecutionHelper.java        | 36 +++++++++++-----------
 .../AmbariCustomCommandExecutionHelperTest.java    |  1 +
 2 files changed, 19 insertions(+), 18 deletions(-)

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 7717939..066aaff 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
@@ -1453,35 +1453,35 @@ public class AmbariCustomCommandExecutionHelper {
       Cluster cluster = clusters.getCluster(clusterName);
       StackId stackId = null;
       String serviceType = null;
-//      TODO add service group null checks when the UI is updated
-//      if (serviceGroupName != null) {
-      if (serviceName != null) {
+
+      if (serviceGroupName != null && serviceName != null) {
         Service service = cluster.getService(serviceGroupName, serviceName);
         stackId = service.getStackId();
         serviceType = service.getServiceType();
-      }
 
-      if (stackId == null) {
-        throw new AmbariException("StackId should not be null. Service " + 
serviceName + " should have a desiredStackId");
-      }
+        if (stackId == null) {
+          throw new AmbariException("StackId should not be null. Service " + 
serviceName + " should have a desiredStackId");
+        }
 
-      AmbariMetaInfo ambariMetaInfo = managementController.getAmbariMetaInfo();
+        AmbariMetaInfo ambariMetaInfo = 
managementController.getAmbariMetaInfo();
 
-      StackInfo stack = ambariMetaInfo.getStack(stackId.getStackName(), 
stackId.getStackVersion());
-      if (stack != null) {
-        ServiceInfo serviceInfo = stack.getService(serviceType);
+        StackInfo stack = ambariMetaInfo.getStack(stackId.getStackName(), 
stackId.getStackVersion());
+        if (stack != null) {
+          ServiceInfo serviceInfo = stack.getService(serviceType);
 
-        if (serviceInfo != null) {
-          // if there is a chance that this action was triggered by a change 
in rack info then we want to
-          // force a topology refresh
-          // TODO : we may be able to be smarter about this and only refresh 
when the rack info has definitely changed
-          Boolean restartRequiredAfterRackChange = 
serviceInfo.isRestartRequiredAfterRackChange();
-          if (restartRequiredAfterRackChange != null && 
restartRequiredAfterRackChange) {
-            return true;
+          if (serviceInfo != null) {
+            // if there is a chance that this action was triggered by a change 
in rack info then we want to
+            // force a topology refresh
+            // TODO : we may be able to be smarter about this and only refresh 
when the rack info has definitely changed
+            Boolean restartRequiredAfterRackChange = 
serviceInfo.isRestartRequiredAfterRackChange();
+            if (restartRequiredAfterRackChange != null && 
restartRequiredAfterRackChange) {
+              return true;
+            }
           }
         }
       }
     }
+      
     return false;
   }
 
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 171c7ad..8bcf7b3 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
@@ -625,6 +625,7 @@ public class AmbariCustomCommandExecutionHelperTest {
     Assert.assertTrue(helper.isTopologyRefreshRequired("START", "c2", "CORE", 
"HDFS"));
     Assert.assertTrue(helper.isTopologyRefreshRequired("RESTART", "c2", 
"CORE", "HDFS"));
     Assert.assertFalse(helper.isTopologyRefreshRequired("STOP", "c2", "CORE", 
"HDFS"));
+    Assert.assertFalse(helper.isTopologyRefreshRequired("RESTART", "c2", null, 
null));
   }
 
   @Test

Reply via email to