Java Code Examples for org.apache.hadoop.yarn.api.records.ApplicationReport#newInstance()

The following examples show how to use org.apache.hadoop.yarn.api.records.ApplicationReport#newInstance() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractYarnClusterTest.java    From flink with Apache License 2.0 6 votes vote down vote up
private ApplicationReport createApplicationReport(
	ApplicationId applicationId,
	YarnApplicationState yarnApplicationState,
	FinalApplicationStatus finalApplicationStatus) {
	return ApplicationReport.newInstance(
		applicationId,
		ApplicationAttemptId.newInstance(applicationId, 0),
		"user",
		"queue",
		"name",
		"localhost",
		42,
		null,
		yarnApplicationState,
		null,
		null,
		1L,
		2L,
		finalApplicationStatus,
		null,
		null,
		1.0f,
		null,
		null);
}
 
Example 2
Source File: AbstractYarnClusterTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
private ApplicationReport createApplicationReport(
	ApplicationId applicationId,
	YarnApplicationState yarnApplicationState,
	FinalApplicationStatus finalApplicationStatus) {
	return ApplicationReport.newInstance(
		applicationId,
		ApplicationAttemptId.newInstance(applicationId, 0),
		"user",
		"queue",
		"name",
		"localhost",
		42,
		null,
		yarnApplicationState,
		null,
		null,
		1L,
		2L,
		finalApplicationStatus,
		null,
		null,
		1.0f,
		null,
		null);
}
 
Example 3
Source File: ApplicationHistoryManagerImpl.java    From hadoop with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example 4
Source File: ApplicationHistoryManagerImpl.java    From big-c with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example 5
Source File: NotRunningJob.java    From big-c with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 6
Source File: TestClientServiceDelegate.java    From big-c with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 7
Source File: ProtocolHATestBase.java    From big-c with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 8
Source File: TestRMWebApp.java    From big-c with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 9
Source File: TestApplicatonReport.java    From big-c with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 10
Source File: TestClientServiceDelegate.java    From big-c with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 11
Source File: TestClientServiceDelegate.java    From hadoop with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 12
Source File: ProtocolHATestBase.java    From hadoop with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 13
Source File: TestRMWebApp.java    From hadoop with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 14
Source File: NotRunningJob.java    From incubator-tez with Apache License 2.0 5 votes vote down vote up
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, "TEZ_MRR", null);
}
 
Example 15
Source File: TestYarnCLI.java    From big-c with Apache License 2.0 4 votes vote down vote up
@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());
  }
}
 
Example 16
Source File: TestYarnCLI.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@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());
  }
}
 
Example 17
Source File: TestYarnCLI.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@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);
  }
}
 
Example 18
Source File: TestYarnCLI.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@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));
  }
}
 
Example 19
Source File: TestAHSClient.java    From hadoop with Apache License 2.0 4 votes vote down vote up
private void createAppReports() {
  ApplicationId applicationId = ApplicationId.newInstance(1234, 5);
  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);
  List<ApplicationReport> applicationReports =
      new ArrayList<ApplicationReport>();
  applicationReports.add(newApplicationReport);
  List<ApplicationAttemptReport> appAttempts =
      new ArrayList<ApplicationAttemptReport>();
  ApplicationAttemptReport attempt =
      ApplicationAttemptReport.newInstance(
        ApplicationAttemptId.newInstance(applicationId, 1),
        "host",
        124,
        "url",
        "oUrl",
        "diagnostics",
        YarnApplicationAttemptState.FINISHED,
        ContainerId.newContainerId(
          newApplicationReport.getCurrentApplicationAttemptId(), 1));
  appAttempts.add(attempt);
  ApplicationAttemptReport attempt1 =
      ApplicationAttemptReport.newInstance(
        ApplicationAttemptId.newInstance(applicationId, 2),
        "host",
        124,
        "url",
        "oUrl",
        "diagnostics",
        YarnApplicationAttemptState.FINISHED,
        ContainerId.newContainerId(
          newApplicationReport.getCurrentApplicationAttemptId(), 2));
  appAttempts.add(attempt1);
  attempts.put(applicationId, appAttempts);

  List<ContainerReport> containerReports = new ArrayList<ContainerReport>();
  ContainerReport container =
      ContainerReport.newInstance(
        ContainerId.newContainerId(attempt.getApplicationAttemptId(), 1),
        null, NodeId.newInstance("host", 1234), Priority.UNDEFINED, 1234,
        5678, "diagnosticInfo", "logURL", 0, ContainerState.COMPLETE,
        "http://" + NodeId.newInstance("host", 2345).toString());
  containerReports.add(container);

  ContainerReport container1 =
      ContainerReport.newInstance(
        ContainerId.newContainerId(attempt.getApplicationAttemptId(), 2),
        null, NodeId.newInstance("host", 1234), Priority.UNDEFINED, 1234,
        5678, "diagnosticInfo", "logURL", 0, ContainerState.COMPLETE,
        "http://" + NodeId.newInstance("host", 2345).toString());
  containerReports.add(container1);
  containers.put(attempt.getApplicationAttemptId(), containerReports);

  ApplicationId applicationId2 = ApplicationId.newInstance(1234, 6);
  ApplicationReport newApplicationReport2 =
      ApplicationReport.newInstance(applicationId2,
        ApplicationAttemptId.newInstance(applicationId2, 2), "user2",
        "queue2", "appname2", "host2", 125, null,
        YarnApplicationState.FINISHED, "diagnostics2", "url2", 2, 2,
        FinalApplicationStatus.SUCCEEDED, null, "N/A", 0.63789f,
        "NON-YARN", null);
  applicationReports.add(newApplicationReport2);

  ApplicationId applicationId3 = ApplicationId.newInstance(1234, 7);
  ApplicationReport newApplicationReport3 =
      ApplicationReport.newInstance(applicationId3,
        ApplicationAttemptId.newInstance(applicationId3, 3), "user3",
        "queue3", "appname3", "host3", 126, null,
        YarnApplicationState.RUNNING, "diagnostics3", "url3", 3, 3,
        FinalApplicationStatus.SUCCEEDED, null, "N/A", 0.73789f,
        "MAPREDUCE", null);
  applicationReports.add(newApplicationReport3);

  ApplicationId applicationId4 = ApplicationId.newInstance(1234, 8);
  ApplicationReport newApplicationReport4 =
      ApplicationReport.newInstance(applicationId4,
        ApplicationAttemptId.newInstance(applicationId4, 4), "user4",
        "queue4", "appname4", "host4", 127, null,
        YarnApplicationState.FAILED, "diagnostics4", "url4", 4, 4,
        FinalApplicationStatus.SUCCEEDED, null, "N/A", 0.83789f,
        "NON-MAPREDUCE", null);
  applicationReports.add(newApplicationReport4);
  reports = applicationReports;
}
 
Example 20
Source File: TestAHSClient.java    From big-c with Apache License 2.0 4 votes vote down vote up
private void createAppReports() {
  ApplicationId applicationId = ApplicationId.newInstance(1234, 5);
  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);
  List<ApplicationReport> applicationReports =
      new ArrayList<ApplicationReport>();
  applicationReports.add(newApplicationReport);
  List<ApplicationAttemptReport> appAttempts =
      new ArrayList<ApplicationAttemptReport>();
  ApplicationAttemptReport attempt =
      ApplicationAttemptReport.newInstance(
        ApplicationAttemptId.newInstance(applicationId, 1),
        "host",
        124,
        "url",
        "oUrl",
        "diagnostics",
        YarnApplicationAttemptState.FINISHED,
        ContainerId.newContainerId(
          newApplicationReport.getCurrentApplicationAttemptId(), 1));
  appAttempts.add(attempt);
  ApplicationAttemptReport attempt1 =
      ApplicationAttemptReport.newInstance(
        ApplicationAttemptId.newInstance(applicationId, 2),
        "host",
        124,
        "url",
        "oUrl",
        "diagnostics",
        YarnApplicationAttemptState.FINISHED,
        ContainerId.newContainerId(
          newApplicationReport.getCurrentApplicationAttemptId(), 2));
  appAttempts.add(attempt1);
  attempts.put(applicationId, appAttempts);

  List<ContainerReport> containerReports = new ArrayList<ContainerReport>();
  ContainerReport container =
      ContainerReport.newInstance(
        ContainerId.newContainerId(attempt.getApplicationAttemptId(), 1),
        null, NodeId.newInstance("host", 1234), Priority.UNDEFINED, 1234,
        5678, "diagnosticInfo", "logURL", 0, ContainerState.COMPLETE,
        "http://" + NodeId.newInstance("host", 2345).toString());
  containerReports.add(container);

  ContainerReport container1 =
      ContainerReport.newInstance(
        ContainerId.newContainerId(attempt.getApplicationAttemptId(), 2),
        null, NodeId.newInstance("host", 1234), Priority.UNDEFINED, 1234,
        5678, "diagnosticInfo", "logURL", 0, ContainerState.COMPLETE,
        "http://" + NodeId.newInstance("host", 2345).toString());
  containerReports.add(container1);
  containers.put(attempt.getApplicationAttemptId(), containerReports);

  ApplicationId applicationId2 = ApplicationId.newInstance(1234, 6);
  ApplicationReport newApplicationReport2 =
      ApplicationReport.newInstance(applicationId2,
        ApplicationAttemptId.newInstance(applicationId2, 2), "user2",
        "queue2", "appname2", "host2", 125, null,
        YarnApplicationState.FINISHED, "diagnostics2", "url2", 2, 2,
        FinalApplicationStatus.SUCCEEDED, null, "N/A", 0.63789f,
        "NON-YARN", null);
  applicationReports.add(newApplicationReport2);

  ApplicationId applicationId3 = ApplicationId.newInstance(1234, 7);
  ApplicationReport newApplicationReport3 =
      ApplicationReport.newInstance(applicationId3,
        ApplicationAttemptId.newInstance(applicationId3, 3), "user3",
        "queue3", "appname3", "host3", 126, null,
        YarnApplicationState.RUNNING, "diagnostics3", "url3", 3, 3,
        FinalApplicationStatus.SUCCEEDED, null, "N/A", 0.73789f,
        "MAPREDUCE", null);
  applicationReports.add(newApplicationReport3);

  ApplicationId applicationId4 = ApplicationId.newInstance(1234, 8);
  ApplicationReport newApplicationReport4 =
      ApplicationReport.newInstance(applicationId4,
        ApplicationAttemptId.newInstance(applicationId4, 4), "user4",
        "queue4", "appname4", "host4", 127, null,
        YarnApplicationState.FAILED, "diagnostics4", "url4", 4, 4,
        FinalApplicationStatus.SUCCEEDED, null, "N/A", 0.83789f,
        "NON-MAPREDUCE", null);
  applicationReports.add(newApplicationReport4);
  reports = applicationReports;
}