public int setServiceState(String serviceName, String state) {
    StateProvider.State s = state.equals("STARTED") ? StateProvider.State.Running :
        state.equals("INSTALLED") ? StateProvider.State.Stopped : StateProvider.State.Unknown;

    int requestId = -1;
    if (!isClientOnlyService(serviceName)) {
      // if the state is already set to the desired state or state is unknown then skip it
      if (s != StateProvider.State.Unknown && !state.equals(getServiceState(serviceName))) {
        Map<String, Set<String>> serviceHostComponents = hostComponents.get(serviceName);
        if (serviceHostComponents != null) {

          for (Map.Entry<String, Set<String>> entry : serviceHostComponents.entrySet()) {
            String      hostName       = entry.getKey();
            Set<String> componentNames = entry.getValue();

            for (String componentName : componentNames) {
              if(isClientOnlyComponent(componentName) || state.equals(getHostComponentState(hostName, componentName))) continue;
              requestId = recordProcess(stateProvider.setRunningState(hostName, componentName, s), requestId,
                      "Set service " + serviceName + " state to " + s);
            }
          }
        }
      }
    }
    return requestId;
  }
Set the service state for the given service name.

@param serviceName  the service name

@return the request id
contrib/ambari-scom/ambari-scom-server/src/main/java/org/apache/ambari/msi/ClusterDefinition.java