當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。