当前位置: 首页>>代码示例>>Java>>正文


Java YarnApplicationState.valueOf方法代码示例

本文整理汇总了Java中org.apache.hadoop.yarn.api.records.YarnApplicationState.valueOf方法的典型用法代码示例。如果您正苦于以下问题:Java YarnApplicationState.valueOf方法的具体用法?Java YarnApplicationState.valueOf怎么用?Java YarnApplicationState.valueOf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.yarn.api.records.YarnApplicationState的用法示例。


在下文中一共展示了YarnApplicationState.valueOf方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: computeState

import org.apache.hadoop.yarn.api.records.YarnApplicationState; //导入方法依赖的package包/类
static StateView computeState(Map<UUID, JobDefinition> jobs, Map<UUID, InstanceInfo> instances) {

    // Instance ID -> JobDefinition ID
    HashMap<UUID, UUID> instanceToJob = new HashMap<>();
    HashMap<UUID, List<InstanceInfo>> jobInstances = new HashMap<>();

    for (Map.Entry<UUID, InstanceInfo> e : instances.entrySet()) {
      YarnApplicationState state = YarnApplicationState.valueOf(e.getValue().status().getState().toString());
      if (!isInstanceAlive(state)) {
        continue;
      }
      UUID jobId = e.getValue().metadata().jobDefinition();
      UUID instanceId = e.getKey();
      instanceToJob.put(instanceId, jobId);
      if (!jobInstances.containsKey(jobId)) {
        jobInstances.put(jobId, new ArrayList<>());
      }
      jobInstances.get(jobId).add(e.getValue());
    }
    jobs.keySet().stream().filter(x -> !jobInstances.containsKey(x))
        .forEach(x -> jobInstances.put(x, Collections.emptyList()));
    return new StateView(jobs, instances, instanceToJob, jobInstances);
  }
 
开发者ID:uber,项目名称:AthenaX,代码行数:24,代码来源:JobWatcherUtil.java

示例2: validateStates

import org.apache.hadoop.yarn.api.records.YarnApplicationState; //导入方法依赖的package包/类
private static void
    validateStates(String stateQuery, Set<String> statesQuery) {
  // stateQuery is deprecated.
  if (stateQuery != null && !stateQuery.isEmpty()) {
    statesQuery.add(stateQuery);
  }
  Set<String> appStates = parseQueries(statesQuery, true);
  for (String appState : appStates) {
    switch (YarnApplicationState.valueOf(
        StringUtils.toUpperCase(appState))) {
      case FINISHED:
      case FAILED:
      case KILLED:
        continue;
      default:
        throw new BadRequestException("Invalid application-state " + appState
            + " specified. It should be a final state");
    }
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:21,代码来源:AHSWebServices.java

示例3: parseQueries

import org.apache.hadoop.yarn.api.records.YarnApplicationState; //导入方法依赖的package包/类
protected static Set<String>
    parseQueries(Set<String> queries, boolean isState) {
  Set<String> params = new HashSet<String>();
  if (!queries.isEmpty()) {
    for (String query : queries) {
      if (query != null && !query.trim().isEmpty()) {
        String[] paramStrs = query.split(",");
        for (String paramStr : paramStrs) {
          if (paramStr != null && !paramStr.trim().isEmpty()) {
            if (isState) {
              try {
                // enum string is in the uppercase
                YarnApplicationState.valueOf(
                    StringUtils.toUpperCase(paramStr.trim()));
              } catch (RuntimeException e) {
                YarnApplicationState[] stateArray =
                    YarnApplicationState.values();
                String allAppStates = Arrays.toString(stateArray);
                throw new BadRequestException("Invalid application-state "
                    + paramStr.trim() + " specified. It should be one of "
                    + allAppStates);
              }
            }
            params.add(StringUtils.toLowerCase(paramStr.trim()));
          }
        }
      }
    }
  }
  return params;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:32,代码来源:WebServices.java

示例4: parseQueries

import org.apache.hadoop.yarn.api.records.YarnApplicationState; //导入方法依赖的package包/类
private static Set<String> parseQueries(
    Set<String> queries, boolean isState) {
  Set<String> params = new HashSet<String>();
  if (!queries.isEmpty()) {
    for (String query : queries) {
      if (query != null && !query.trim().isEmpty()) {
        String[] paramStrs = query.split(",");
        for (String paramStr : paramStrs) {
          if (paramStr != null && !paramStr.trim().isEmpty()) {
            if (isState) {
              try {
                // enum string is in the uppercase
                YarnApplicationState.valueOf(
                    StringUtils.toUpperCase(paramStr.trim()));
              } catch (RuntimeException e) {
                YarnApplicationState[] stateArray =
                    YarnApplicationState.values();
                String allAppStates = Arrays.toString(stateArray);
                throw new BadRequestException(
                    "Invalid application-state " + paramStr.trim()
                    + " specified. It should be one of " + allAppStates);
              }
            }
            params.add(
                StringUtils.toLowerCase(paramStr.trim()));
          }
        }
      }
    }
  }
  return params;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:33,代码来源:RMWebServices.java

示例5: convertFromProtoFormat

import org.apache.hadoop.yarn.api.records.YarnApplicationState; //导入方法依赖的package包/类
public static YarnApplicationState convertFromProtoFormat(YarnApplicationStateProto e) {
  return YarnApplicationState.valueOf(e.name());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:4,代码来源:ProtoUtils.java

示例6: getApplications

import org.apache.hadoop.yarn.api.records.YarnApplicationState; //导入方法依赖的package包/类
public List<ApplicationReport> getApplications(int id) {
  String result = null;
  String squeueCmd = conf.get(
      HPCConfiguration.YARN_APPLICATION_HPC_COMMAND_SLURM_SQUEUE,
      HPCConfiguration.DEFAULT_YARN_APPLICATION_HPC_COMMAND_SLURM_SQUEUE);
  List<ApplicationReport> applications = new ArrayList<ApplicationReport>();
  try {
    String argJ = id < 0 ? "" : "-j " + id;
    result = Shell.execCommand(squeueCmd, "-h", argJ, "-o %i %P %j %u %k");

    String[] resultLines = result.split("\\n");
    for (String line : resultLines) {
      if (line == null || line.length() == 0) {
        return applications;
      }

      String[] lineParts = line.trim().split("\\s+");

      if (!("YarnMaster".equals(lineParts[2]) && StringUtils
          .isNotEmpty(lineParts[4])))
        continue;

      String[] addr = lineParts[4].split(":");
      if (addr.length != 3)
        continue;

      ApplicationReport appReport = Records
          .newRecord(ApplicationReport.class);

      int jobid = Integer.parseInt(lineParts[0]);
      ApplicationId applicationId = ApplicationId.newInstance(
          getClusterTimestamp(), jobid);

      appReport.setApplicationId(applicationId);
      appReport.setTrackingUrl("");
      appReport.setQueue(lineParts[1]);
      appReport.setName(lineParts[2]);
      appReport.setUser(lineParts[3]);

      appReport.setHost(addr[1]);
      appReport.setRpcPort(Integer.parseInt(addr[2]));

      String stateStr = addr[0].toUpperCase();
      YarnApplicationState state = YarnApplicationState.valueOf(stateStr);
      appReport.setYarnApplicationState(state);
      if (state == YarnApplicationState.FINISHED) {
        appReport.setFinalApplicationStatus(FinalApplicationStatus.SUCCEEDED);
      }else{
        appReport.setFinalApplicationStatus(FinalApplicationStatus.UNDEFINED);
      }
      applications.add(appReport);
    }
  } catch (Throwable t) {
    throw new YarnRuntimeException(result, t);
  }
  return applications;
}
 
开发者ID:intel-hpdd,项目名称:scheduling-connector-for-hadoop,代码行数:58,代码来源:SlurmApplicationClient.java


注:本文中的org.apache.hadoop.yarn.api.records.YarnApplicationState.valueOf方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。