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