Java Code Examples for org.apache.hadoop.yarn.api.records.ApplicationAttemptReport#newInstance()
The following examples show how to use
org.apache.hadoop.yarn.api.records.ApplicationAttemptReport#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: RMAppAttemptImpl.java From hadoop with Apache License 2.0 | 6 votes |
@Override public ApplicationAttemptReport createApplicationAttemptReport() { this.readLock.lock(); ApplicationAttemptReport attemptReport = null; try { // AM container maybe not yet allocated. and also unmangedAM doesn't have // am container. ContainerId amId = masterContainer == null ? null : masterContainer.getId(); attemptReport = ApplicationAttemptReport.newInstance(this .getAppAttemptId(), this.getHost(), this.getRpcPort(), this .getTrackingUrl(), this.getOriginalTrackingUrl(), this.getDiagnostics(), YarnApplicationAttemptState .valueOf(this.getState().toString()), amId); } finally { this.readLock.unlock(); } return attemptReport; }
Example 2
Source File: RMAppAttemptImpl.java From big-c with Apache License 2.0 | 6 votes |
@Override public ApplicationAttemptReport createApplicationAttemptReport() { this.readLock.lock(); ApplicationAttemptReport attemptReport = null; try { // AM container maybe not yet allocated. and also unmangedAM doesn't have // am container. ContainerId amId = masterContainer == null ? null : masterContainer.getId(); attemptReport = ApplicationAttemptReport.newInstance(this .getAppAttemptId(), this.getHost(), this.getRpcPort(), this .getTrackingUrl(), this.getOriginalTrackingUrl(), this.getDiagnostics(), YarnApplicationAttemptState .valueOf(this.getState().toString()), amId); } finally { this.readLock.unlock(); } return attemptReport; }
Example 3
Source File: ApplicationHistoryManagerImpl.java From hadoop with Apache License 2.0 | 5 votes |
private ApplicationAttemptReport convertToApplicationAttemptReport( ApplicationAttemptHistoryData appAttemptHistory) { return ApplicationAttemptReport.newInstance( appAttemptHistory.getApplicationAttemptId(), appAttemptHistory.getHost(), appAttemptHistory.getRPCPort(), appAttemptHistory.getTrackingURL(), null, appAttemptHistory.getDiagnosticsInfo(), appAttemptHistory.getYarnApplicationAttemptState(), appAttemptHistory.getMasterContainerId()); }
Example 4
Source File: TestYarnCLI.java From hadoop with Apache License 2.0 | 5 votes |
@Test public void testGetApplicationAttemptReport() throws Exception { ApplicationCLI cli = createAndGetAppCLI(); ApplicationId applicationId = ApplicationId.newInstance(1234, 5); ApplicationAttemptId attemptId = ApplicationAttemptId.newInstance( applicationId, 1); ApplicationAttemptReport attemptReport = ApplicationAttemptReport .newInstance(attemptId, "host", 124, "url", "oUrl", "diagnostics", YarnApplicationAttemptState.FINISHED, ContainerId.newContainerId( attemptId, 1)); when( client .getApplicationAttemptReport(any(ApplicationAttemptId.class))) .thenReturn(attemptReport); int result = cli.run(new String[] { "applicationattempt", "-status", attemptId.toString() }); assertEquals(0, result); verify(client).getApplicationAttemptReport(attemptId); ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintWriter pw = new PrintWriter(baos); pw.println("Application Attempt Report : "); pw.println("\tApplicationAttempt-Id : appattempt_1234_0005_000001"); pw.println("\tState : FINISHED"); pw.println("\tAMContainer : container_1234_0005_01_000001"); pw.println("\tTracking-URL : url"); pw.println("\tRPC Port : 124"); pw.println("\tAM Host : host"); pw.println("\tDiagnostics : diagnostics"); pw.close(); String appReportStr = baos.toString("UTF-8"); Assert.assertEquals(appReportStr, sysOutStream.toString()); verify(sysOut, times(1)).println(isA(String.class)); }
Example 5
Source File: ApplicationHistoryManagerImpl.java From big-c with Apache License 2.0 | 5 votes |
private ApplicationAttemptReport convertToApplicationAttemptReport( ApplicationAttemptHistoryData appAttemptHistory) { return ApplicationAttemptReport.newInstance( appAttemptHistory.getApplicationAttemptId(), appAttemptHistory.getHost(), appAttemptHistory.getRPCPort(), appAttemptHistory.getTrackingURL(), null, appAttemptHistory.getDiagnosticsInfo(), appAttemptHistory.getYarnApplicationAttemptState(), appAttemptHistory.getMasterContainerId()); }
Example 6
Source File: TestYarnCLI.java From big-c with Apache License 2.0 | 5 votes |
@Test public void testGetApplicationAttemptReport() throws Exception { ApplicationCLI cli = createAndGetAppCLI(); ApplicationId applicationId = ApplicationId.newInstance(1234, 5); ApplicationAttemptId attemptId = ApplicationAttemptId.newInstance( applicationId, 1); ApplicationAttemptReport attemptReport = ApplicationAttemptReport .newInstance(attemptId, "host", 124, "url", "oUrl", "diagnostics", YarnApplicationAttemptState.FINISHED, ContainerId.newContainerId( attemptId, 1)); when( client .getApplicationAttemptReport(any(ApplicationAttemptId.class))) .thenReturn(attemptReport); int result = cli.run(new String[] { "applicationattempt", "-status", attemptId.toString() }); assertEquals(0, result); verify(client).getApplicationAttemptReport(attemptId); ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintWriter pw = new PrintWriter(baos); pw.println("Application Attempt Report : "); pw.println("\tApplicationAttempt-Id : appattempt_1234_0005_000001"); pw.println("\tState : FINISHED"); pw.println("\tAMContainer : container_1234_0005_01_000001"); pw.println("\tTracking-URL : url"); pw.println("\tRPC Port : 124"); pw.println("\tAM Host : host"); pw.println("\tDiagnostics : diagnostics"); pw.close(); String appReportStr = baos.toString("UTF-8"); Assert.assertEquals(appReportStr, sysOutStream.toString()); verify(sysOut, times(1)).println(isA(String.class)); }
Example 7
Source File: ProtocolHATestBase.java From hadoop with Apache License 2.0 | 4 votes |
public ApplicationAttemptReport createFakeApplicationAttemptReport() { return ApplicationAttemptReport.newInstance( createFakeApplicationAttemptId(), "localhost", 0, "", "", "", YarnApplicationAttemptState.RUNNING, createFakeContainerId()); }
Example 8
Source File: TestAHSClient.java From hadoop with Apache License 2.0 | 4 votes |
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 9
Source File: TestYarnCLI.java From hadoop with Apache License 2.0 | 4 votes |
@Test public void testGetApplicationAttempts() throws Exception { ApplicationCLI cli = createAndGetAppCLI(); ApplicationId applicationId = ApplicationId.newInstance(1234, 5); ApplicationAttemptId attemptId = ApplicationAttemptId.newInstance( applicationId, 1); ApplicationAttemptId attemptId1 = ApplicationAttemptId.newInstance( applicationId, 2); ApplicationAttemptReport attemptReport = ApplicationAttemptReport .newInstance(attemptId, "host", 124, "url", "oUrl", "diagnostics", YarnApplicationAttemptState.FINISHED, ContainerId.newContainerId( attemptId, 1)); ApplicationAttemptReport attemptReport1 = ApplicationAttemptReport .newInstance(attemptId1, "host", 124, "url", "oUrl", "diagnostics", YarnApplicationAttemptState.FINISHED, ContainerId.newContainerId( attemptId1, 1)); List<ApplicationAttemptReport> reports = new ArrayList<ApplicationAttemptReport>(); reports.add(attemptReport); reports.add(attemptReport1); when(client.getApplicationAttempts(any(ApplicationId.class))) .thenReturn(reports); int result = cli.run(new String[] { "applicationattempt", "-list", applicationId.toString() }); assertEquals(0, result); verify(client).getApplicationAttempts(applicationId); ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintWriter pw = new PrintWriter(baos); pw.println("Total number of application attempts :2"); pw.print(" ApplicationAttempt-Id"); pw.print("\t State"); pw.print("\t AM-Container-Id"); pw.println("\t Tracking-URL"); pw.print(" appattempt_1234_0005_000001"); pw.print("\t FINISHED"); pw.print("\t container_1234_0005_01_000001"); pw.println("\t url"); pw.print(" appattempt_1234_0005_000002"); pw.print("\t FINISHED"); pw.print("\t container_1234_0005_02_000001"); pw.println("\t url"); pw.close(); String appReportStr = baos.toString("UTF-8"); Assert.assertEquals(appReportStr, sysOutStream.toString()); }
Example 10
Source File: ProtocolHATestBase.java From big-c with Apache License 2.0 | 4 votes |
public ApplicationAttemptReport createFakeApplicationAttemptReport() { return ApplicationAttemptReport.newInstance( createFakeApplicationAttemptId(), "localhost", 0, "", "", "", YarnApplicationAttemptState.RUNNING, createFakeContainerId()); }
Example 11
Source File: TestAHSClient.java From big-c with Apache License 2.0 | 4 votes |
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 12
Source File: TestYarnCLI.java From big-c with Apache License 2.0 | 4 votes |
@Test public void testGetApplicationAttempts() throws Exception { ApplicationCLI cli = createAndGetAppCLI(); ApplicationId applicationId = ApplicationId.newInstance(1234, 5); ApplicationAttemptId attemptId = ApplicationAttemptId.newInstance( applicationId, 1); ApplicationAttemptId attemptId1 = ApplicationAttemptId.newInstance( applicationId, 2); ApplicationAttemptReport attemptReport = ApplicationAttemptReport .newInstance(attemptId, "host", 124, "url", "oUrl", "diagnostics", YarnApplicationAttemptState.FINISHED, ContainerId.newContainerId( attemptId, 1)); ApplicationAttemptReport attemptReport1 = ApplicationAttemptReport .newInstance(attemptId1, "host", 124, "url", "oUrl", "diagnostics", YarnApplicationAttemptState.FINISHED, ContainerId.newContainerId( attemptId1, 1)); List<ApplicationAttemptReport> reports = new ArrayList<ApplicationAttemptReport>(); reports.add(attemptReport); reports.add(attemptReport1); when(client.getApplicationAttempts(any(ApplicationId.class))) .thenReturn(reports); int result = cli.run(new String[] { "applicationattempt", "-list", applicationId.toString() }); assertEquals(0, result); verify(client).getApplicationAttempts(applicationId); ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintWriter pw = new PrintWriter(baos); pw.println("Total number of application attempts :2"); pw.print(" ApplicationAttempt-Id"); pw.print("\t State"); pw.print("\t AM-Container-Id"); pw.println("\t Tracking-URL"); pw.print(" appattempt_1234_0005_000001"); pw.print("\t FINISHED"); pw.print("\t container_1234_0005_01_000001"); pw.println("\t url"); pw.print(" appattempt_1234_0005_000002"); pw.print("\t FINISHED"); pw.print("\t container_1234_0005_02_000001"); pw.println("\t url"); pw.close(); String appReportStr = baos.toString("UTF-8"); Assert.assertEquals(appReportStr, sysOutStream.toString()); }