org.apache.hadoop.yarn.api.records.ApplicationAttemptReport Java Examples
The following examples show how to use
org.apache.hadoop.yarn.api.records.ApplicationAttemptReport.
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: YarnClientImpl.java From big-c with Apache License 2.0 | 6 votes |
@Override public List<ApplicationAttemptReport> getApplicationAttempts( ApplicationId appId) throws YarnException, IOException { try { GetApplicationAttemptsRequest request = Records .newRecord(GetApplicationAttemptsRequest.class); request.setApplicationId(appId); GetApplicationAttemptsResponse response = rmClient .getApplicationAttempts(request); return response.getApplicationAttemptList(); } catch (YarnException e) { if (!historyServiceEnabled) { // Just throw it as usual if historyService is not enabled. throw e; } // Even if history-service is enabled, treat all exceptions still the same // except the following if (e.getClass() != ApplicationNotFoundException.class) { throw e; } return historyClient.getApplicationAttempts(appId); } }
Example #2
Source File: TestYarnClient.java From hadoop with Apache License 2.0 | 6 votes |
@Test(timeout = 10000) public void testGetApplicationAttempt() throws YarnException, IOException { Configuration conf = new Configuration(); final YarnClient client = new MockYarnClient(); client.init(conf); client.start(); List<ApplicationReport> expectedReports = ((MockYarnClient) client) .getReports(); ApplicationId applicationId = ApplicationId.newInstance(1234, 5); ApplicationAttemptId appAttemptId = ApplicationAttemptId.newInstance( applicationId, 1); ApplicationAttemptReport report = client .getApplicationAttemptReport(appAttemptId); Assert.assertNotNull(report); Assert.assertEquals(report.getApplicationAttemptId().toString(), expectedReports.get(0).getCurrentApplicationAttemptId().toString()); client.stop(); }
Example #3
Source File: TestYarnClient.java From big-c with Apache License 2.0 | 6 votes |
@Test(timeout = 10000) public void testGetApplicationAttempt() throws YarnException, IOException { Configuration conf = new Configuration(); final YarnClient client = new MockYarnClient(); client.init(conf); client.start(); List<ApplicationReport> expectedReports = ((MockYarnClient) client) .getReports(); ApplicationId applicationId = ApplicationId.newInstance(1234, 5); ApplicationAttemptId appAttemptId = ApplicationAttemptId.newInstance( applicationId, 1); ApplicationAttemptReport report = client .getApplicationAttemptReport(appAttemptId); Assert.assertNotNull(report); Assert.assertEquals(report.getApplicationAttemptId().toString(), expectedReports.get(0).getCurrentApplicationAttemptId().toString()); client.stop(); }
Example #4
Source File: ApplicationHistoryManagerOnTimelineStore.java From hadoop with Apache License 2.0 | 6 votes |
@Override public Map<ApplicationAttemptId, ApplicationAttemptReport> getApplicationAttempts(ApplicationId appId) throws YarnException, IOException { ApplicationReportExt app = getApplication( appId, ApplicationReportField.USER_AND_ACLS); checkAccess(app); TimelineEntities entities = timelineDataManager.getEntities( AppAttemptMetricsConstants.ENTITY_TYPE, new NameValuePair( AppAttemptMetricsConstants.PARENT_PRIMARY_FILTER, appId .toString()), null, null, null, null, null, Long.MAX_VALUE, EnumSet.allOf(Field.class), UserGroupInformation.getLoginUser()); Map<ApplicationAttemptId, ApplicationAttemptReport> appAttempts = new LinkedHashMap<ApplicationAttemptId, ApplicationAttemptReport>(); for (TimelineEntity entity : entities.getEntities()) { ApplicationAttemptReport appAttempt = convertToApplicationAttemptReport(entity); appAttempts.put(appAttempt.getApplicationAttemptId(), appAttempt); } return appAttempts; }
Example #5
Source File: TestAHSClient.java From big-c with Apache License 2.0 | 6 votes |
@Test(timeout = 10000) public void testGetApplicationAttempts() throws YarnException, IOException { Configuration conf = new Configuration(); final AHSClient client = new MockAHSClient(); client.init(conf); client.start(); ApplicationId applicationId = ApplicationId.newInstance(1234, 5); List<ApplicationAttemptReport> reports = client.getApplicationAttempts(applicationId); Assert.assertNotNull(reports); Assert.assertEquals(reports.get(0).getApplicationAttemptId(), ApplicationAttemptId.newInstance(applicationId, 1)); Assert.assertEquals(reports.get(1).getApplicationAttemptId(), ApplicationAttemptId.newInstance(applicationId, 2)); client.stop(); }
Example #6
Source File: TestAHSClient.java From hadoop with Apache License 2.0 | 6 votes |
@Test(timeout = 10000) public void testGetApplicationAttempt() throws YarnException, IOException { Configuration conf = new Configuration(); final AHSClient client = new MockAHSClient(); client.init(conf); client.start(); List<ApplicationReport> expectedReports = ((MockAHSClient) client).getReports(); ApplicationId applicationId = ApplicationId.newInstance(1234, 5); ApplicationAttemptId appAttemptId = ApplicationAttemptId.newInstance(applicationId, 1); ApplicationAttemptReport report = client.getApplicationAttemptReport(appAttemptId); Assert.assertNotNull(report); Assert.assertEquals(report.getApplicationAttemptId().toString(), expectedReports.get(0).getCurrentApplicationAttemptId().toString()); client.stop(); }
Example #7
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 #8
Source File: ApplicationCLI.java From big-c with Apache License 2.0 | 6 votes |
/** * Lists the application attempts matching the given applicationid * * @param applicationId * @throws YarnException * @throws IOException */ private void listApplicationAttempts(String applicationId) throws YarnException, IOException { PrintWriter writer = new PrintWriter( new OutputStreamWriter(sysout, Charset.forName("UTF-8"))); List<ApplicationAttemptReport> appAttemptsReport = client .getApplicationAttempts(ConverterUtils.toApplicationId(applicationId)); writer.println("Total number of application attempts " + ":" + appAttemptsReport.size()); writer.printf(APPLICATION_ATTEMPTS_PATTERN, "ApplicationAttempt-Id", "State", "AM-Container-Id", "Tracking-URL"); for (ApplicationAttemptReport appAttemptReport : appAttemptsReport) { writer.printf(APPLICATION_ATTEMPTS_PATTERN, appAttemptReport .getApplicationAttemptId(), appAttemptReport .getYarnApplicationAttemptState(), appAttemptReport .getAMContainerId().toString(), appAttemptReport.getTrackingUrl()); } writer.flush(); }
Example #9
Source File: ApplicationCLI.java From hadoop with Apache License 2.0 | 6 votes |
/** * Lists the application attempts matching the given applicationid * * @param applicationId * @throws YarnException * @throws IOException */ private void listApplicationAttempts(String applicationId) throws YarnException, IOException { PrintWriter writer = new PrintWriter( new OutputStreamWriter(sysout, Charset.forName("UTF-8"))); List<ApplicationAttemptReport> appAttemptsReport = client .getApplicationAttempts(ConverterUtils.toApplicationId(applicationId)); writer.println("Total number of application attempts " + ":" + appAttemptsReport.size()); writer.printf(APPLICATION_ATTEMPTS_PATTERN, "ApplicationAttempt-Id", "State", "AM-Container-Id", "Tracking-URL"); for (ApplicationAttemptReport appAttemptReport : appAttemptsReport) { writer.printf(APPLICATION_ATTEMPTS_PATTERN, appAttemptReport .getApplicationAttemptId(), appAttemptReport .getYarnApplicationAttemptState(), appAttemptReport .getAMContainerId().toString(), appAttemptReport.getTrackingUrl()); } writer.flush(); }
Example #10
Source File: TestApplicationHistoryClientService.java From big-c with Apache License 2.0 | 6 votes |
@Test public void testApplicationAttempts() throws IOException, YarnException { ApplicationId appId = ApplicationId.newInstance(0, 1); ApplicationAttemptId appAttemptId = ApplicationAttemptId.newInstance(appId, 1); ApplicationAttemptId appAttemptId1 = ApplicationAttemptId.newInstance(appId, 2); GetApplicationAttemptsRequest request = GetApplicationAttemptsRequest.newInstance(appId); GetApplicationAttemptsResponse response = clientService.getApplicationAttempts(request); List<ApplicationAttemptReport> attemptReports = response.getApplicationAttemptList(); Assert.assertNotNull(attemptReports); Assert.assertEquals(appAttemptId, attemptReports.get(0) .getApplicationAttemptId()); Assert.assertEquals(appAttemptId1, attemptReports.get(1) .getApplicationAttemptId()); }
Example #11
Source File: ApplicationHistoryManagerOnTimelineStore.java From big-c with Apache License 2.0 | 6 votes |
@Override public Map<ApplicationAttemptId, ApplicationAttemptReport> getApplicationAttempts(ApplicationId appId) throws YarnException, IOException { ApplicationReportExt app = getApplication( appId, ApplicationReportField.USER_AND_ACLS); checkAccess(app); TimelineEntities entities = timelineDataManager.getEntities( AppAttemptMetricsConstants.ENTITY_TYPE, new NameValuePair( AppAttemptMetricsConstants.PARENT_PRIMARY_FILTER, appId .toString()), null, null, null, null, null, Long.MAX_VALUE, EnumSet.allOf(Field.class), UserGroupInformation.getLoginUser()); Map<ApplicationAttemptId, ApplicationAttemptReport> appAttempts = new LinkedHashMap<ApplicationAttemptId, ApplicationAttemptReport>(); for (TimelineEntity entity : entities.getEntities()) { ApplicationAttemptReport appAttempt = convertToApplicationAttemptReport(entity); appAttempts.put(appAttempt.getApplicationAttemptId(), appAttempt); } return appAttempts; }
Example #12
Source File: YarnClientImpl.java From hadoop with Apache License 2.0 | 6 votes |
@Override public List<ApplicationAttemptReport> getApplicationAttempts( ApplicationId appId) throws YarnException, IOException { try { GetApplicationAttemptsRequest request = Records .newRecord(GetApplicationAttemptsRequest.class); request.setApplicationId(appId); GetApplicationAttemptsResponse response = rmClient .getApplicationAttempts(request); return response.getApplicationAttemptList(); } catch (YarnException e) { if (!historyServiceEnabled) { // Just throw it as usual if historyService is not enabled. throw e; } // Even if history-service is enabled, treat all exceptions still the same // except the following if (e.getClass() != ApplicationNotFoundException.class) { throw e; } return historyClient.getApplicationAttempts(appId); } }
Example #13
Source File: YarnClientImpl.java From hadoop with Apache License 2.0 | 6 votes |
@Override public ApplicationAttemptReport getApplicationAttemptReport( ApplicationAttemptId appAttemptId) throws YarnException, IOException { try { GetApplicationAttemptReportRequest request = Records .newRecord(GetApplicationAttemptReportRequest.class); request.setApplicationAttemptId(appAttemptId); GetApplicationAttemptReportResponse response = rmClient .getApplicationAttemptReport(request); return response.getApplicationAttemptReport(); } catch (YarnException e) { if (!historyServiceEnabled) { // Just throw it as usual if historyService is not enabled. throw e; } // Even if history-service is enabled, treat all exceptions still the same // except the following if (e.getClass() != ApplicationNotFoundException.class) { throw e; } return historyClient.getApplicationAttemptReport(appAttemptId); } }
Example #14
Source File: TestApplicationHistoryManagerOnTimelineStore.java From big-c with Apache License 2.0 | 5 votes |
@Test public void testGetApplicationAttempts() throws Exception { final ApplicationId appId = ApplicationId.newInstance(0, 1); Collection<ApplicationAttemptReport> appAttempts; if (callerUGI == null) { appAttempts = historyManager.getApplicationAttempts(appId).values(); } else { try { appAttempts = callerUGI.doAs( new PrivilegedExceptionAction<Collection<ApplicationAttemptReport>> () { @Override public Collection<ApplicationAttemptReport> run() throws Exception { return historyManager.getApplicationAttempts(appId).values(); } }); if (callerUGI != null && callerUGI.getShortUserName().equals("user3")) { // The exception is expected Assert.fail(); } } catch (AuthorizationException e) { if (callerUGI != null && callerUGI.getShortUserName().equals("user3")) { // The exception is expected return; } throw e; } } Assert.assertNotNull(appAttempts); Assert.assertEquals(SCALE, appAttempts.size()); }
Example #15
Source File: GetApplicationAttemptsResponse.java From big-c with Apache License 2.0 | 5 votes |
@Public @Unstable public static GetApplicationAttemptsResponse newInstance( List<ApplicationAttemptReport> applicationAttempts) { GetApplicationAttemptsResponse response = Records.newRecord(GetApplicationAttemptsResponse.class); response.setApplicationAttemptList(applicationAttempts); return response; }
Example #16
Source File: TestYarnClient.java From big-c with Apache License 2.0 | 5 votes |
@Override public List<ApplicationAttemptReport> getApplicationAttempts( ApplicationId appId) throws YarnException, IOException { when(mockAppAttemptsResponse.getApplicationAttemptList()).thenReturn( getAttempts(appId)); return super.getApplicationAttempts(appId); }
Example #17
Source File: ApplicationHistoryClientService.java From big-c with Apache License 2.0 | 5 votes |
@Override public GetApplicationAttemptsResponse getApplicationAttempts( GetApplicationAttemptsRequest request) throws YarnException, IOException { GetApplicationAttemptsResponse response = GetApplicationAttemptsResponse .newInstance(new ArrayList<ApplicationAttemptReport>(history .getApplicationAttempts(request.getApplicationId()).values())); return response; }
Example #18
Source File: GetApplicationAttemptReportResponsePBImpl.java From big-c with Apache License 2.0 | 5 votes |
@Override public void setApplicationAttemptReport( ApplicationAttemptReport ApplicationAttemptReport) { maybeInitBuilder(); if (ApplicationAttemptReport == null) { builder.clearApplicationAttemptReport(); } this.applicationAttemptReport = ApplicationAttemptReport; }
Example #19
Source File: GetApplicationAttemptsResponsePBImpl.java From big-c with Apache License 2.0 | 5 votes |
private void addLocalApplicationAttemptsToProto() { maybeInitBuilder(); builder.clearApplicationAttempts(); if (applicationAttemptList == null) { return; } Iterable<ApplicationAttemptReportProto> iterable = new Iterable<ApplicationAttemptReportProto>() { @Override public Iterator<ApplicationAttemptReportProto> iterator() { return new Iterator<ApplicationAttemptReportProto>() { Iterator<ApplicationAttemptReport> iter = applicationAttemptList .iterator(); @Override public boolean hasNext() { return iter.hasNext(); } @Override public ApplicationAttemptReportProto next() { return convertToProtoFormat(iter.next()); } @Override public void remove() { throw new UnsupportedOperationException(); } }; } }; builder.addAllApplicationAttempts(iterable); }
Example #20
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 #21
Source File: TestApplicationClientProtocolOnHA.java From hadoop with Apache License 2.0 | 5 votes |
@Test(timeout = 15000) public void testGetApplicationAttemptsOnHA() throws Exception { List<ApplicationAttemptReport> reports = client.getApplicationAttempts(cluster.createFakeAppId()); Assert.assertTrue(reports != null && !reports.isEmpty()); Assert.assertEquals(cluster.createFakeApplicationAttemptReports(), reports); }
Example #22
Source File: UnmanagedAMLauncher.java From big-c with Apache License 2.0 | 5 votes |
private ApplicationAttemptReport monitorCurrentAppAttempt( ApplicationId appId, YarnApplicationAttemptState attemptState) throws YarnException, IOException { long startTime = System.currentTimeMillis(); ApplicationAttemptId attemptId = null; while (true) { if (attemptId == null) { attemptId = rmClient.getApplicationReport(appId) .getCurrentApplicationAttemptId(); } ApplicationAttemptReport attemptReport = null; if (attemptId != null) { attemptReport = rmClient.getApplicationAttemptReport(attemptId); if (attemptState.equals(attemptReport.getYarnApplicationAttemptState())) { return attemptReport; } } LOG.info("Current attempt state of " + appId + " is " + (attemptReport == null ? " N/A " : attemptReport.getYarnApplicationAttemptState()) + ", waiting for current attempt to reach " + attemptState); try { Thread.sleep(1000); } catch (InterruptedException e) { LOG.warn("Interrupted while waiting for current attempt of " + appId + " to reach " + attemptState); } if (System.currentTimeMillis() - startTime > AM_STATE_WAIT_TIMEOUT_MS) { String errmsg = "Timeout for waiting current attempt of " + appId + " to reach " + attemptState; LOG.error(errmsg); throw new RuntimeException(errmsg); } } }
Example #23
Source File: ClientRMService.java From big-c with Apache License 2.0 | 5 votes |
@Override public GetApplicationAttemptsResponse getApplicationAttempts( GetApplicationAttemptsRequest request) throws YarnException, IOException { ApplicationId appId = request.getApplicationId(); UserGroupInformation callerUGI; try { callerUGI = UserGroupInformation.getCurrentUser(); } catch (IOException ie) { LOG.info("Error getting UGI ", ie); throw RPCUtil.getRemoteException(ie); } RMApp application = this.rmContext.getRMApps().get(appId); if (application == null) { // If the RM doesn't have the application, throw // ApplicationNotFoundException and let client to handle. throw new ApplicationNotFoundException("Application with id '" + appId + "' doesn't exist in RM."); } boolean allowAccess = checkAccess(callerUGI, application.getUser(), ApplicationAccessType.VIEW_APP, application); GetApplicationAttemptsResponse response = null; if (allowAccess) { Map<ApplicationAttemptId, RMAppAttempt> attempts = application .getAppAttempts(); List<ApplicationAttemptReport> listAttempts = new ArrayList<ApplicationAttemptReport>(); Iterator<Map.Entry<ApplicationAttemptId, RMAppAttempt>> iter = attempts .entrySet().iterator(); while (iter.hasNext()) { listAttempts.add(iter.next().getValue() .createApplicationAttemptReport()); } response = GetApplicationAttemptsResponse.newInstance(listAttempts); } else { throw new YarnException("User " + callerUGI.getShortUserName() + " does not have privilage to see this aplication " + appId); } return response; }
Example #24
Source File: GetApplicationAttemptsResponsePBImpl.java From big-c with Apache License 2.0 | 5 votes |
@Override public void setApplicationAttemptList( List<ApplicationAttemptReport> applicationAttempts) { maybeInitBuilder(); if (applicationAttempts == null) { builder.clearApplicationAttempts(); } this.applicationAttemptList = applicationAttempts; }
Example #25
Source File: TestYarnClient.java From hadoop with Apache License 2.0 | 5 votes |
@Override public List<ApplicationAttemptReport> getApplicationAttempts( ApplicationId appId) throws YarnException, IOException { when(mockAppAttemptsResponse.getApplicationAttemptList()).thenReturn( getAttempts(appId)); return super.getApplicationAttempts(appId); }
Example #26
Source File: ApplicationHistoryManagerOnTimelineStore.java From big-c with Apache License 2.0 | 5 votes |
@Override public ContainerReport getAMContainer(ApplicationAttemptId appAttemptId) throws YarnException, IOException { ApplicationAttemptReport appAttempt = getApplicationAttempt(appAttemptId, false); return getContainer(appAttempt.getAMContainerId()); }
Example #27
Source File: TestAHSClient.java From hadoop with Apache License 2.0 | 5 votes |
@Override public List<ApplicationAttemptReport> getApplicationAttempts( ApplicationId appId) throws YarnException, IOException { when(mockAppAttemptsResponse.getApplicationAttemptList()).thenReturn( getAttempts(appId)); return super.getApplicationAttempts(appId); }
Example #28
Source File: ProtocolHATestBase.java From hadoop with Apache License 2.0 | 5 votes |
public List<ApplicationAttemptReport> createFakeApplicationAttemptReports() { List<ApplicationAttemptReport> reports = new ArrayList<ApplicationAttemptReport>(); reports.add(createFakeApplicationAttemptReport()); return reports; }
Example #29
Source File: TestApplicationClientProtocolOnHA.java From hadoop with Apache License 2.0 | 5 votes |
@Test(timeout = 15000) public void testGetApplicationAttemptReportOnHA() throws Exception { ApplicationAttemptReport report = client.getApplicationAttemptReport(cluster .createFakeApplicationAttemptId()); Assert.assertTrue(report != null); Assert.assertEquals(cluster.createFakeApplicationAttemptReport(), report); }
Example #30
Source File: AHSClientImpl.java From hadoop with Apache License 2.0 | 5 votes |
@Override public List<ApplicationAttemptReport> getApplicationAttempts( ApplicationId appId) throws YarnException, IOException { GetApplicationAttemptsRequest request = GetApplicationAttemptsRequest .newInstance(appId); GetApplicationAttemptsResponse response = ahsClient .getApplicationAttempts(request); return response.getApplicationAttemptList(); }