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


Java YarnApplicationState类代码示例

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


YarnApplicationState类属于org.apache.hadoop.yarn.api.records包,在下文中一共展示了YarnApplicationState类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: awaitApplication

import org.apache.hadoop.yarn.api.records.YarnApplicationState; //导入依赖的package包/类
boolean awaitApplication(ApplicationId appId) throws Exception {
  Set<YarnApplicationState> terminated = Sets.newHashSet(
      YarnApplicationState.FAILED,
      YarnApplicationState.FINISHED,
      YarnApplicationState.KILLED);
  while (true) {
    ApplicationReport report = yarnClient.getApplicationReport(appId);
    YarnApplicationState state = report.getYarnApplicationState();
    if (state.equals(YarnApplicationState.RUNNING)) {
      ClusterSpec clusterSpec = Client.getClusterSpec(yarnClient, appId);
      if (isClusterSpecSatisfied(clusterSpec)) {
        System.out.println("ClusterSpec: " + Utils.toJsonString(clusterSpec.getCluster()));
        return true;
      }
    } else if (terminated.contains(state)) {
      return false;
    } else {
      Thread.sleep(1000);
    }
  }
}
 
开发者ID:Intel-bigdata,项目名称:TensorFlowOnYARN,代码行数:22,代码来源:LaunchCluster.java

示例3: clarifyAppState

import org.apache.hadoop.yarn.api.records.YarnApplicationState; //导入依赖的package包/类
private String clarifyAppState(YarnApplicationState state) {
  String ret = state.toString();
  switch (state) {
  case NEW:
    return ret + ": waiting for application to be initialized";
  case NEW_SAVING:
    return ret + ": waiting for application to be persisted in state-store.";
  case SUBMITTED:
    return ret + ": waiting for application to be accepted by scheduler.";
  case ACCEPTED:
    return ret + ": waiting for AM container to be allocated, launched and"
        + " register with RM.";
  case RUNNING:
    return ret + ": AM has registered with RM and started running.";
  default:
    return ret;
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:19,代码来源:AppBlock.java

示例4: buildScoreboard

import org.apache.hadoop.yarn.api.records.YarnApplicationState; //导入依赖的package包/类
private static Map<YarnApplicationState, Map<String, Long>> buildScoreboard(
   Set<String> states, Set<String> types) {
  Map<YarnApplicationState, Map<String, Long>> scoreboard
      = new HashMap<YarnApplicationState, Map<String, Long>>();
  // default states will result in enumerating all YarnApplicationStates
  assert !states.isEmpty();
  for (String state : states) {
    Map<String, Long> partScoreboard = new HashMap<String, Long>();
    scoreboard.put(
        YarnApplicationState.valueOf(StringUtils.toUpperCase(state)),
        partScoreboard);
    // types is verified no to be empty
    for (String type : types) {
      partScoreboard.put(type, 0L);
    }
  }
  return scoreboard;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:19,代码来源:RMWebServices.java

示例5: render

import org.apache.hadoop.yarn.api.records.YarnApplicationState; //导入依赖的package包/类
@Override public void render(Block html) {
  UL<DIV<Hamlet>> mainList = html.
    div("#nav").
      h3("Cluster").
      ul().
        li().a(url("cluster"), "About")._().
        li().a(url("nodes"), "Nodes")._().
        li().a(url("nodelabels"), "Node Labels")._();
  UL<LI<UL<DIV<Hamlet>>>> subAppsList = mainList.
        li().a(url("apps"), "Applications").
          ul();
  subAppsList.li()._();
  for (YarnApplicationState state : YarnApplicationState.values()) {
    subAppsList.
            li().a(url("apps", state.toString()), state.toString())._();
  }
  subAppsList._()._();
  mainList.
        li().a(url("scheduler"), "Scheduler")._()._().
      h3("Tools").
      ul().
        li().a("/conf", "Configuration")._().
        li().a("/logs", "Local logs")._().
        li().a("/stacks", "Server stacks")._().
        li().a("/jmx?qry=Hadoop:*", "Server metrics")._()._()._();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:27,代码来源:NavBlock.java

示例6: ApplicationFinishedEvent

import org.apache.hadoop.yarn.api.records.YarnApplicationState; //导入依赖的package包/类
public ApplicationFinishedEvent(
    ApplicationId appId,
    String diagnosticsInfo,
    FinalApplicationStatus appStatus,
    YarnApplicationState state,
    ApplicationAttemptId latestAppAttemptId,
    long finishedTime,
    RMAppMetrics appMetrics) {
  super(SystemMetricsEventType.APP_FINISHED, finishedTime);
  this.appId = appId;
  this.diagnosticsInfo = diagnosticsInfo;
  this.appStatus = appStatus;
  this.latestAppAttemptId = latestAppAttemptId;
  this.state = state;
  this.appMetrics=appMetrics;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:17,代码来源:ApplicationFinishedEvent.java

示例7: createApplicationState

import org.apache.hadoop.yarn.api.records.YarnApplicationState; //导入依赖的package包/类
public static YarnApplicationState createApplicationState(
    RMAppState rmAppState) {
  switch (rmAppState) {
    case NEW:
      return YarnApplicationState.NEW;
    case NEW_SAVING:
      return YarnApplicationState.NEW_SAVING;
    case SUBMITTED:
      return YarnApplicationState.SUBMITTED;
    case ACCEPTED:
      return YarnApplicationState.ACCEPTED;
    case RUNNING:
      return YarnApplicationState.RUNNING;
    case FINISHING:
    case FINISHED:
      return YarnApplicationState.FINISHED;
    case KILLED:
      return YarnApplicationState.KILLED;
    case FAILED:
      return YarnApplicationState.FAILED;
    default:
      throw new YarnRuntimeException("Unknown state passed!");
    }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:25,代码来源:RMServerUtils.java

示例8: testAppsQueryState

import org.apache.hadoop.yarn.api.records.YarnApplicationState; //导入依赖的package包/类
@Test
public void testAppsQueryState() throws JSONException, Exception {
  rm.start();
  MockNM amNodeManager = rm.registerNode("127.0.0.1:1234", 2048);
  RMApp app1 = rm.submitApp(CONTAINER_MB);
  amNodeManager.nodeHeartbeat(true);
  WebResource r = resource();

  ClientResponse response = r.path("ws").path("v1").path("cluster")
      .path("apps")
      .queryParam("state", YarnApplicationState.ACCEPTED.toString())
      .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
  assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
  JSONObject json = response.getEntity(JSONObject.class);
  assertEquals("incorrect number of elements", 1, json.length());
  JSONObject apps = json.getJSONObject("apps");
  assertEquals("incorrect number of elements", 1, apps.length());
  JSONArray array = apps.getJSONArray("app");
  assertEquals("incorrect number of elements", 1, array.length());
  verifyAppInfo(array.getJSONObject(0), app1);
  rm.stop();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:23,代码来源:TestRMWebServicesApps.java

示例9: testAppsQueryStatesNone

import org.apache.hadoop.yarn.api.records.YarnApplicationState; //导入依赖的package包/类
@Test
public void testAppsQueryStatesNone() throws JSONException, Exception {
  rm.start();
  MockNM amNodeManager = rm.registerNode("127.0.0.1:1234", 2048);
  rm.submitApp(CONTAINER_MB);
  amNodeManager.nodeHeartbeat(true);
  WebResource r = resource();

  ClientResponse response = r.path("ws").path("v1").path("cluster")
      .path("apps")
      .queryParam("states", YarnApplicationState.RUNNING.toString())
      .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
  assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
  JSONObject json = response.getEntity(JSONObject.class);
  assertEquals("incorrect number of elements", 1, json.length());
  assertEquals("apps is not null", JSONObject.NULL, json.get("apps"));
  rm.stop();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:19,代码来源:TestRMWebServicesApps.java

示例10: testAppsQueryStateNone

import org.apache.hadoop.yarn.api.records.YarnApplicationState; //导入依赖的package包/类
@Test
public void testAppsQueryStateNone() throws JSONException, Exception {
  rm.start();
  MockNM amNodeManager = rm.registerNode("127.0.0.1:1234", 2048);
  rm.submitApp(CONTAINER_MB);
  amNodeManager.nodeHeartbeat(true);
  WebResource r = resource();

  ClientResponse response = r.path("ws").path("v1").path("cluster")
      .path("apps")
      .queryParam("state", YarnApplicationState.RUNNING.toString())
      .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
  assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
  JSONObject json = response.getEntity(JSONObject.class);
  assertEquals("incorrect number of elements", 1, json.length());
  assertEquals("apps is not null", JSONObject.NULL, json.get("apps"));
  rm.stop();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:19,代码来源:TestRMWebServicesApps.java

示例11: getApplicationReport

import org.apache.hadoop.yarn.api.records.YarnApplicationState; //导入依赖的package包/类
@Override
public ApplicationReport getApplicationReport(ApplicationId applicationId)
    throws IOException {
  List<ApplicationReport> reports = null;
  try {
    reports = getApplications(applicationId.getId());
  } catch (Throwable e) {
    LOG.info("Couldn't get application report for " + applicationId
        + ", might be completed already.");
  }
  if (reports == null || reports.isEmpty()) {
    return ApplicationReport.newInstance(applicationId, null, "", "default",
        "", "", 0, null, YarnApplicationState.FINISHED, "", "", 0, 0,
        FinalApplicationStatus.SUCCEEDED, null, "", 100, null, null);
  }
  return reports.get(0);
}
 
开发者ID:intel-hpdd,项目名称:scheduling-connector-for-hadoop,代码行数:18,代码来源:SlurmApplicationClient.java

示例12: 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

示例13: testJobSubmissionFailure

import org.apache.hadoop.yarn.api.records.YarnApplicationState; //导入依赖的package包/类
@Test(timeout=20000)
public void testJobSubmissionFailure() throws Exception {
  when(resourceMgrDelegate.submitApplication(any(ApplicationSubmissionContext.class))).
  thenReturn(appId);
  ApplicationReport report = mock(ApplicationReport.class);
  when(report.getApplicationId()).thenReturn(appId);
  when(report.getDiagnostics()).thenReturn(failString);
  when(report.getYarnApplicationState()).thenReturn(YarnApplicationState.FAILED);
  when(resourceMgrDelegate.getApplicationReport(appId)).thenReturn(report);
  Credentials credentials = new Credentials();
  File jobxml = new File(testWorkDir, "job.xml");
  OutputStream out = new FileOutputStream(jobxml);
  conf.writeXml(out);
  out.close();
  try {
    yarnRunner.submitJob(jobId, testWorkDir.getAbsolutePath().toString(), credentials);
  } catch(IOException io) {
    LOG.info("Logging exception:", io);
    assertTrue(io.getLocalizedMessage().contains(failString));
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:22,代码来源:TestYARNRunner.java

示例14: tesAllJobs

import org.apache.hadoop.yarn.api.records.YarnApplicationState; //导入依赖的package包/类
@Test
public void tesAllJobs() throws Exception {
  final ApplicationClientProtocol applicationsManager = Mockito.mock(ApplicationClientProtocol.class);
  GetApplicationsResponse allApplicationsResponse = Records
      .newRecord(GetApplicationsResponse.class);
  List<ApplicationReport> applications = new ArrayList<ApplicationReport>();
  applications.add(getApplicationReport(YarnApplicationState.FINISHED,
      FinalApplicationStatus.FAILED));
  applications.add(getApplicationReport(YarnApplicationState.FINISHED,
      FinalApplicationStatus.SUCCEEDED));
  applications.add(getApplicationReport(YarnApplicationState.FINISHED,
      FinalApplicationStatus.KILLED));
  applications.add(getApplicationReport(YarnApplicationState.FAILED,
      FinalApplicationStatus.FAILED));
  allApplicationsResponse.setApplicationList(applications);
  Mockito.when(
      applicationsManager.getApplications(Mockito
          .any(GetApplicationsRequest.class))).thenReturn(
      allApplicationsResponse);
  ResourceMgrDelegate resourceMgrDelegate = new ResourceMgrDelegate(
    new YarnConfiguration()) {
    @Override
    protected void serviceStart() throws Exception {
      Assert.assertTrue(this.client instanceof YarnClientImpl);
      ((YarnClientImpl) this.client).setRMClient(applicationsManager);
    }
  };
  JobStatus[] allJobs = resourceMgrDelegate.getAllJobs();

  Assert.assertEquals(State.FAILED, allJobs[0].getState());
  Assert.assertEquals(State.SUCCEEDED, allJobs[1].getState());
  Assert.assertEquals(State.KILLED, allJobs[2].getState());
  Assert.assertEquals(State.FAILED, allJobs[3].getState());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:35,代码来源:TestResourceMgrDelegate.java

示例15: testView

import org.apache.hadoop.yarn.api.records.YarnApplicationState; //导入依赖的package包/类
@Test
public void testView() throws Exception {
  Injector injector =
      WebAppTests.createMockInjector(ApplicationBaseProtocol.class,
        mockApplicationHistoryClientService(5, 1, 1));
  AHSView ahsViewInstance = injector.getInstance(AHSView.class);

  ahsViewInstance.render();
  WebAppTests.flushOutput(injector);

  ahsViewInstance.set(YarnWebParams.APP_STATE,
    YarnApplicationState.FAILED.toString());
  ahsViewInstance.render();
  WebAppTests.flushOutput(injector);

  ahsViewInstance.set(YarnWebParams.APP_STATE, StringHelper.cjoin(
    YarnApplicationState.FAILED.toString(), YarnApplicationState.KILLED));
  ahsViewInstance.render();
  WebAppTests.flushOutput(injector);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:21,代码来源:TestAHSWebApp.java


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