public String getStatusCommandTimeout(ServiceInfo serviceInfo) throws AmbariException {
    String commandTimeout = configs.getDefaultAgentTaskTimeout(false);

    if (serviceInfo.getSchemaVersion().equals(AmbariMetaInfo.SCHEMA_VERSION_2)) {
      // Service check command is not custom command
      CommandScriptDefinition script = serviceInfo.getCommandScript();
      if (script != null) {
        if (script.getTimeout() > 0) {
          commandTimeout = String.valueOf(script.getTimeout());
        }
      } else {
        String message = String.format("Service %s has no command script " +
            "defined. It is not possible to run service check" +
            " for this service", serviceInfo.getName());
        throw new AmbariException(message);
      }
    }

    // Try to apply overridden service check timeout value if available
    Long overriddenTimeout = configs.getAgentServiceCheckTaskTimeout();
    if (!overriddenTimeout.equals(Configuration.AGENT_SERVICE_CHECK_TASK_TIMEOUT.getDefaultValue())) {
      commandTimeout = String.valueOf(overriddenTimeout);
    }
    return commandTimeout;
  }
Filter hosts according to status of host/host components
@param hosts Host name set to filter
@param actionExecutionContext Received request to execute a command
@param resourceFilter Resource filter
@return Set of excluded hosts
@throws AmbariException
ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelper.java