當前位置: 首頁>>代碼示例>>Java>>正文


Java ApplicationReport.newInstance方法代碼示例

本文整理匯總了Java中org.apache.hadoop.yarn.api.records.ApplicationReport.newInstance方法的典型用法代碼示例。如果您正苦於以下問題:Java ApplicationReport.newInstance方法的具體用法?Java ApplicationReport.newInstance怎麽用?Java ApplicationReport.newInstance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.hadoop.yarn.api.records.ApplicationReport的用法示例。


在下文中一共展示了ApplicationReport.newInstance方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: convertToApplicationReport

import org.apache.hadoop.yarn.api.records.ApplicationReport; //導入方法依賴的package包/類
private ApplicationReport convertToApplicationReport(
    ApplicationHistoryData appHistory) throws IOException {
  ApplicationAttemptId currentApplicationAttemptId = null;
  String trackingUrl = UNAVAILABLE;
  String host = UNAVAILABLE;
  int rpcPort = -1;

  ApplicationAttemptHistoryData lastAttempt =
      getLastAttempt(appHistory.getApplicationId());
  if (lastAttempt != null) {
    currentApplicationAttemptId = lastAttempt.getApplicationAttemptId();
    trackingUrl = lastAttempt.getTrackingURL();
    host = lastAttempt.getHost();
    rpcPort = lastAttempt.getRPCPort();
  }
  return ApplicationReport.newInstance(appHistory.getApplicationId(),
    currentApplicationAttemptId, appHistory.getUser(), appHistory.getQueue(),
    appHistory.getApplicationName(), host, rpcPort, null,
    appHistory.getYarnApplicationState(), appHistory.getDiagnosticsInfo(),
    trackingUrl, appHistory.getStartTime(), appHistory.getFinishTime(),
    appHistory.getFinalApplicationStatus(), null, "", 100,
    appHistory.getApplicationType(), null);
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:24,代碼來源:ApplicationHistoryManagerImpl.java

示例2: getApplicationReport

import org.apache.hadoop.yarn.api.records.ApplicationReport; //導入方法依賴的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

示例3: createApplicationReport

import org.apache.hadoop.yarn.api.records.ApplicationReport; //導入方法依賴的package包/類
protected static ApplicationReport createApplicationReport(
    int appIdInt, int appAttemptIdInt, long timestamp) {
  ApplicationId appId = ApplicationId.newInstance(timestamp, appIdInt);
  ApplicationAttemptId appAttemptId =
      ApplicationAttemptId.newInstance(appId, appAttemptIdInt);
  ApplicationReport appReport =
      ApplicationReport.newInstance(appId, appAttemptId, "user", "queue",
        "appname", "host", 124, null, YarnApplicationState.FINISHED,
        "diagnostics", "url", 0, 0, FinalApplicationStatus.SUCCEEDED, null,
        "N/A", 0.53789f, YarnConfiguration.DEFAULT_APPLICATION_TYPE, null);
  return appReport;
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:13,代碼來源:TestApplicatonReport.java

示例4: mockClientRMService

import org.apache.hadoop.yarn.api.records.ApplicationReport; //導入方法依賴的package包/類
public static ClientRMService mockClientRMService(RMContext rmContext) {
  ClientRMService clientRMService = mock(ClientRMService.class);
  List<ApplicationReport> appReports = new ArrayList<ApplicationReport>();
  for (RMApp app : rmContext.getRMApps().values()) {
    ApplicationReport appReport =
        ApplicationReport.newInstance(
            app.getApplicationId(), (ApplicationAttemptId) null,
            app.getUser(), app.getQueue(),
            app.getName(), (String) null, 0, (Token) null,
            app.createApplicationState(),
            app.getDiagnostics().toString(), (String) null,
            app.getStartTime(), app.getFinishTime(),
            app.getFinalApplicationStatus(),
            (ApplicationResourceUsageReport) null, app.getTrackingUrl(),
            app.getProgress(), app.getApplicationType(), (Token) null);
    appReports.add(appReport);
  }
  GetApplicationsResponse response = mock(GetApplicationsResponse.class);
  when(response.getApplicationList()).thenReturn(appReports);
  try {
    when(clientRMService.getApplications(any(GetApplicationsRequest.class)))
        .thenReturn(response);
  } catch (YarnException e) {
    Assert.fail("Exception is not expteced.");
  }
  return clientRMService;
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:28,代碼來源:TestRMWebApp.java

示例5: createFakeAppReport

import org.apache.hadoop.yarn.api.records.ApplicationReport; //導入方法依賴的package包/類
public ApplicationReport createFakeAppReport() {
  ApplicationId appId = ApplicationId.newInstance(1000l, 1);
  ApplicationAttemptId attemptId =
      ApplicationAttemptId.newInstance(appId, 1);
  // create a fake application report
  ApplicationReport report =
      ApplicationReport.newInstance(appId, attemptId, "fakeUser",
          "fakeQueue", "fakeApplicationName", "localhost", 0, null,
          YarnApplicationState.FINISHED, "fake an application report", "",
          1000l, 1200l, FinalApplicationStatus.FAILED, null, "", 50f,
          "fakeApplicationType", null);
  return report;
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:14,代碼來源:ProtocolHATestBase.java

示例6: getUnknownApplicationReport

import org.apache.hadoop.yarn.api.records.ApplicationReport; //導入方法依賴的package包/類
private ApplicationReport getUnknownApplicationReport() {
  ApplicationId unknownAppId = recordFactory
      .newRecordInstance(ApplicationId.class);
  ApplicationAttemptId unknownAttemptId = recordFactory
      .newRecordInstance(ApplicationAttemptId.class);

  // Setting AppState to NEW and finalStatus to UNDEFINED as they are never
  // used for a non running job
  return ApplicationReport.newInstance(unknownAppId, unknownAttemptId,
    "N/A", "N/A", "N/A", "N/A", 0, null, YarnApplicationState.NEW, "N/A",
    "N/A", 0, 0, FinalApplicationStatus.UNDEFINED, null, "N/A", 0.0f,
    YarnConfiguration.DEFAULT_APPLICATION_TYPE, null);
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:14,代碼來源:NotRunningJob.java

示例7: getFinishedApplicationReport

import org.apache.hadoop.yarn.api.records.ApplicationReport; //導入方法依賴的package包/類
private ApplicationReport getFinishedApplicationReport() {
  ApplicationId appId = ApplicationId.newInstance(1234, 5);
  ApplicationAttemptId attemptId = ApplicationAttemptId.newInstance(
      appId, 0);
  return ApplicationReport.newInstance(appId, attemptId, "user", "queue",
    "appname", "host", 124, null, YarnApplicationState.FINISHED,
    "diagnostics", "url", 0, 0, FinalApplicationStatus.SUCCEEDED, null,
    "N/A", 0.0f, YarnConfiguration.DEFAULT_APPLICATION_TYPE, null);
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:10,代碼來源:TestClientServiceDelegate.java

示例8: getRunningApplicationReport

import org.apache.hadoop.yarn.api.records.ApplicationReport; //導入方法依賴的package包/類
private ApplicationReport getRunningApplicationReport(String host, int port) {
  ApplicationId appId = ApplicationId.newInstance(1234, 5);
  ApplicationAttemptId attemptId = ApplicationAttemptId.newInstance(
      appId, 0);
  return ApplicationReport.newInstance(appId, attemptId, "user", "queue",
    "appname", host, port, null, YarnApplicationState.RUNNING, "diagnostics",
    "url", 0, 0, FinalApplicationStatus.UNDEFINED, null, "N/A", 0.0f,
    YarnConfiguration.DEFAULT_APPLICATION_TYPE, null);
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:10,代碼來源:TestClientServiceDelegate.java

示例9: testGetApplicationReport

import org.apache.hadoop.yarn.api.records.ApplicationReport; //導入方法依賴的package包/類
@Test
public void testGetApplicationReport() throws Exception {
  for (int i = 0; i < 2; ++i) {
    ApplicationCLI cli = createAndGetAppCLI();
    ApplicationId applicationId = ApplicationId.newInstance(1234, 5);
    ApplicationResourceUsageReport usageReport = i == 0 ? null :
        ApplicationResourceUsageReport.newInstance(
            2, 0, null, null, null, 123456, 4567, 4567);
    ApplicationReport newApplicationReport = ApplicationReport.newInstance(
        applicationId, ApplicationAttemptId.newInstance(applicationId, 1),
        "user", "queue", "appname", "host", 124, null,
        YarnApplicationState.FINISHED, "diagnostics", "url", 0, 0,
        FinalApplicationStatus.SUCCEEDED, usageReport, "N/A", 0.53789f, "YARN",
        null);
    when(client.getApplicationReport(any(ApplicationId.class))).thenReturn(
        newApplicationReport);
    int result = cli.run(new String[] { "application", "-status", applicationId.toString() });
    assertEquals(0, result);
    verify(client, times(1 + i)).getApplicationReport(applicationId);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    PrintWriter pw = new PrintWriter(baos);
    pw.println("Application Report : ");
    pw.println("\tApplication-Id : application_1234_0005");
    pw.println("\tApplication-Name : appname");
    pw.println("\tApplication-Type : YARN");
    pw.println("\tUser : user");
    pw.println("\tQueue : queue");
    pw.println("\tStart-Time : 0");
    pw.println("\tFinish-Time : 0");
    pw.println("\tProgress : 53.79%");
    pw.println("\tState : FINISHED");
    pw.println("\tFinal-State : SUCCEEDED");
    pw.println("\tTracking-URL : N/A");
    pw.println("\tRPC Port : 124");
    pw.println("\tAM Host : host");
    pw.println("\tAggregate Resource Allocation : " +
        (i == 0 ? "N/A" : "123456 MB-seconds, 4567 vcore-seconds, 4567 gcore-seconds"));
    pw.println("\tDiagnostics : diagnostics");
    pw.close();
    String appReportStr = baos.toString("UTF-8");
    Assert.assertEquals(appReportStr, sysOutStream.toString());
    sysOutStream.reset();
    verify(sysOut, times(1 + i)).println(isA(String.class));
  }
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:46,代碼來源:TestYarnCLI.java

示例10: testKillApplication

import org.apache.hadoop.yarn.api.records.ApplicationReport; //導入方法依賴的package包/類
@Test
public void testKillApplication() throws Exception {
  ApplicationCLI cli = createAndGetAppCLI();
  ApplicationId applicationId = ApplicationId.newInstance(1234, 5);

  ApplicationReport newApplicationReport2 = ApplicationReport.newInstance(
      applicationId, ApplicationAttemptId.newInstance(applicationId, 1),
      "user", "queue", "appname", "host", 124, null,
      YarnApplicationState.FINISHED, "diagnostics", "url", 0, 0,
      FinalApplicationStatus.SUCCEEDED, null, "N/A", 0.53789f, "YARN", null);
  when(client.getApplicationReport(any(ApplicationId.class))).thenReturn(
      newApplicationReport2);
  int result = cli.run(new String[] { "application","-kill", applicationId.toString() });
  assertEquals(0, result);
  verify(client, times(0)).killApplication(any(ApplicationId.class));
  verify(sysOut).println(
      "Application " + applicationId + " has already finished ");

  ApplicationReport newApplicationReport = ApplicationReport.newInstance(
      applicationId, ApplicationAttemptId.newInstance(applicationId, 1),
      "user", "queue", "appname", "host", 124, null,
      YarnApplicationState.RUNNING, "diagnostics", "url", 0, 0,
      FinalApplicationStatus.SUCCEEDED, null, "N/A", 0.53789f, "YARN", null);
  when(client.getApplicationReport(any(ApplicationId.class))).thenReturn(
      newApplicationReport);
  result = cli.run(new String[] { "application","-kill", applicationId.toString() });
  assertEquals(0, result);
  verify(client).killApplication(any(ApplicationId.class));
  verify(sysOut).println("Killing application application_1234_0005");

  doThrow(new ApplicationNotFoundException("Application with id '"
      + applicationId + "' doesn't exist in RM.")).when(client)
      .getApplicationReport(applicationId);
  cli = createAndGetAppCLI();
  try {
    int exitCode =
        cli.run(new String[] { "application","-kill", applicationId.toString() });
    verify(sysOut).println("Application with id '" + applicationId +
            "' doesn't exist in RM.");
    Assert.assertNotSame("should return non-zero exit code.", 0, exitCode);
  } catch (ApplicationNotFoundException appEx) {
    Assert.fail("application -kill should not throw" +
        "ApplicationNotFoundException. " + appEx);
  } catch (Exception e) {
    Assert.fail("Unexpected exception: " + e);
  }
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:48,代碼來源:TestYarnCLI.java

示例11: testMoveApplicationAcrossQueues

import org.apache.hadoop.yarn.api.records.ApplicationReport; //導入方法依賴的package包/類
@Test
public void testMoveApplicationAcrossQueues() throws Exception {
  ApplicationCLI cli = createAndGetAppCLI();
  ApplicationId applicationId = ApplicationId.newInstance(1234, 5);

  ApplicationReport newApplicationReport2 = ApplicationReport.newInstance(
      applicationId, ApplicationAttemptId.newInstance(applicationId, 1),
      "user", "queue", "appname", "host", 124, null,
      YarnApplicationState.FINISHED, "diagnostics", "url", 0, 0,
      FinalApplicationStatus.SUCCEEDED, null, "N/A", 0.53789f, "YARN", null);
  when(client.getApplicationReport(any(ApplicationId.class))).thenReturn(
      newApplicationReport2);
  int result = cli.run(new String[] { "application", "-movetoqueue",
      applicationId.toString(), "-queue", "targetqueue"});
  assertEquals(0, result);
  verify(client, times(0)).moveApplicationAcrossQueues(
      any(ApplicationId.class), any(String.class));
  verify(sysOut).println(
      "Application " + applicationId + " has already finished ");

  ApplicationReport newApplicationReport = ApplicationReport.newInstance(
      applicationId, ApplicationAttemptId.newInstance(applicationId, 1),
      "user", "queue", "appname", "host", 124, null,
      YarnApplicationState.RUNNING, "diagnostics", "url", 0, 0,
      FinalApplicationStatus.SUCCEEDED, null, "N/A", 0.53789f, "YARN", null);
  when(client.getApplicationReport(any(ApplicationId.class))).thenReturn(
      newApplicationReport);
  result = cli.run(new String[] { "application", "-movetoqueue",
      applicationId.toString(), "-queue", "targetqueue"});
  assertEquals(0, result);
  verify(client).moveApplicationAcrossQueues(any(ApplicationId.class),
      any(String.class));
  verify(sysOut).println("Moving application application_1234_0005 to queue targetqueue");
  verify(sysOut).println("Successfully completed move.");

  doThrow(new ApplicationNotFoundException("Application with id '"
      + applicationId + "' doesn't exist in RM.")).when(client)
      .moveApplicationAcrossQueues(applicationId, "targetqueue");
  cli = createAndGetAppCLI();
  try {
    result = cli.run(new String[] { "application", "-movetoqueue",
        applicationId.toString(), "-queue", "targetqueue"});
    Assert.fail();
  } catch (Exception ex) {
    Assert.assertTrue(ex instanceof ApplicationNotFoundException);
    Assert.assertEquals("Application with id '" + applicationId +
        "' doesn't exist in RM.", ex.getMessage());
  }
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:50,代碼來源:TestYarnCLI.java


注:本文中的org.apache.hadoop.yarn.api.records.ApplicationReport.newInstance方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。