private TreeMap<String, String> getMetadataClusterLevelConfigsParams(Cluster cluster, StackId stackId) throws AmbariException {
    TreeMap<String, String> clusterLevelParams = new TreeMap<>();

    Map<String, DesiredConfig> desiredConfigs = cluster.getDesiredConfigs(false);
    if (MapUtils.isNotEmpty(desiredConfigs)) {

      Set<String> userSet = configHelper.getPropertyValuesWithPropertyType(stackId, PropertyType.USER, cluster, desiredConfigs);
      String userList = gson.toJson(userSet);
      clusterLevelParams.put(USER_LIST, userList);

      //Create a user_group mapping and send it as part of the hostLevelParams
      Map<String, Set<String>> userGroupsMap = configHelper.createUserGroupsMap(
          stackId, cluster, desiredConfigs);
      String userGroups = gson.toJson(userGroupsMap);
      clusterLevelParams.put(USER_GROUPS, userGroups);

      Set<String> groupSet = configHelper.getPropertyValuesWithPropertyType(stackId, PropertyType.GROUP, cluster, desiredConfigs);
      String groupList = gson.toJson(groupSet);
      clusterLevelParams.put(GROUP_LIST, groupList);
    }
    Set<String> notManagedHdfsPathSet = configHelper.getPropertyValuesWithPropertyType(stackId,
        PropertyType.NOT_MANAGED_HDFS_PATH, cluster, desiredConfigs);
    String notManagedHdfsPathList = gson.toJson(notManagedHdfsPathSet);
    clusterLevelParams.put(NOT_MANAGED_HDFS_PATH_LIST, notManagedHdfsPathList);

    for (Service service : cluster.getServices().values()) {
      ServiceInfo serviceInfoInstance = ambariMetaInfo.getService(service);
      String serviceType = serviceInfoInstance.getServiceType();
      if (serviceType != null) {
        LOG.debug("Adding {} to command parameters for {}", serviceInfoInstance.getServiceType(),
          serviceInfoInstance.getName());
        clusterLevelParams.put(DFS_TYPE, serviceInfoInstance.getServiceType());
        break;
      }
    }

    return clusterLevelParams;
  }
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