public TreeMap<String, String> getTopologyCommandParams(Long clusterId, String serviceName, String componentName, ServiceComponentHost sch) throws AmbariException {
    TreeMap<String, String> commandParams = new TreeMap<>();
    RepositoryVersionEntity repositoryVersion = getComponentRepositoryVersion(clusterId, serviceName, componentName);
    if (null != repositoryVersion) {
      StackId stackId = repositoryVersion.getStackId();
      ServiceInfo serviceInfo = ambariMetaInfo.getService(stackId.getStackName(),
          stackId.getStackVersion(), serviceName);
      ComponentInfo componentInfo = ambariMetaInfo.getComponent(
          stackId.getStackName(), stackId.getStackVersion(),
          serviceName, componentName);

      commandParams.put(SERVICE_PACKAGE_FOLDER, serviceInfo.getServicePackageFolder());
      String scriptName = null;
      String scriptCommandTimeout = "";
      CommandScriptDefinition script = componentInfo.getCommandScript();
      if (serviceInfo.getSchemaVersion().equals(AmbariMetaInfo.SCHEMA_VERSION_2)) {
        if (script != null) {
          scriptName = script.getScript();
          if (script.getTimeout() > 0) {
            scriptCommandTimeout = String.valueOf(script.getTimeout());
          }
        } else {
          String message = String.format("Component %s of service %s has not " +
              "command script defined", componentName, serviceName);
          throw new AmbariException(message);
        }
      }
      String agentDefaultCommandTimeout = configs.getDefaultAgentTaskTimeout(false);
      String actualTimeout = (!scriptCommandTimeout.equals("") ? scriptCommandTimeout : agentDefaultCommandTimeout);

      commandParams.put(COMMAND_TIMEOUT, actualTimeout);
      commandParams.put(SCRIPT, scriptName);
      commandParams.put(SCRIPT_TYPE, script.getScriptType().toString());
    }
    String schVersion = sch.getVersion();
    if (!schVersion.equals("UNKNOWN")) {
      commandParams.put(VERSION, schVersion);
    }
    return commandParams;
  }
Collects full metadata info about clusters for agent.
@return metadata info about clusters
@throws AmbariException
ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java