You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by nc...@apache.org on 2014/07/31 23:04:59 UTC

git commit: AMBARI-6698. Expose Stack Service Information For Commands (Jonathan Hurley via ncole)

Repository: ambari
Updated Branches:
  refs/heads/trunk 3667b2b1b -> 6705a0f61


AMBARI-6698. Expose Stack Service Information For Commands (Jonathan Hurley via ncole)


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

Branch: refs/heads/trunk
Commit: 6705a0f6157e8b2aef821cd599d4f59ed0ded901
Parents: 3667b2b
Author: Nate Cole <nc...@hortonworks.com>
Authored: Thu Jul 31 17:04:24 2014 -0400
Committer: Nate Cole <nc...@hortonworks.com>
Committed: Thu Jul 31 17:04:32 2014 -0400

----------------------------------------------------------------------
 .../AmbariManagementControllerImpl.java         | 146 ++++----
 .../StackServiceComponentResponse.java          |  51 ++-
 .../server/controller/StackServiceResponse.java |  68 +++-
 .../StackServiceComponentResourceProvider.java  |  66 ++--
 .../internal/StackServiceResourceProvider.java  |  46 ++-
 .../ambari/server/state/ComponentInfo.java      |  20 +-
 .../apache/ambari/server/state/ServiceInfo.java |   8 +-
 .../src/main/resources/properties.json          |   3 +
 .../AmbariManagementControllerTest.java         | 359 +++++++++++--------
 9 files changed, 461 insertions(+), 306 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/6705a0f6/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 ef031e6..8a8b792 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
@@ -20,11 +20,6 @@ package org.apache.ambari.server.controller;
 
 import com.google.common.cache.Cache;
 import com.google.common.cache.CacheBuilder;
-import com.google.gson.Gson;
-import com.google.inject.Inject;
-import com.google.inject.Injector;
-import com.google.inject.Singleton;
-import com.google.inject.persist.Transactional;
 
 import java.io.File;
 import java.io.IOException;
@@ -136,6 +131,12 @@ import org.apache.http.client.utils.URIBuilder;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.google.gson.Gson;
+import com.google.inject.Inject;
+import com.google.inject.Injector;
+import com.google.inject.Singleton;
+import com.google.inject.persist.Transactional;
+
 @Singleton
 public class AmbariManagementControllerImpl implements AmbariManagementController {
 
@@ -225,45 +226,46 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
     this.actionManager = actionManager;
     this.injector = injector;
     injector.injectMembers(this);
-    this.gson = injector.getInstance(Gson.class);
+    gson = injector.getInstance(Gson.class);
     LOG.info("Initializing the AmbariManagementControllerImpl");
-    this.masterHostname =  InetAddress.getLocalHost().getCanonicalHostName();
-    this.maintenanceStateHelper = injector.getInstance(MaintenanceStateHelper.class);
+    masterHostname =  InetAddress.getLocalHost().getCanonicalHostName();
+    maintenanceStateHelper = injector.getInstance(MaintenanceStateHelper.class);
 
     if(configs != null)
     {
       if (configs.getApiSSLAuthentication()) {
-        this.masterProtocol = "https";
-        this.masterPort = configs.getClientSSLApiPort();
+        masterProtocol = "https";
+        masterPort = configs.getClientSSLApiPort();
       } else {
-        this.masterProtocol = "http";
-        this.masterPort = configs.getClientApiPort();
+        masterProtocol = "http";
+        masterPort = configs.getClientApiPort();
       }
-      this.jdkResourceUrl = getAmbariServerURI(JDK_RESOURCE_LOCATION);
-      this.javaHome = configs.getJavaHome();
-      this.jdkName = configs.getJDKName();
-      this.jceName = configs.getJCEName();
-      this.ojdbcUrl = getAmbariServerURI(JDK_RESOURCE_LOCATION + "/" + configs.getOjdbcJarName());
-      this.mysqljdbcUrl = getAmbariServerURI(JDK_RESOURCE_LOCATION + "/" + configs.getMySQLJarName());
+      jdkResourceUrl = getAmbariServerURI(JDK_RESOURCE_LOCATION);
+      javaHome = configs.getJavaHome();
+      jdkName = configs.getJDKName();
+      jceName = configs.getJCEName();
+      ojdbcUrl = getAmbariServerURI(JDK_RESOURCE_LOCATION + "/" + configs.getOjdbcJarName());
+      mysqljdbcUrl = getAmbariServerURI(JDK_RESOURCE_LOCATION + "/" + configs.getMySQLJarName());
 
-      this.serverDB = configs.getServerDBName();
+      serverDB = configs.getServerDBName();
     } else {
-      this.masterProtocol = null;
-      this.masterPort = null;
+      masterProtocol = null;
+      masterPort = null;
 
-      this.jdkResourceUrl = null;
-      this.javaHome = null;
-      this.jdkName = null;
-      this.jceName = null;
-      this.ojdbcUrl = null;
-      this.mysqljdbcUrl = null;
-      this.serverDB = null;
+      jdkResourceUrl = null;
+      javaHome = null;
+      jdkName = null;
+      jceName = null;
+      ojdbcUrl = null;
+      mysqljdbcUrl = null;
+      serverDB = null;
     }
   }
 
   public String getAmbariServerURI(String path) {
-    if(masterProtocol==null || masterHostname==null || masterPort==null)
+    if(masterProtocol==null || masterHostname==null || masterPort==null) {
       return null;
+    }
 
     URIBuilder uriBuilder = new URIBuilder();
     uriBuilder.setScheme(masterProtocol);
@@ -654,8 +656,9 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
       }
 
       User user = users.getAnyUser(request.getUsername());
-      if (null != user)
+      if (null != user) {
         throw new AmbariException("User already exists.");
+      }
 
       users.createUser(request.getUsername(), request.getPassword());
 
@@ -663,8 +666,9 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
         user = users.getAnyUser(request.getUsername());
         if (null != user) {
           for (String role : request.getRoles()) {
-            if (!user.getRoles().contains(role))
+            if (!user.getRoles().contains(role)) {
               users.addRoleToUser(user, role);
+            }
           }
         }
       }
@@ -1836,8 +1840,9 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
             // any targeted information
             String keyName = scHost.getServiceComponentName().toLowerCase();
             if (requestProperties.containsKey(keyName)) {
-              if (null == requestParameters)
+              if (null == requestParameters) {
                 requestParameters = new HashMap<String, String>();
+              }
               requestParameters.put(keyName, requestProperties.get(keyName));
             }
 
@@ -2318,8 +2323,9 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
   public synchronized void updateUsers(Set<UserRequest> requests) throws AmbariException {
     for (UserRequest request : requests) {
       User u = users.getAnyUser(request.getUsername());
-      if (null == u)
+      if (null == u) {
         continue;
+      }
 
       if (null != request.getOldPassword() && null != request.getPassword()) {
         users.modifyPassword(u.getUserName(), request.getOldPassword(),
@@ -2464,8 +2470,9 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
             + ", username=" + r.getUsername());
       }
       User u = users.getAnyUser(r.getUsername());
-      if (null != u)
+      if (null != u) {
         users.removeUser(u);
+      }
     }
   }
 
@@ -2609,7 +2616,9 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
             }
           }
         }
-        if (throwException) throw e;
+        if (throwException) {
+          throw e;
+        }
       }
     }
     return response;
@@ -2931,10 +2940,10 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
     String stackName = request.getStackName();
 
     if (stackName != null) {
-      org.apache.ambari.server.state.Stack stack = this.ambariMetaInfo.getStack(stackName);
+      org.apache.ambari.server.state.Stack stack = ambariMetaInfo.getStack(stackName);
       response = Collections.singleton(stack.convertToResponse());
     } else {
-      Set<org.apache.ambari.server.state.Stack> supportedStackNames = this.ambariMetaInfo.getStackNames();
+      Set<org.apache.ambari.server.state.Stack> supportedStackNames = ambariMetaInfo.getStackNames();
       response = new HashSet<StackResponse>();
       for (org.apache.ambari.server.state.Stack stack: supportedStackNames) {
         response.add(stack.convertToResponse());
@@ -2993,7 +3002,7 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
     Set<RepositoryResponse> response;
 
     if (repoId == null) {
-      List<RepositoryInfo> repositories = this.ambariMetaInfo.getRepositories(stackName, stackVersion, osType);
+      List<RepositoryInfo> repositories = ambariMetaInfo.getRepositories(stackName, stackVersion, osType);
       response = new HashSet<RepositoryResponse>();
 
       for (RepositoryInfo repository: repositories) {
@@ -3001,7 +3010,7 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
       }
 
     } else {
-      RepositoryInfo repository = this.ambariMetaInfo.getRepository(stackName, stackVersion, osType, repoId);
+      RepositoryInfo repository = ambariMetaInfo.getRepository(stackName, stackVersion, osType, repoId);
       response = Collections.singleton(repository.convertToResponse());
     }
 
@@ -3011,17 +3020,21 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
   @Override
   public void updateRespositories(Set<RepositoryRequest> requests) throws AmbariException {
     for (RepositoryRequest rr : requests) {
-      if (null == rr.getStackName() || rr.getStackName().isEmpty())
+      if (null == rr.getStackName() || rr.getStackName().isEmpty()) {
         throw new AmbariException("Stack name must be specified.");
+      }
 
-      if (null == rr.getStackVersion() || rr.getStackVersion().isEmpty())
+      if (null == rr.getStackVersion() || rr.getStackVersion().isEmpty()) {
         throw new AmbariException("Stack version must be specified.");
+      }
 
-      if (null == rr.getOsType() || rr.getOsType().isEmpty())
+      if (null == rr.getOsType() || rr.getOsType().isEmpty()) {
         throw new AmbariException("OS type must be specified.");
+      }
 
-      if (null == rr.getRepoId() || rr.getRepoId().isEmpty())
+      if (null == rr.getRepoId() || rr.getRepoId().isEmpty()) {
         throw new AmbariException("Repo ID must be specified.");
+      }
 
       if (null != rr.getBaseUrl()) {
         if (!rr.isVerifyBaseUrl()) {
@@ -3043,12 +3056,13 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
             String suffix = String.format(suffixes[i], repoName);
             String spec = rr.getBaseUrl();
 
-            if (spec.charAt(spec.length()-1) != '/' && suffix.charAt(0) != '/')
+            if (spec.charAt(spec.length()-1) != '/' && suffix.charAt(0) != '/') {
               spec = rr.getBaseUrl() + "/" + suffix;
-            else if (spec.charAt(spec.length()-1) == '/' && suffix.charAt(0) == '/')
+            } else if (spec.charAt(spec.length()-1) == '/' && suffix.charAt(0) == '/') {
               spec = rr.getBaseUrl() + suffix.substring(1);
-            else
+            } else {
               spec = rr.getBaseUrl() + suffix;
+            }
 
             try {
               IOUtils.readLines(usp.readFrom(spec));
@@ -3110,10 +3124,10 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
     String stackVersion = request.getStackVersion();
 
     if (stackVersion != null) {
-      StackInfo stackInfo = this.ambariMetaInfo.getStackInfo(stackName, stackVersion);
+      StackInfo stackInfo = ambariMetaInfo.getStackInfo(stackName, stackVersion);
       response = Collections.singleton(stackInfo.convertToResponse());
     } else {
-      Set<StackInfo> stackInfos = this.ambariMetaInfo.getStackInfos(stackName);
+      Set<StackInfo> stackInfos = ambariMetaInfo.getStackInfos(stackName);
       response = new HashSet<StackVersionResponse>();
       for (StackInfo stackInfo: stackInfos) {
         response.add(stackInfo.convertToResponse());
@@ -3162,13 +3176,13 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
     String serviceName = request.getServiceName();
 
     if (serviceName != null) {
-      ServiceInfo service = this.ambariMetaInfo.getService(stackName, stackVersion, serviceName);
-      response = Collections.singleton(service.convertToResponse());
+      ServiceInfo service = ambariMetaInfo.getService(stackName, stackVersion, serviceName);
+      response = Collections.singleton(new StackServiceResponse(service));
     } else {
-      Map<String, ServiceInfo> services = this.ambariMetaInfo.getServices(stackName, stackVersion);
+      Map<String, ServiceInfo> services = ambariMetaInfo.getServices(stackName, stackVersion);
       response = new HashSet<StackServiceResponse>();
       for (ServiceInfo service : services.values()) {
-        response.add(service.convertToResponse());
+        response.add(new StackServiceResponse(service));
       }
     }
     return response;
@@ -3209,11 +3223,11 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
     String propertyName = request.getPropertyName();
 
     if (propertyName != null) {
-      PropertyInfo property = this.ambariMetaInfo.getProperty(stackName, stackVersion, serviceName, propertyName);
+      PropertyInfo property = ambariMetaInfo.getProperty(stackName, stackVersion, serviceName, propertyName);
       response = Collections.singleton(property.convertToResponse());
     } else {
 
-      Set<PropertyInfo> properties = this.ambariMetaInfo.getProperties(stackName, stackVersion, serviceName);
+      Set<PropertyInfo> properties = ambariMetaInfo.getProperties(stackName, stackVersion, serviceName);
       response = new HashSet<StackConfigurationResponse>();
 
       for (PropertyInfo property: properties) {
@@ -3265,15 +3279,16 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
     String componentName = request.getComponentName();
 
     if (componentName != null) {
-      ComponentInfo component = this.ambariMetaInfo.getComponent(stackName, stackVersion, serviceName, componentName);
-      response = Collections.singleton(component.convertToResponse());
+      ComponentInfo component = ambariMetaInfo.getComponent(stackName, stackVersion, serviceName, componentName);
+      response = Collections.singleton(new StackServiceComponentResponse(
+          component));
 
     } else {
-      List<ComponentInfo> components = this.ambariMetaInfo.getComponentsByService(stackName, stackVersion, serviceName);
+      List<ComponentInfo> components = ambariMetaInfo.getComponentsByService(stackName, stackVersion, serviceName);
       response = new HashSet<StackServiceComponentResponse>();
 
       for (ComponentInfo component: components) {
-        response.add(component.convertToResponse());
+        response.add(new StackServiceComponentResponse(component));
       }
     }
     return response;
@@ -3316,13 +3331,14 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
     String osType = request.getOsType();
 
     if (osType != null) {
-      OperatingSystemInfo operatingSystem = this.ambariMetaInfo.getOperatingSystem(stackName, stackVersion, osType);
+      OperatingSystemInfo operatingSystem = ambariMetaInfo.getOperatingSystem(stackName, stackVersion, osType);
       response = Collections.singleton(operatingSystem.convertToResponse());
     } else {
-      Set<OperatingSystemInfo> operatingSystems = this.ambariMetaInfo.getOperatingSystems(stackName, stackVersion);
+      Set<OperatingSystemInfo> operatingSystems = ambariMetaInfo.getOperatingSystems(stackName, stackVersion);
       response = new HashSet<OperatingSystemResponse>();
-      for (OperatingSystemInfo operatingSystem : operatingSystems)
+      for (OperatingSystemInfo operatingSystem : operatingSystems) {
         response.add(operatingSystem.convertToResponse());
+      }
     }
 
     return response;
@@ -3353,7 +3369,7 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
 
   private Set<RootServiceResponse> getRootServices (RootServiceRequest request)
       throws AmbariException{
-    return this.rootServiceResponseFactory.getRootServices(request);
+    return rootServiceResponseFactory.getRootServices(request);
   }
 
   @Override
@@ -3383,7 +3399,7 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
 
   private Set<RootServiceComponentResponse> getRootServiceComponents(
       RootServiceComponentRequest request) throws AmbariException{
-    return this.rootServiceResponseFactory.getRootServiceComponents(request);
+    return rootServiceResponseFactory.getRootServiceComponents(request);
   }
 
   @Override
@@ -3462,15 +3478,17 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
     return mysqljdbcUrl;
   }
 
+  @Override
   public Map<String, String> getRcaParameters() {
 
     String hostName = StageUtils.getHostName();
 
     String url = configs.getRcaDatabaseUrl();
-    if (url.contains(Configuration.HOSTNAME_MACRO))
+    if (url.contains(Configuration.HOSTNAME_MACRO)) {
       url =
           url.replace(Configuration.HOSTNAME_MACRO,
               hostsMap.getHostMap(hostName));
+    }
 
     Map<String, String> rcaParameters = new HashMap<String, String>();
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/6705a0f6/ambari-server/src/main/java/org/apache/ambari/server/controller/StackServiceComponentResponse.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/StackServiceComponentResponse.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/StackServiceComponentResponse.java
index fe2c0d6..d76f350 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/StackServiceComponentResponse.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/StackServiceComponentResponse.java
@@ -18,7 +18,13 @@
 
 package org.apache.ambari.server.controller;
 
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
 import org.apache.ambari.server.state.AutoDeployInfo;
+import org.apache.ambari.server.state.ComponentInfo;
+import org.apache.ambari.server.state.CustomCommandDefinition;
 
 /**
  * Stack service component response.
@@ -69,14 +75,36 @@ public class StackServiceComponentResponse {
    */
   private AutoDeployInfo autoDeploy;
 
+  /**
+   * The names of the custom commands defined for the component.
+   */
+  private List<String> customCommands;
+
 
-  public StackServiceComponentResponse(String componentName, String componentCategory,
-      boolean isClient, boolean isMaster, String cardinality) {
-    setComponentName(componentName);
-    setComponentCategory(componentCategory);
-    setClient(isClient);
-    setMaster(isMaster);
-    setCardinality(cardinality);
+  /**
+   * Constructor.
+   *
+   * @param component
+   *          the component to generate the response from (not {@code null}).
+   */
+  public StackServiceComponentResponse(ComponentInfo component) {
+    componentName = component.getName();
+    componentCategory = component.getCategory();
+    isClient = component.isClient();
+    isMaster = component.isMaster();
+    cardinality = component.getCardinality();
+    autoDeploy = component.getAutoDeploy();
+
+    // the custom command names defined for this component
+    List<CustomCommandDefinition> definitions = component.getCustomCommands();
+    if (null == definitions || definitions.size() == 0) {
+      customCommands = Collections.emptyList();
+    } else {
+      customCommands = new ArrayList<String>(definitions.size());
+      for (CustomCommandDefinition command : definitions) {
+        customCommands.add(command.getName());
+      }
+    }
   }
 
   /**
@@ -240,4 +268,13 @@ public class StackServiceComponentResponse {
   public void setAutoDeploy(AutoDeployInfo autoDeploy) {
     this.autoDeploy = autoDeploy;
   }
+
+  /**
+   * Gets the names of all of the custom commands for this component.
+   *
+   * @return the commands or an empty list (never {@code null}).
+   */
+  public List<String> getCustomCommands() {
+    return customCommands;
+  }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/6705a0f6/ambari-server/src/main/java/org/apache/ambari/server/controller/StackServiceResponse.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/StackServiceResponse.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/StackServiceResponse.java
index df91239..25b3b8d 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/StackServiceResponse.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/StackServiceResponse.java
@@ -18,29 +18,51 @@
 
 package org.apache.ambari.server.controller;
 
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
 import java.util.Map;
 
+import org.apache.ambari.server.state.CustomCommandDefinition;
+import org.apache.ambari.server.state.ServiceInfo;
+
 public class StackServiceResponse {
 
   private String stackName;
   private String stackVersion;
   private String serviceName;
-
   private String userName;
-
   private String comments;
-  
   private String serviceVersion;
-  
+  private boolean serviceCheckSupported;
+  private List<String> customCommands;
+
   private Map<String, Map<String, Map<String, String>>> configTypes;
 
-  public StackServiceResponse(String serviceName, String userName, String comments, String serviceVersion,
-      Map<String, Map<String, Map<String, String>>> types) {
-    setServiceName(serviceName);
-    setUserName(userName);
-    setComments(comments);
-    setServiceVersion(serviceVersion);
-    configTypes = types;
+  /**
+   * Constructor.
+   *
+   * @param service
+   *          the service to generate the response from (not {@code null}).
+   */
+  public StackServiceResponse(ServiceInfo service) {
+    serviceName = service.getName();
+    userName = null;
+    comments = service.getComment();
+    serviceVersion = service.getVersion();
+    configTypes = service.getConfigTypes();
+    serviceCheckSupported = null != service.getCommandScript();
+
+    // the custom command names defined at the service (not component) level
+    List<CustomCommandDefinition> definitions = service.getCustomCommands();
+    if (null == definitions || definitions.size() == 0) {
+      customCommands = Collections.emptyList();
+    } else {
+      customCommands = new ArrayList<String>(definitions.size());
+      for (CustomCommandDefinition command : definitions) {
+        customCommands.add(command.getName());
+      }
+    }
   }
 
   public String getStackName() {
@@ -90,9 +112,31 @@ public class StackServiceResponse {
   public void setServiceVersion(String serviceVersion) {
     this.serviceVersion = serviceVersion;
   }
-  
+
   public Map<String, Map<String, Map<String, String>>> getConfigTypes() {
     return configTypes;
   }
 
+  /**
+   * Gets whether the service represented by this response supports running
+   * "Service Checks". A service check is possible where there is a custom
+   * command defined in the {@code metainfo.xml} of the service definition. This
+   * not the same as a custom command defined for a component.
+   *
+   * @return {@code true} if this service supports running "Service Checks",
+   *         {@code false} otherwise.
+   *
+   */
+  public boolean isServiceCheckSupported() {
+    return serviceCheckSupported;
+  }
+
+  /**
+   * Gets the names of all of the custom commands for this service.
+   *
+   * @return the commands or an empty list (never {@code null}).
+   */
+  public List<String> getCustomCommands() {
+    return customCommands;
+  }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/6705a0f6/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackServiceComponentResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackServiceComponentResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackServiceComponentResourceProvider.java
index 86d0455..e7e50d0 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackServiceComponentResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackServiceComponentResourceProvider.java
@@ -42,27 +42,38 @@ import org.apache.ambari.server.state.AutoDeployInfo;
 public class StackServiceComponentResourceProvider extends
     ReadOnlyResourceProvider {
 
-  protected static final String STACK_NAME_PROPERTY_ID = PropertyHelper
-      .getPropertyId("StackServiceComponents", "stack_name");
-  protected static final String STACK_VERSION_PROPERTY_ID = PropertyHelper
-      .getPropertyId("StackServiceComponents", "stack_version");
-  protected static final String SERVICE_NAME_PROPERTY_ID = PropertyHelper
-      .getPropertyId("StackServiceComponents", "service_name");
-  protected static final String COMPONENT_NAME_PROPERTY_ID = PropertyHelper
-      .getPropertyId("StackServiceComponents", "component_name");
-  protected static final String COMPONENT_CATEGORY_PROPERTY_ID = PropertyHelper
-      .getPropertyId("StackServiceComponents", "component_category");
-  protected static final String IS_CLIENT_PROPERTY_ID = PropertyHelper
-      .getPropertyId("StackServiceComponents", "is_client");
-  protected static final String IS_MASTER_PROPERTY_ID = PropertyHelper
-      .getPropertyId("StackServiceComponents", "is_master");
-  protected static final String CARDINALITY_ID = PropertyHelper
-      .getPropertyId("StackServiceComponents", "cardinality");
-  protected static final String AUTO_DEPLOY_ENABLED_ID = PropertyHelper
-      .getPropertyId("auto_deploy", "enabled");
-  protected static final String AUTO_DEPLOY_LOCATION_ID = PropertyHelper
-      .getPropertyId("auto_deploy", "location");
+  private static final String STACK_NAME_PROPERTY_ID = PropertyHelper.getPropertyId(
+      "StackServiceComponents", "stack_name");
 
+  private static final String STACK_VERSION_PROPERTY_ID = PropertyHelper.getPropertyId(
+      "StackServiceComponents", "stack_version");
+
+  private static final String SERVICE_NAME_PROPERTY_ID = PropertyHelper.getPropertyId(
+      "StackServiceComponents", "service_name");
+
+  private static final String COMPONENT_NAME_PROPERTY_ID = PropertyHelper.getPropertyId(
+      "StackServiceComponents", "component_name");
+
+  private static final String COMPONENT_CATEGORY_PROPERTY_ID = PropertyHelper.getPropertyId(
+      "StackServiceComponents", "component_category");
+
+  private static final String IS_CLIENT_PROPERTY_ID = PropertyHelper.getPropertyId(
+      "StackServiceComponents", "is_client");
+
+  private static final String IS_MASTER_PROPERTY_ID = PropertyHelper.getPropertyId(
+      "StackServiceComponents", "is_master");
+
+  private static final String CARDINALITY_ID = PropertyHelper.getPropertyId(
+      "StackServiceComponents", "cardinality");
+
+  private static final String CUSTOM_COMMANDS_PROPERTY_ID = PropertyHelper.getPropertyId(
+      "StackServiceComponents", "custom_commands");
+
+  private static final String AUTO_DEPLOY_ENABLED_ID = PropertyHelper.getPropertyId(
+      "auto_deploy", "enabled");
+
+  private static final String AUTO_DEPLOY_LOCATION_ID = PropertyHelper.getPropertyId(
+      "auto_deploy", "location");
 
   private static Set<String> pkPropertyIds = new HashSet<String>(
       Arrays.asList(new String[] { STACK_NAME_PROPERTY_ID,
@@ -106,28 +117,31 @@ public class StackServiceComponentResourceProvider extends
 
       setResourceProperty(resource, STACK_NAME_PROPERTY_ID,
           response.getStackName(), requestedIds);
-      
+
       setResourceProperty(resource, STACK_VERSION_PROPERTY_ID,
           response.getStackVersion(), requestedIds);
-      
+
       setResourceProperty(resource, SERVICE_NAME_PROPERTY_ID,
           response.getServiceName(), requestedIds);
-      
+
       setResourceProperty(resource, COMPONENT_NAME_PROPERTY_ID,
           response.getComponentName(), requestedIds);
-      
+
       setResourceProperty(resource, COMPONENT_CATEGORY_PROPERTY_ID,
           response.getComponentCategory(), requestedIds);
-      
+
       setResourceProperty(resource, IS_CLIENT_PROPERTY_ID,
           response.isClient(), requestedIds);
-      
+
       setResourceProperty(resource, IS_MASTER_PROPERTY_ID,
           response.isMaster(), requestedIds);
 
       setResourceProperty(resource, CARDINALITY_ID,
           response.getCardinality(), requestedIds);
 
+      setResourceProperty(resource, CUSTOM_COMMANDS_PROPERTY_ID,
+          response.getCustomCommands(), requestedIds);
+
       AutoDeployInfo autoDeployInfo = response.getAutoDeploy();
       if (autoDeployInfo != null) {
         setResourceProperty(resource, AUTO_DEPLOY_ENABLED_ID,

http://git-wip-us.apache.org/repos/asf/ambari/blob/6705a0f6/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackServiceResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackServiceResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackServiceResourceProvider.java
index 21546e4..0523edc 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackServiceResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackServiceResourceProvider.java
@@ -41,26 +41,32 @@ import org.apache.ambari.server.controller.utilities.PropertyHelper;
 
 public class StackServiceResourceProvider extends ReadOnlyResourceProvider {
 
-  protected static final String SERVICE_NAME_PROPERTY_ID = PropertyHelper
-      .getPropertyId("StackServices", "service_name");
+  protected static final String SERVICE_NAME_PROPERTY_ID = PropertyHelper.getPropertyId(
+      "StackServices", "service_name");
 
-  public static final String STACK_NAME_PROPERTY_ID = PropertyHelper
-      .getPropertyId("StackServices", "stack_name");
+  public static final String STACK_NAME_PROPERTY_ID = PropertyHelper.getPropertyId(
+      "StackServices", "stack_name");
 
-  public static final String STACK_VERSION_PROPERTY_ID = PropertyHelper
-      .getPropertyId("StackServices", "stack_version");
+  public static final String STACK_VERSION_PROPERTY_ID = PropertyHelper.getPropertyId(
+      "StackServices", "stack_version");
 
-  private static final String USER_NAME_PROPERTY_ID = PropertyHelper
-      .getPropertyId("StackServices", "user_name");
+  private static final String USER_NAME_PROPERTY_ID = PropertyHelper.getPropertyId(
+      "StackServices", "user_name");
 
-  private static final String COMMENTS_PROPERTY_ID = PropertyHelper
-      .getPropertyId("StackServices", "comments");
+  private static final String COMMENTS_PROPERTY_ID = PropertyHelper.getPropertyId(
+      "StackServices", "comments");
 
-  private static final String VERSION_PROPERTY_ID = PropertyHelper
-      .getPropertyId("StackServices", "service_version");
-  
-  private static final String CONFIG_TYPES = PropertyHelper
-      .getPropertyId("StackServices", "config_types");
+  private static final String VERSION_PROPERTY_ID = PropertyHelper.getPropertyId(
+      "StackServices", "service_version");
+
+  private static final String CONFIG_TYPES = PropertyHelper.getPropertyId(
+      "StackServices", "config_types");
+
+  private static final String SERVICE_CHECK_SUPPORTED_PROPERTY_ID = PropertyHelper.getPropertyId(
+      "StackServices", "service_check_supported");
+
+  private static final String CUSTOM_COMMANDS_PROPERTY_ID = PropertyHelper.getPropertyId(
+      "StackServices", "custom_commands");
 
   private static Set<String> pkPropertyIds = new HashSet<String>(
       Arrays.asList(new String[] { STACK_NAME_PROPERTY_ID,
@@ -115,13 +121,19 @@ public class StackServiceResourceProvider extends ReadOnlyResourceProvider {
 
       setResourceProperty(resource, COMMENTS_PROPERTY_ID,
           response.getComments(), requestedIds);
-      
+
       setResourceProperty(resource, VERSION_PROPERTY_ID,
           response.getServiceVersion(), requestedIds);
-      
+
       setResourceProperty(resource, CONFIG_TYPES,
           response.getConfigTypes(), requestedIds);
 
+      setResourceProperty(resource, SERVICE_CHECK_SUPPORTED_PROPERTY_ID,
+          response.isServiceCheckSupported(), requestedIds);
+
+      setResourceProperty(resource, CUSTOM_COMMANDS_PROPERTY_ID,
+          response.getCustomCommands(), requestedIds);
+
       resources.add(resource);
     }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/6705a0f6/ambari-server/src/main/java/org/apache/ambari/server/state/ComponentInfo.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/ComponentInfo.java b/ambari-server/src/main/java/org/apache/ambari/server/state/ComponentInfo.java
index feec350..06977b2 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/ComponentInfo.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/ComponentInfo.java
@@ -18,17 +18,15 @@
 
 package org.apache.ambari.server.state;
 
+import java.util.ArrayList;
+import java.util.List;
+
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlElementWrapper;
 import javax.xml.bind.annotation.XmlElements;
 
-import org.apache.ambari.server.controller.StackServiceComponentResponse;
-
-import java.util.ArrayList;
-import java.util.List;
-
 @XmlAccessorType(XmlAccessType.FIELD)
 public class ComponentInfo {
   private String name;
@@ -105,16 +103,6 @@ public class ComponentInfo {
     return "MASTER".equals(category);
   }
 
-  public StackServiceComponentResponse convertToResponse() {
-    StackServiceComponentResponse response = new StackServiceComponentResponse(
-        getName(), getCategory(), isClient(), isMaster(), cardinality);
-
-    if (autoDeploy != null) {
-      response.setAutoDeploy(autoDeploy);
-    }
-    return response;
-  }
-
   public boolean isDeleted() {
     return deleted;
   }
@@ -185,6 +173,6 @@ public class ComponentInfo {
   }
 
   public String getCardinality() {
-    return this.cardinality;
+    return cardinality;
   }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/6705a0f6/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceInfo.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceInfo.java b/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceInfo.java
index ee5ab44..f2d9fe3 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceInfo.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceInfo.java
@@ -36,7 +36,6 @@ import javax.xml.bind.annotation.XmlElements;
 import javax.xml.bind.annotation.XmlTransient;
 
 import org.apache.ambari.server.api.services.AmbariMetaInfo;
-import org.apache.ambari.server.controller.StackServiceResponse;
 import org.apache.ambari.server.state.stack.MetricDefinition;
 import org.codehaus.jackson.annotate.JsonIgnore;
 import org.codehaus.jackson.map.annotate.JsonFilter;
@@ -224,15 +223,10 @@ public class ServiceInfo {
     return sb.toString();
   }
   
-  public StackServiceResponse convertToResponse()
-  {
-    return new StackServiceResponse(getName(), null, getComment(), getVersion(),
-        getConfigTypes());
-  }
-  
   public Map<String, Map<String, Map<String, String>>> getConfigTypes() {
     return configTypes;
   }
+
   public void setConfigTypes(Map<String, Map<String, Map<String, String>>> configTypes) {
     this.configTypes = configTypes;
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/6705a0f6/ambari-server/src/main/resources/properties.json
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/properties.json b/ambari-server/src/main/resources/properties.json
index 65f4a95..8c0c9fc 100644
--- a/ambari-server/src/main/resources/properties.json
+++ b/ambari-server/src/main/resources/properties.json
@@ -226,6 +226,8 @@
         "StackServices/comments",
         "StackServices/service_version",
         "StackServices/config_types",
+        "StackServices/service_check_supported",
+        "StackServices/custom_commands",
         "_"
     ],
     "StackConfiguration":[
@@ -248,6 +250,7 @@
         "StackServiceComponents/is_client",
         "StackServiceComponents/is_master",
         "StackServiceComponents/cardinality",
+        "StackServiceComponents/custom_commands",
         "auto_deploy/enabled",
         "auto_deploy/location",
         "_"

http://git-wip-us.apache.org/repos/asf/ambari/blob/6705a0f6/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 8c92ba3..efacf41 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
@@ -155,6 +155,7 @@ public class AmbariManagementControllerTest {
   private static final String REPO_ID = "HDP-1.1.1.16";
   private static final String PROPERTY_NAME = "hbase.regionserver.msginterval";
   private static final String SERVICE_NAME = "HDFS";
+  private static final String NAGIOS_SERVICE_NAME = "NAGIOS";
   private static final int STACK_VERSIONS_CNT = 12;
   private static final int REPOS_CNT = 3;
   private static final int STACKS_CNT = 1;
@@ -217,15 +218,15 @@ public class AmbariManagementControllerTest {
     injector.getInstance(PersistService.class).stop();
     actionDB = null;
   }
-  
+
   private void setOsFamily(Host host, String osFamily, String osVersion) {
     Map<String, String> hostAttributes = new HashMap<String, String>();
     hostAttributes.put("os_family", osFamily);
     hostAttributes.put("os_release_version", osVersion);
-    
+
     host.setHostAttributes(hostAttributes);
   }
-  
+
   private void addHost(String hostname) throws AmbariException {
     addHost(hostname, null);
   }
@@ -235,8 +236,9 @@ public class AmbariManagementControllerTest {
     setOsFamily(clusters.getHost(hostname), "redhat", "6.3");
     clusters.getHost(hostname).setState(HostState.HEALTHY);
     clusters.getHost(hostname).persist();
-    if (null != clusterName)
+    if (null != clusterName) {
       clusters.mapHostToCluster(hostname, clusterName);
+    }
   }
 
   private void deleteHost(String hostname) throws AmbariException {
@@ -572,7 +574,7 @@ public class AmbariManagementControllerTest {
     } catch (Exception e) {
       // Expected
     }
-    
+
     r.setStackVersion("HDP-1.0.1");
     r.setProvisioningState(State.INSTALLING.name());
     try {
@@ -580,7 +582,7 @@ public class AmbariManagementControllerTest {
      fail("Expected create cluster for invalid request - invalid provisioning state");
     } catch (Exception e) {
       // Expected
-    }    
+    }
   }
 
   @Test
@@ -3607,7 +3609,7 @@ public class AmbariManagementControllerTest {
 
     Map<String,String> mapRequestProps = new HashMap<String, String>();
     mapRequestProps.put("context", "testServiceComponentHostUpdateStackId");
-    
+
     RequestStatusResponse resp = controller.updateHostComponents(reqs, mapRequestProps, true);
     List<Stage> stages = actionDB.getAllStages(resp.getRequestId());
     Assert.assertEquals(1, stages.size());
@@ -3981,7 +3983,7 @@ public class AmbariManagementControllerTest {
     assertEquals(1, response.getTasks().size());
     taskStatus = response.getTasks().get(0);
     Assert.assertEquals("h3", taskStatus.getHostName());
-    
+
     Assert.assertTrue(null != cmd.getPassiveInfo());
   }
 
@@ -4056,7 +4058,7 @@ public class AmbariManagementControllerTest {
     Map<String, String> requestProperties = new HashMap<String, String>();
     requestProperties.put(REQUEST_CONTEXT_PROPERTY, "Called from a test");
     requestProperties.put("hdfs_client", "abc");
-    
+
     RequestStatusResponse response = controller.createAction(actionRequest, requestProperties);
 
     List<Stage> stages = actionDB.getAllStages(response.getRequestId());
@@ -4076,7 +4078,7 @@ public class AmbariManagementControllerTest {
       .getExecutionCommand().getRoleParams();
     Map<String, String> hostParams = hrc.getExecutionCommandWrapper()
         .getExecutionCommand().getHostLevelParams();
-        
+
     Assert.assertNotNull(roleParams);
     Assert.assertTrue(hostParams.containsKey(ExecutionCommand.KeyNames.DB_DRIVER_FILENAME));
     Assert.assertTrue(hostParams.containsKey(ExecutionCommand.KeyNames.MYSQL_JDBC_URL));
@@ -4084,7 +4086,7 @@ public class AmbariManagementControllerTest {
     Assert.assertEquals("CLIENT", roleParams.get(ExecutionCommand.KeyNames.COMPONENT_CATEGORY));
     Assert.assertTrue(hrc.getExecutionCommandWrapper().getExecutionCommand().getCommandParams().containsKey("hdfs_client"));
     Assert.assertEquals("abc", hrc.getExecutionCommandWrapper().getExecutionCommand().getCommandParams().get("hdfs_client"));
-    
+
     // verify passive info is not passed when not NAGIOS
     Assert.assertNull(hrc.getExecutionCommandWrapper().getExecutionCommand().getPassiveInfo());
   }
@@ -4102,18 +4104,18 @@ public class AmbariManagementControllerTest {
     hdfs.addServiceComponent(Role.HDFS_CLIENT.name()).persist();
     hdfs.addServiceComponent(Role.NAMENODE.name()).persist();
     hdfs.addServiceComponent(Role.DATANODE.name()).persist();
-    
+
     hdfs.getServiceComponent(Role.HDFS_CLIENT.name()).addServiceComponentHost("h1").persist();
     hdfs.getServiceComponent(Role.NAMENODE.name()).addServiceComponentHost("h1").persist();
     hdfs.getServiceComponent(Role.DATANODE.name()).addServiceComponentHost("h1").persist();
-    
 
-    
+
+
     Service nagios = cluster.addService("NAGIOS");
     nagios.persist();
     nagios.addServiceComponent(Role.NAGIOS_SERVER.name()).persist();
     nagios.getServiceComponent(Role.NAGIOS_SERVER.name()).addServiceComponentHost("h1").persist();
-    
+
     installService("c1", "HDFS", false, false);
     installService("c1", "NAGIOS", false, false);
 
@@ -4123,8 +4125,8 @@ public class AmbariManagementControllerTest {
     // set this after starting - setting it before will skip it due to rules
     // around bulk starts
     hdfs.getServiceComponent(Role.DATANODE.name()).getServiceComponentHost(
-        "h1").setMaintenanceState(MaintenanceState.ON);    
-    
+        "h1").setMaintenanceState(MaintenanceState.ON);
+
     Cluster c = clusters.getCluster("c1");
     Service s = c.getService("HDFS");
 
@@ -4169,10 +4171,10 @@ public class AmbariManagementControllerTest {
     Assert.assertNotNull(hrc);
     Assert.assertEquals("RESTART NAGIOS/NAGIOS_SERVER", hrc.getCommandDetail());
 
-    
+
     Set<Map<String, String>> pi =
         hrc.getExecutionCommandWrapper().getExecutionCommand().getPassiveInfo();
-    
+
     Assert.assertNotNull(pi);
     Assert.assertTrue(pi.size() > 0);
     Map<String, String> map = pi.iterator().next();
@@ -4182,9 +4184,9 @@ public class AmbariManagementControllerTest {
     Assert.assertEquals("h1", map.get("host"));
     Assert.assertEquals("HDFS", map.get("service"));
     Assert.assertEquals("DATANODE", map.get("component"));
-  }  
-  
-  
+  }
+
+
   @SuppressWarnings("serial")
   @Test
   public void testCreateActionsFailures() throws Exception {
@@ -4540,7 +4542,7 @@ public class AmbariManagementControllerTest {
     resourceFilter = new RequestResourceFilter("MAPREDUCE", null, null);
     actionRequest.getResourceFilters().add(resourceFilter);
 
-    this.injector.getInstance(ActionMetadata.class).addServiceCheckAction("MAPREDUCE");
+    injector.getInstance(ActionMetadata.class).addServiceCheckAction("MAPREDUCE");
     response = controller.createAction(actionRequest, requestProperties);
 
     assertEquals(1, response.getTasks().size());
@@ -4970,7 +4972,7 @@ public class AmbariManagementControllerTest {
 
     Map<String, String> configs = new HashMap<String, String>();
     configs.put("a", "b");
-    
+
     Map<String, Map<String, String>> configAttributes = new HashMap<String, Map<String,String>>();
     configAttributes.put("final", new HashMap<String, String>());
     configAttributes.get("final").put("a", "true");
@@ -5329,16 +5331,18 @@ public class AmbariManagementControllerTest {
       for (HostRoleCommand hrc : hrcs) {
         LOG.debug("role: " + hrc.getRole());
         if (hrc.getRole().toString().equals("HDFS_CLIENT")) {
-          if (hrc.getHostName().equals(host3))
+          if (hrc.getHostName().equals(host3)) {
             hdfsCmdHost3 = hrc;
-          else if (hrc.getHostName().equals(host2))
+          } else if (hrc.getHostName().equals(host2)) {
             hdfsCmdHost2 = hrc;
+          }
         }
         if (hrc.getRole().toString().equals("MAPREDUCE_CLIENT")) {
-          if (hrc.getHostName().equals(host2))
+          if (hrc.getHostName().equals(host2)) {
             mapRedCmdHost2 = hrc;
-          else if (hrc.getHostName().equals(host3))
+          } else if (hrc.getHostName().equals(host3)) {
             mapRedCmdHost3 = hrc;
+          }
         }
       }
     }
@@ -5371,8 +5375,9 @@ public class AmbariManagementControllerTest {
     for (Stage stage : stages) {
       for (HostRoleCommand hrc : stage.getOrderedHostRoleCommands()) {
         if (hrc.getRole().toString().equals("MAPREDUCE_CLIENT") && hrc
-          .getHostName().equals(host2))
+          .getHostName().equals(host2)) {
           clientWithHostDown = hrc;
+        }
       }
     }
     Assert.assertNull(clientWithHostDown);
@@ -5491,10 +5496,10 @@ public class AmbariManagementControllerTest {
     String componentName1 = "PIG";
     createServiceComponent(clusterName, serviceName, componentName1,
         State.INIT);
-    
+
     String host1 = "h1";
     String host2 = "h2";
-    
+
     addHost(host1, clusterName);
     addHost(host2, clusterName);
 
@@ -5545,7 +5550,7 @@ public class AmbariManagementControllerTest {
     requests.clear();
     requests.add(r);
 
-    this.injector.getInstance(ActionMetadata.class).addServiceCheckAction("PIG");
+    injector.getInstance(ActionMetadata.class).addServiceCheckAction("PIG");
     trackAction = ServiceResourceProviderTest.updateServices(controller, requests, mapRequestProps, true, false);
     Assert.assertNotNull(trackAction);
     Assert.assertEquals(State.INSTALLED,
@@ -6618,7 +6623,7 @@ public class AmbariManagementControllerTest {
 
     String host1 = "h1";
     String host2 = "h2";
-    
+
     addHost(host1, clusterName);
     addHost(host2, clusterName);
 
@@ -7102,8 +7107,6 @@ public class AmbariManagementControllerTest {
 
   @Test
   public void testGetStackServices() throws Exception {
-
-
     StackServiceRequest request = new StackServiceRequest(STACK_NAME, NEW_STACK_VERSION, null);
     Set<StackServiceResponse> responses = controller.getStackServices(Collections.singleton(request));
     Assert.assertEquals(12, responses.size());
@@ -7124,26 +7127,23 @@ public class AmbariManagementControllerTest {
     } catch (StackAccessException e) {
       // do nothing
     }
-
-
   }
+
   @Test
   public void testConfigInComponent() throws Exception {
     StackServiceRequest requestWithParams = new StackServiceRequest(STACK_NAME, "2.0.6", "YARN");
     Set<StackServiceResponse> responsesWithParams = controller.getStackServices(Collections.singleton(requestWithParams));
-    
+
     Assert.assertEquals(1, responsesWithParams.size());
-    
+
     for (StackServiceResponse responseWithParams: responsesWithParams) {
       Assert.assertEquals(responseWithParams.getServiceName(), "YARN");
       Assert.assertTrue(responseWithParams.getConfigTypes().containsKey("capacity-scheduler"));
     }
   }
-  
+
   @Test
   public void testGetStackConfigurations() throws Exception {
-
-
     StackConfigurationRequest request = new StackConfigurationRequest(STACK_NAME, STACK_VERSION, SERVICE_NAME, null);
     Set<StackConfigurationResponse> responses = controller.getStackConfigurations(Collections.singleton(request));
     Assert.assertEquals(STACK_PROPERTIES_CNT, responses.size());
@@ -7168,8 +7168,6 @@ public class AmbariManagementControllerTest {
 
   @Test
   public void testGetStackComponents() throws Exception {
-
-
     StackServiceComponentRequest request = new StackServiceComponentRequest(STACK_NAME, STACK_VERSION, SERVICE_NAME, null);
     Set<StackServiceComponentResponse> responses = controller.getStackComponents(Collections.singleton(request));
     Assert.assertEquals(STACK_COMPONENTS_CNT, responses.size());
@@ -7189,14 +7187,10 @@ public class AmbariManagementControllerTest {
     } catch (StackAccessException e) {
       // do nothing
     }
-
-
   }
 
   @Test
   public void testGetStackOperatingSystems() throws Exception {
-
-
     OperatingSystemRequest request = new OperatingSystemRequest(STACK_NAME, STACK_VERSION, null);
     Set<OperatingSystemResponse> responses = controller.getStackOperatingSystems(Collections.singleton(request));
     Assert.assertEquals(OS_CNT, responses.size());
@@ -7219,6 +7213,52 @@ public class AmbariManagementControllerTest {
   }
 
   @Test
+  public void testStackServiceCheckSupported() throws Exception {
+    StackServiceRequest hdfsServiceRequest = new StackServiceRequest(
+        STACK_NAME,
+        NEW_STACK_VERSION, SERVICE_NAME);
+
+    Set<StackServiceResponse> responses = controller.getStackServices(Collections.singleton(hdfsServiceRequest));
+    Assert.assertEquals(1, responses.size());
+
+    StackServiceResponse response = responses.iterator().next();
+    assertTrue(response.isServiceCheckSupported());
+
+    StackServiceRequest nagiosServiceRequest = new StackServiceRequest(
+        STACK_NAME, NEW_STACK_VERSION, NAGIOS_SERVICE_NAME);
+
+    responses = controller.getStackServices(Collections.singleton(nagiosServiceRequest));
+    Assert.assertEquals(1, responses.size());
+
+    response = responses.iterator().next();
+    assertFalse(response.isServiceCheckSupported());
+  }
+
+  @Test
+  public void testStackServiceComponentCustomCommands() throws Exception {
+    StackServiceComponentRequest namenodeRequest = new StackServiceComponentRequest(
+        STACK_NAME, NEW_STACK_VERSION, SERVICE_NAME, COMPONENT_NAME);
+
+    Set<StackServiceComponentResponse> responses = controller.getStackComponents(Collections.singleton(namenodeRequest));
+    Assert.assertEquals(1, responses.size());
+
+    StackServiceComponentResponse response = responses.iterator().next();
+    assertNotNull(response.getCustomCommands());
+    assertEquals(1, response.getCustomCommands().size());
+    assertEquals("DECOMMISSION", response.getCustomCommands().get(0));
+
+    StackServiceComponentRequest journalNodeRequest = new StackServiceComponentRequest(
+        STACK_NAME, NEW_STACK_VERSION, SERVICE_NAME, "JOURNALNODE");
+
+    responses = controller.getStackComponents(Collections.singleton(journalNodeRequest));
+    Assert.assertEquals(1, responses.size());
+
+    response = responses.iterator().next();
+    assertNotNull(response.getCustomCommands());
+    assertEquals(0, response.getCustomCommands().size());
+  }
+
+  @Test
   public void testServerActionForUpgradeFinalization() throws AmbariException {
     String clusterName = "foo1";
     StackId currentStackId = new StackId("HDP-0.1");
@@ -7661,33 +7701,33 @@ public class AmbariManagementControllerTest {
     }
 
     private void fillRoleToIndex() {
-      this.roleToIndex.put(Role.NAMENODE, 0);
-      this.roleToIndex.put(Role.SECONDARY_NAMENODE, 1);
-      this.roleToIndex.put(Role.DATANODE, 2);
-      this.roleToIndex.put(Role.HDFS_CLIENT, 3);
-      this.roleToIndex.put(Role.JOBTRACKER, 4);
-      this.roleToIndex.put(Role.TASKTRACKER, 5);
-      this.roleToIndex.put(Role.MAPREDUCE_CLIENT, 6);
-      this.roleToIndex.put(Role.ZOOKEEPER_SERVER, 7);
-      this.roleToIndex.put(Role.ZOOKEEPER_CLIENT, 8);
-      this.roleToIndex.put(Role.HBASE_MASTER, 9);
-
-      this.roleToIndex.put(Role.HBASE_REGIONSERVER, 10);
-      this.roleToIndex.put(Role.HBASE_CLIENT, 11);
-      this.roleToIndex.put(Role.HIVE_SERVER, 12);
-      this.roleToIndex.put(Role.HIVE_METASTORE, 13);
-      this.roleToIndex.put(Role.HIVE_CLIENT, 14);
-      this.roleToIndex.put(Role.HCAT, 15);
-      this.roleToIndex.put(Role.OOZIE_SERVER, 16);
-      this.roleToIndex.put(Role.OOZIE_CLIENT, 17);
-      this.roleToIndex.put(Role.WEBHCAT_SERVER, 18);
-      this.roleToIndex.put(Role.PIG, 19);
-
-      this.roleToIndex.put(Role.SQOOP, 20);
-      this.roleToIndex.put(Role.GANGLIA_SERVER, 21);
-      this.roleToIndex.put(Role.GANGLIA_MONITOR, 22);
-      this.roleToIndex.put(Role.NAGIOS_SERVER, 23);
-      this.roleToIndex.put(Role.AMBARI_SERVER_ACTION, 24);
+      roleToIndex.put(Role.NAMENODE, 0);
+      roleToIndex.put(Role.SECONDARY_NAMENODE, 1);
+      roleToIndex.put(Role.DATANODE, 2);
+      roleToIndex.put(Role.HDFS_CLIENT, 3);
+      roleToIndex.put(Role.JOBTRACKER, 4);
+      roleToIndex.put(Role.TASKTRACKER, 5);
+      roleToIndex.put(Role.MAPREDUCE_CLIENT, 6);
+      roleToIndex.put(Role.ZOOKEEPER_SERVER, 7);
+      roleToIndex.put(Role.ZOOKEEPER_CLIENT, 8);
+      roleToIndex.put(Role.HBASE_MASTER, 9);
+
+      roleToIndex.put(Role.HBASE_REGIONSERVER, 10);
+      roleToIndex.put(Role.HBASE_CLIENT, 11);
+      roleToIndex.put(Role.HIVE_SERVER, 12);
+      roleToIndex.put(Role.HIVE_METASTORE, 13);
+      roleToIndex.put(Role.HIVE_CLIENT, 14);
+      roleToIndex.put(Role.HCAT, 15);
+      roleToIndex.put(Role.OOZIE_SERVER, 16);
+      roleToIndex.put(Role.OOZIE_CLIENT, 17);
+      roleToIndex.put(Role.WEBHCAT_SERVER, 18);
+      roleToIndex.put(Role.PIG, 19);
+
+      roleToIndex.put(Role.SQOOP, 20);
+      roleToIndex.put(Role.GANGLIA_SERVER, 21);
+      roleToIndex.put(Role.GANGLIA_MONITOR, 22);
+      roleToIndex.put(Role.NAGIOS_SERVER, 23);
+      roleToIndex.put(Role.AMBARI_SERVER_ACTION, 24);
     }
   }
 
@@ -7781,8 +7821,9 @@ public class AmbariManagementControllerTest {
       clusters.getCluster(clusterName).getService(serviceName)
         .getServiceComponents().values()) {
       for (ServiceComponentHost sch : sc.getServiceComponentHosts().values()) {
-        if (!sch.getServiceComponentName().equals("HDFS_CLIENT"))
+        if (!sch.getServiceComponentName().equals("HDFS_CLIENT")) {
           sch.setState(State.STARTED);
+        }
       }
     }
 
@@ -8048,8 +8089,8 @@ public class AmbariManagementControllerTest {
     ExecutionCommandWrapper execWrapper = execWrappers.iterator().next();
     Assert.assertTrue(execWrapper.getExecutionCommand().getCommandParams().containsKey("datanode"));
     Assert.assertFalse(execWrapper.getExecutionCommand().getCommandParams().containsKey("namendode"));
-     
-    
+
+
 
     // set the host components on host2 to UNKNOWN state to simulate a lost host
     for (ServiceComponentHost sch : clusters.getCluster(clusterName).getServiceComponentHosts(host2)) {
@@ -8200,7 +8241,7 @@ public class AmbariManagementControllerTest {
     request.setVerifyBaseUrl(false);
     controller.updateRespositories(requests);
     Assert.assertEquals(request.getBaseUrl(), repo.getBaseUrl());
-    
+
     requests.clear();
     request = new RepositoryRequest(STACK_NAME, STACK_VERSION, OS_TYPE, REPO_ID);
     request.setBaseUrl("https://hortonworks.com");
@@ -8211,7 +8252,7 @@ public class AmbariManagementControllerTest {
     } catch (Exception e) {
       System.err.println(e.getMessage());
       assertTrue(e.getMessage().contains(IOException.class.getName()));
-    }    
+    }
 
     requests.clear();
     request = new RepositoryRequest(STACK_NAME, STACK_VERSION, OS_TYPE, REPO_ID);
@@ -8222,7 +8263,7 @@ public class AmbariManagementControllerTest {
       controller.updateRespositories(requests);
     } catch (Exception e) {
       assertTrue(e.getMessage().contains(MalformedURLException.class.getName()));
-    } 
+    }
 
     requests.clear();
     request = new RepositoryRequest(STACK_NAME, STACK_VERSION, OS_TYPE, REPO_ID);
@@ -8235,8 +8276,8 @@ public class AmbariManagementControllerTest {
       String exceptionMsg = e.getMessage();
       assertTrue(exceptionMsg.contains(UnknownHostException.class.getName())
         || exceptionMsg.contains(ConnectException.class.getName()));
-    }      
-    
+    }
+
     // reset repo
     requests.clear();
     request = new RepositoryRequest(STACK_NAME, STACK_VERSION, OS_TYPE, REPO_ID);
@@ -8246,8 +8287,9 @@ public class AmbariManagementControllerTest {
     Assert.assertEquals(repo.getBaseUrl(), repo.getDefaultBaseUrl());
 
     String baseUrl = repo.getDefaultBaseUrl();
-    if (!baseUrl.endsWith("/"))
+    if (!baseUrl.endsWith("/")) {
       baseUrl += "/";
+    }
 
     // variation #1: url with trailing slash, suffix preceding slash
     backingProperties.setProperty(Configuration.REPO_SUFFIX_KEY_UBUNTU, "/repodata/repomd.xml");
@@ -8498,7 +8540,7 @@ public class AmbariManagementControllerTest {
     }
 
   }
-  
+
   @Test
   public void testGetRootServices() throws Exception {
 
@@ -9654,7 +9696,7 @@ public class AmbariManagementControllerTest {
 
     assertTrue(zookeeperSch.isRestartRequired());   //Restart if removing host!
   }
-  
+
   @Test
   public void testMaintenanceState() throws Exception {
     String clusterName = "c1";
@@ -9681,7 +9723,7 @@ public class AmbariManagementControllerTest {
 
     String host1 = "h1";
     String host2 = "h2";
-    
+
     addHost(host1, clusterName);
     addHost(host2, clusterName);
 
@@ -9692,21 +9734,21 @@ public class AmbariManagementControllerTest {
 
     Map<String, String> requestProperties = new HashMap<String, String>();
     requestProperties.put("context", "Called from a test");
-    
+
     Cluster cluster = clusters.getCluster(clusterName);
     Service service = cluster.getService(serviceName);
     Map<String, Host> hosts = clusters.getHostsForCluster(clusterName);
 
     MaintenanceStateHelper maintenanceStateHelper =
             MaintenanceStateHelperTest.getMaintenanceStateHelperInstance(clusters);
-    
+
     // test updating a service
     ServiceRequest sr = new ServiceRequest(clusterName, serviceName, null);
     sr.setMaintenanceState(MaintenanceState.ON.name());
     ServiceResourceProviderTest.updateServices(controller, Collections.singleton(sr),
         requestProperties, false, false, maintenanceStateHelper);
     Assert.assertEquals(MaintenanceState.ON, service.getMaintenanceState());
-    
+
     // check the host components implied state vs desired state
     for (ServiceComponent sc : service.getServiceComponents().values()) {
       for (ServiceComponentHost sch : sc.getServiceComponentHosts().values()) {
@@ -9715,13 +9757,13 @@ public class AmbariManagementControllerTest {
         Assert.assertEquals(MaintenanceState.OFF, sch.getMaintenanceState());
       }
     }
-    
+
     // reset
     sr.setMaintenanceState(MaintenanceState.OFF.name());
     ServiceResourceProviderTest.updateServices(controller, Collections.singleton(sr),
         requestProperties, false, false, maintenanceStateHelper);
     Assert.assertEquals(MaintenanceState.OFF, service.getMaintenanceState());
-    
+
     // check the host components implied state vs desired state
     for (ServiceComponent sc : service.getServiceComponents().values()) {
       for (ServiceComponentHost sch : sc.getServiceComponentHosts().values()) {
@@ -9730,16 +9772,16 @@ public class AmbariManagementControllerTest {
         Assert.assertEquals(MaintenanceState.OFF, sch.getMaintenanceState());
       }
     }
-    
+
     // passivate a host
     HostRequest hr = new HostRequest(host1, clusterName, requestProperties);
     hr.setMaintenanceState(MaintenanceState.ON.name());
     HostResourceProviderTest.updateHosts(controller, Collections.singleton(hr),
         new HashMap<String, String>());
-    
+
     Host host = hosts.get(host1);
     Assert.assertEquals(MaintenanceState.ON, host.getMaintenanceState(cluster.getClusterId()));
-    
+
     // check the host components implied state vs desired state, only for affected hosts
     for (ServiceComponent sc : service.getServiceComponents().values()) {
       for (ServiceComponentHost sch : sc.getServiceComponentHosts().values()) {
@@ -9752,15 +9794,15 @@ public class AmbariManagementControllerTest {
         Assert.assertEquals(MaintenanceState.OFF, sch.getMaintenanceState());
       }
     }
-    
+
     // reset
     hr.setMaintenanceState(MaintenanceState.OFF.name());
     HostResourceProviderTest.updateHosts(controller, Collections.singleton(hr),
         new HashMap<String, String>());
-    
+
     host = hosts.get(host1);
     Assert.assertEquals(MaintenanceState.OFF, host.getMaintenanceState(cluster.getClusterId()));
-    
+
     // check the host components active state vs desired state
     for (ServiceComponent sc : service.getServiceComponents().values()) {
       for (ServiceComponentHost sch : sc.getServiceComponentHosts().values()) {
@@ -9769,7 +9811,7 @@ public class AmbariManagementControllerTest {
         Assert.assertEquals(MaintenanceState.OFF, sch.getMaintenanceState());
       }
     }
-    
+
     // passivate several hosts
     HostRequest hr1 = new HostRequest(host1, clusterName, requestProperties);
     hr1.setMaintenanceState(MaintenanceState.ON.name());
@@ -9784,7 +9826,7 @@ public class AmbariManagementControllerTest {
     Assert.assertEquals(MaintenanceState.ON, host.getMaintenanceState(cluster.getClusterId()));
     host = hosts.get(host2);
     Assert.assertEquals(MaintenanceState.ON, host.getMaintenanceState(cluster.getClusterId()));
-    
+
     // reset
     hr1 = new HostRequest(host1, clusterName, requestProperties);
     hr1.setMaintenanceState(MaintenanceState.OFF.name());
@@ -9800,7 +9842,7 @@ public class AmbariManagementControllerTest {
     host = hosts.get(host2);
     Assert.assertEquals(MaintenanceState.OFF, host.getMaintenanceState(cluster.getClusterId()));
 
-    
+
     // only do one SCH
     ServiceComponentHost targetSch = service.getServiceComponent(
         componentName2).getServiceComponentHosts().get(host2);
@@ -9809,26 +9851,26 @@ public class AmbariManagementControllerTest {
 
     // check the host components active state vs desired state
     Assert.assertEquals(MaintenanceState.ON, controller.getEffectiveMaintenanceState(targetSch));
-    
+
     // update the service
     service.setMaintenanceState(MaintenanceState.ON);
     Assert.assertEquals(MaintenanceState.ON, controller.getEffectiveMaintenanceState(targetSch));
-    
+
     // make SCH active
     targetSch.setMaintenanceState(MaintenanceState.OFF);
     Assert.assertEquals(MaintenanceState.IMPLIED_FROM_SERVICE,
       controller.getEffectiveMaintenanceState(targetSch));
-    
+
     // update the service
     service.setMaintenanceState(MaintenanceState.OFF);
     Assert.assertEquals(MaintenanceState.OFF, controller.getEffectiveMaintenanceState(targetSch));
-    
+
     host = hosts.get(host2);
     // update host
     host.setMaintenanceState(cluster.getClusterId(), MaintenanceState.ON);
     Assert.assertEquals(MaintenanceState.IMPLIED_FROM_HOST,
       controller.getEffectiveMaintenanceState(targetSch));
-    
+
     targetSch.setMaintenanceState(MaintenanceState.ON);
     Assert.assertEquals(MaintenanceState.ON, controller.getEffectiveMaintenanceState(targetSch));
 
@@ -9837,7 +9879,7 @@ public class AmbariManagementControllerTest {
       for (ServiceComponentHost sch : sc.getServiceComponentHosts().values()) {
         Assert.assertEquals(State.INIT, sch.getState());
       }
-    }    
+    }
 
     long id1 = installService(clusterName, serviceName, false, false, maintenanceStateHelper);
     long id2 = installService(clusterName, nagiosService, false, false, maintenanceStateHelper);
@@ -9873,9 +9915,10 @@ public class AmbariManagementControllerTest {
 
     // verify passive sch was skipped
     for (ServiceComponent sc : service.getServiceComponents().values()) {
-      if (!sc.getName().equals(componentName2))
+      if (!sc.getName().equals(componentName2)) {
         continue;
-      
+      }
+
       for (ServiceComponentHost sch : sc.getServiceComponentHosts().values()) {
         Assert.assertEquals(sch == targetSch ? State.INIT : State.INSTALLED, sch.getState());
       }
@@ -9889,12 +9932,12 @@ public class AmbariManagementControllerTest {
     createCluster(clusterName);
     clusters.getCluster(clusterName)
         .setDesiredStackVersion(new StackId("HDP-0.1"));
-    
+
     String serviceName1 = "HDFS";
     String serviceName2 = "MAPREDUCE";
     createService(clusterName, serviceName1, null);
     createService(clusterName, serviceName2, null);
-    
+
     String componentName1_1 = "NAMENODE";
     String componentName1_2 = "DATANODE";
     String componentName1_3 = "HDFS_CLIENT";
@@ -9904,54 +9947,54 @@ public class AmbariManagementControllerTest {
         State.INIT);
     createServiceComponent(clusterName, serviceName1, componentName1_3,
         State.INIT);
-    
+
     String componentName2_1 = "JOBTRACKER";
     String componentName2_2 = "TASKTRACKER";
     createServiceComponent(clusterName, serviceName2, componentName2_1,
         State.INIT);
     createServiceComponent(clusterName, serviceName2, componentName2_2,
         State.INIT);
-    
+
     String host1 = "h1";
     String host2 = "h2";
-    
+
     addHost(host1, clusterName);
     addHost(host2, clusterName);
 
     createServiceComponentHost(clusterName, serviceName1, componentName1_1, host1, null);
     createServiceComponentHost(clusterName, serviceName1, componentName1_2, host1, null);
     createServiceComponentHost(clusterName, serviceName1, componentName1_2, host2, null);
-    
+
     createServiceComponentHost(clusterName, serviceName2, componentName2_1, host1, null);
     createServiceComponentHost(clusterName, serviceName2, componentName2_2, host2, null);
 
     MaintenanceStateHelper maintenanceStateHelper =
             MaintenanceStateHelperTest.getMaintenanceStateHelperInstance(clusters);
-    
+
     installService(clusterName, serviceName1, false, false, maintenanceStateHelper);
     installService(clusterName, serviceName2, false, false, maintenanceStateHelper);
-    
+
     startService(clusterName, serviceName1, false, false, maintenanceStateHelper);
     startService(clusterName, serviceName2, false, false, maintenanceStateHelper);
-    
+
     Map<String, String> requestProperties = new HashMap<String, String>();
     requestProperties.put("context", "Called from a test");
 
     Cluster cluster = clusters.getCluster(clusterName);
-    
+
     for (Service service : cluster.getServices().values()) {
       Assert.assertEquals(State.STARTED, service.getDesiredState());
     }
-    
+
     Service service2 = cluster.getService(serviceName2);
     service2.setMaintenanceState(MaintenanceState.ON);
-    
+
     Set<ServiceRequest> srs = new HashSet<ServiceRequest>();
     srs.add(new ServiceRequest(clusterName, serviceName1, State.INSTALLED.name()));
     srs.add(new ServiceRequest(clusterName, serviceName2, State.INSTALLED.name()));
     RequestStatusResponse rsr = ServiceResourceProviderTest.updateServices(controller, srs,
             requestProperties, false, false, maintenanceStateHelper);
-    
+
     for (ShortTaskStatus sts : rsr.getTasks()) {
       String role = sts.getRole();
       Assert.assertFalse(role.equals(componentName2_1));
@@ -9959,52 +10002,53 @@ public class AmbariManagementControllerTest {
     }
 
     for (Service service : cluster.getServices().values()) {
-      if (service.getName().equals(serviceName2))
+      if (service.getName().equals(serviceName2)) {
         Assert.assertEquals(State.STARTED, service.getDesiredState());
-      else
+      } else {
         Assert.assertEquals(State.INSTALLED, service.getDesiredState());
+      }
     }
-    
+
     service2.setMaintenanceState(MaintenanceState.OFF);
     ServiceResourceProviderTest.updateServices(controller, srs, requestProperties,
             false, false, maintenanceStateHelper);
     for (Service service : cluster.getServices().values()) {
       Assert.assertEquals(State.INSTALLED, service.getDesiredState());
     }
-    
+
     startService(clusterName, serviceName1, false, false, maintenanceStateHelper);
     startService(clusterName, serviceName2, false, false, maintenanceStateHelper);
-    
+
     // test host
     Host h1 = clusters.getHost(host1);
     h1.setMaintenanceState(cluster.getClusterId(), MaintenanceState.ON);
-    
+
     srs = new HashSet<ServiceRequest>();
     srs.add(new ServiceRequest(clusterName, serviceName1, State.INSTALLED.name()));
     srs.add(new ServiceRequest(clusterName, serviceName2, State.INSTALLED.name()));
-    
+
     rsr = ServiceResourceProviderTest.updateServices(controller, srs, requestProperties,
             false, false, maintenanceStateHelper);
-    
+
     for (ShortTaskStatus sts : rsr.getTasks()) {
       Assert.assertFalse(sts.getHostName().equals(host1));
     }
-    
+
     h1.setMaintenanceState(cluster.getClusterId(), MaintenanceState.OFF);
     startService(clusterName, serviceName2, false, false, maintenanceStateHelper);
-    
+
     service2.setMaintenanceState(MaintenanceState.ON);
 
     ServiceRequest sr = new ServiceRequest(clusterName, serviceName2, State.INSTALLED.name());
     rsr = ServiceResourceProviderTest.updateServices(controller,
         Collections.singleton(sr), requestProperties, false, false, maintenanceStateHelper);
-    
+
     Assert.assertTrue("Service start request defaults to Cluster operation level," +
                     "command does not create tasks",
         rsr == null || rsr.getTasks().size() == 0);
-    
+
   }
-  
+
   @Test
   public void testEmptyConfigs() throws Exception {
     String clusterName = "c1";
@@ -10020,14 +10064,14 @@ public class AmbariManagementControllerTest {
     controller.updateClusters(Collections.singleton(cr), new HashMap<String, String>());
     Config config = cluster.getDesiredConfigByType("typeA");
     Assert.assertNull(config);
-    
+
     // test empty map with no prior
     cr.setDesiredConfig(
         new ConfigurationRequest(clusterName, "typeA", "v1", new HashMap<String, String>(), new HashMap<String, Map<String,String>>()));
     controller.updateClusters(Collections.singleton(cr), new HashMap<String, String>());
     config = cluster.getDesiredConfigByType("typeA");
     Assert.assertNotNull(config);
-    
+
     // test empty properties on a new version
     cr.setDesiredConfig(
         new ConfigurationRequest(clusterName, "typeA", "v2", new HashMap<String, String>(), new HashMap<String, Map<String,String>>()));
@@ -10035,7 +10079,7 @@ public class AmbariManagementControllerTest {
     config = cluster.getDesiredConfigByType("typeA");
     Assert.assertNotNull(config);
     Assert.assertEquals(Integer.valueOf(0), Integer.valueOf(config.getProperties().size()));
-    
+
     // test new version
     Map<String, String> map = new HashMap<String, String>();
     map.clear();
@@ -10049,7 +10093,7 @@ public class AmbariManagementControllerTest {
     config = cluster.getDesiredConfigByType("typeA");
     Assert.assertNotNull(config);
     Assert.assertTrue(config.getProperties().containsKey("c"));
-    
+
     // test reset to v2
     cr.setDesiredConfig(
         new ConfigurationRequest(clusterName, "typeA", "v2", new HashMap<String, String>(), new HashMap<String, Map<String,String>>()));
@@ -10058,10 +10102,10 @@ public class AmbariManagementControllerTest {
     Assert.assertEquals("v2", config.getTag());
     Assert.assertNotNull(config);
     Assert.assertEquals(Integer.valueOf(0), Integer.valueOf(config.getProperties().size()));
-    
+
     // test v2, but with properties
     cr.setDesiredConfig(
-        new ConfigurationRequest(clusterName, "typeA", "v2", new HashMap<String, String>() {{ put("a", "b"); }}, 
+        new ConfigurationRequest(clusterName, "typeA", "v2", new HashMap<String, String>() {{ put("a", "b"); }},
             new HashMap<String, Map<String,String>>(){{put("final", new HashMap<String, String>(){{put("a", "true");}});
           }
         }));
@@ -10079,14 +10123,14 @@ public class AmbariManagementControllerTest {
     String hostname2 = "h2";
     addHost(hostname1);
     addHost(hostname2);
-    
+
     ambariMetaInfo.addActionDefinition(new ActionDefinition("a1", ActionType.SYSTEM,
         "", "", "", "action def description", TargetHostType.ANY,
         Short.valueOf("60")));
-    
+
     Map<String, String> requestProperties = new HashMap<String, String>();
     requestProperties.put(REQUEST_CONTEXT_PROPERTY, "Called from a test");
-    
+
     Map<String, String> requestParams = new HashMap<String, String>();
     requestParams.put("some_custom_param", "abc");
 
@@ -10095,7 +10139,7 @@ public class AmbariManagementControllerTest {
     RequestResourceFilter resourceFilter = new RequestResourceFilter(null, null, hosts);
     List<RequestResourceFilter> resourceFilters = new ArrayList<RequestResourceFilter>();
     resourceFilters.add(resourceFilter);
-    
+
     ExecuteActionRequest actionRequest = new ExecuteActionRequest(null, null,
         "a1", resourceFilters, null, requestParams);
     RequestStatusResponse response = controller.createAction(actionRequest, requestProperties);
@@ -10106,26 +10150,26 @@ public class AmbariManagementControllerTest {
     Stage stage = actionDB.getAllStages(response.getRequestId()).get(0);
     Assert.assertNotNull(stage);
     Assert.assertEquals(-1L, stage.getClusterId());
-    
-    List<HostRoleCommand> storedTasks = actionDB.getRequestTasks(response.getRequestId());    
+
+    List<HostRoleCommand> storedTasks = actionDB.getRequestTasks(response.getRequestId());
     Assert.assertEquals(1, storedTasks.size());
     HostRoleCommand task = storedTasks.get(0);
     Assert.assertEquals(RoleCommand.ACTIONEXECUTE, task.getRoleCommand());
     Assert.assertEquals("a1", task.getRole().name());
     Assert.assertEquals(hostname1, task.getHostName());
-    
+
     ExecutionCommand cmd = task.getExecutionCommandWrapper().getExecutionCommand();
     Assert.assertTrue(cmd.getCommandParams().containsKey("some_custom_param"));
     Assert.assertEquals(null, cmd.getServiceName());
     Assert.assertEquals(null, cmd.getComponentName());
-    
+
     // !!! target two hosts
 
     hosts = Arrays.asList(hostname1, hostname2);
     resourceFilter = new RequestResourceFilter(null, null, hosts);
     resourceFilters = new ArrayList<RequestResourceFilter>();
     resourceFilters.add(resourceFilter);
-    
+
     actionRequest = new ExecuteActionRequest(null, null,
         "a1", resourceFilters, null, requestParams);
     response = controller.createAction(actionRequest, requestProperties);
@@ -10133,10 +10177,11 @@ public class AmbariManagementControllerTest {
     boolean host1Found = false;
     boolean host2Found = false;
     for (ShortTaskStatus sts : response.getTasks()) {
-      if (sts.getHostName().equals(hostname1))
+      if (sts.getHostName().equals(hostname1)) {
         host1Found = true;
-      else if (sts.getHostName().equals(hostname2))
+      } else if (sts.getHostName().equals(hostname2)) {
         host2Found = true;
+      }
     }
     Assert.assertTrue(host1Found);
     Assert.assertTrue(host2Found);
@@ -10144,14 +10189,14 @@ public class AmbariManagementControllerTest {
     stage = actionDB.getAllStages(response.getRequestId()).get(0);
     Assert.assertNotNull(stage);
     Assert.assertEquals(-1L, stage.getClusterId());
-    
-    storedTasks = actionDB.getRequestTasks(response.getRequestId());    
+
+    storedTasks = actionDB.getRequestTasks(response.getRequestId());
     Assert.assertEquals(2, storedTasks.size());
     task = storedTasks.get(0);
     Assert.assertEquals(RoleCommand.ACTIONEXECUTE, task.getRoleCommand());
     Assert.assertEquals("a1", task.getRole().name());
     Assert.assertEquals(hostname1, task.getHostName());
-    
+
     cmd = task.getExecutionCommandWrapper().getExecutionCommand();
     Assert.assertTrue(cmd.getCommandParams().containsKey("some_custom_param"));
     Assert.assertEquals(null, cmd.getServiceName());
@@ -10202,7 +10247,7 @@ public class AmbariManagementControllerTest {
     ConfigurationRequest cr1 = new ConfigurationRequest(clusterName, "hdfs-site", "version1", hdfsConfigs, hdfsConfigAttributes);
     ClusterRequest crReq1 = new ClusterRequest(null, clusterName, null, null);
     crReq1.setDesiredConfig(cr1);
-    
+
     controller.updateClusters(Collections.singleton(crReq1), null);
 
     // Start
@@ -10258,4 +10303,4 @@ public class AmbariManagementControllerTest {
 
 }
 
-  
+