public boolean isTopologyRefreshRequired(String actionName, String clusterName, String serviceName)
      throws AmbariException {

    if (actionName.equals(START_COMMAND_NAME) || actionName.equals(RESTART_COMMAND_NAME)) {
      Cluster cluster = clusters.getCluster(clusterName);
      StackId stackId = null;
      if (serviceName != null) {
        try {
          Service service = cluster.getService(serviceName);
          stackId = service.getDesiredStackId();
        } catch (AmbariException e) {
          LOG.debug("Could not load service {}, skipping topology check", serviceName);
        }
      }

      if (stackId == null) {
        stackId = cluster.getDesiredStackVersion();
      }

      AmbariMetaInfo ambariMetaInfo = managementController.getAmbariMetaInfo();

      StackInfo stack = ambariMetaInfo.getStack(stackId.getStackName(), stackId.getStackVersion());
      if (stack != null) {
        ServiceInfo serviceInfo = stack.getService(serviceName);

        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;
  }
Determine whether or not the action should trigger a topology refresh.

@param actionName   the action name (i.e. START, RESTART)
@param clusterName  the cluster name
@param serviceName  the service name

@return true if a topology refresh is required for the action
ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelper.java