org.apache.hadoop.yarn.api.records.FinalApplicationStatus Java Examples
The following examples show how to use
org.apache.hadoop.yarn.api.records.FinalApplicationStatus.
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: TestRMAppAttemptTransitions.java From big-c with Apache License 2.0 | 6 votes |
@Test public void testFinalSavingToFinishedWithExpire() { Container amContainer = allocateApplicationAttempt(); launchApplicationAttempt(amContainer); runApplicationAttempt(amContainer, "host", 8042, "oldtrackingurl", false); FinalApplicationStatus finalStatus = FinalApplicationStatus.SUCCEEDED; String trackingUrl = "mytrackingurl"; String diagnostics = "Successssseeeful"; applicationAttempt.handle(new RMAppAttemptUnregistrationEvent( applicationAttempt.getAppAttemptId(), trackingUrl, finalStatus, diagnostics)); assertEquals(RMAppAttemptState.FINAL_SAVING, applicationAttempt.getAppAttemptState()); assertEquals(YarnApplicationAttemptState.RUNNING, applicationAttempt.createApplicationAttemptState()); // Expire event comes before Attempt_saved event. applicationAttempt.handle(new RMAppAttemptEvent(applicationAttempt .getAppAttemptId(), RMAppAttemptEventType.EXPIRE)); assertEquals(RMAppAttemptState.FINAL_SAVING, applicationAttempt.getAppAttemptState()); // send attempt_saved sendAttemptUpdateSavedEvent(applicationAttempt); testAppAttemptFinishedState(amContainer, finalStatus, trackingUrl, diagnostics, 0, false); }
Example #2
Source File: StreamingAppMasterService.java From attic-apex-core with Apache License 2.0 | 6 votes |
private void finishApplication(FinalApplicationStatus finalStatus) throws YarnException, IOException { LOG.info("Application completed. Signalling finish to RM"); FinishApplicationMasterRequest finishReq = Records.newRecord(FinishApplicationMasterRequest.class); finishReq.setFinalApplicationStatus(finalStatus); if (finalStatus != FinalApplicationStatus.SUCCEEDED) { String diagnostics = "Diagnostics." + " completed=" + numCompletedContainers.get() + ", allocated=" + allocatedContainers.size() + ", failed=" + numFailedContainers.get(); if (!StringUtils.isEmpty(dnmgr.shutdownDiagnosticsMessage)) { diagnostics += "\n"; diagnostics += dnmgr.shutdownDiagnosticsMessage; } // YARN-208 - as of 2.0.1-alpha dropped by the RM finishReq.setDiagnostics(diagnostics); // expected termination of the master process // application status and diagnostics message are set above } LOG.info("diagnostics: " + finishReq.getDiagnostics()); amRmClient.unregisterApplicationMaster(finishReq.getFinalApplicationStatus(), finishReq.getDiagnostics(), null); }
Example #3
Source File: TestRMAppAttemptTransitions.java From big-c with Apache License 2.0 | 6 votes |
/** * {@link RMAppAttemptState#FINISHING} */ private void testAppAttemptFinishingState(Container container, FinalApplicationStatus finalStatus, String trackingUrl, String diagnostics) { assertEquals(RMAppAttemptState.FINISHING, applicationAttempt.getAppAttemptState()); assertEquals(diagnostics, applicationAttempt.getDiagnostics()); verifyUrl(trackingUrl, applicationAttempt.getOriginalTrackingUrl()); assertEquals(getProxyUrl(applicationAttempt), applicationAttempt.getTrackingUrl()); assertEquals(container, applicationAttempt.getMasterContainer()); assertEquals(finalStatus, applicationAttempt.getFinalApplicationStatus()); verifyTokenCount(applicationAttempt.getAppAttemptId(), 0); verifyAttemptFinalStateSaved(); }
Example #4
Source File: TestRMApplicationHistoryWriter.java From big-c with Apache License 2.0 | 6 votes |
private static RMApp createRMApp(ApplicationId appId) { RMApp app = mock(RMApp.class); when(app.getApplicationId()).thenReturn(appId); when(app.getName()).thenReturn("test app"); when(app.getApplicationType()).thenReturn("test app type"); when(app.getUser()).thenReturn("test user"); when(app.getQueue()).thenReturn("test queue"); when(app.getSubmitTime()).thenReturn(0L); when(app.getStartTime()).thenReturn(1L); when(app.getFinishTime()).thenReturn(2L); when(app.getDiagnostics()).thenReturn( new StringBuilder("test diagnostics info")); when(app.getFinalApplicationStatus()).thenReturn( FinalApplicationStatus.UNDEFINED); return app; }
Example #5
Source File: TestRMAppAttemptTransitions.java From hadoop with Apache License 2.0 | 6 votes |
@Test public void testFinishingKill() { Container amContainer = allocateApplicationAttempt(); launchApplicationAttempt(amContainer); runApplicationAttempt(amContainer, "host", 8042, "oldtrackingurl", false); FinalApplicationStatus finalStatus = FinalApplicationStatus.FAILED; String trackingUrl = "newtrackingurl"; String diagnostics = "Job failed"; unregisterApplicationAttempt(amContainer, finalStatus, trackingUrl, diagnostics); applicationAttempt.handle( new RMAppAttemptEvent( applicationAttempt.getAppAttemptId(), RMAppAttemptEventType.KILL)); testAppAttemptFinishingState(amContainer, finalStatus, trackingUrl, diagnostics); }
Example #6
Source File: AppAttemptFinishedEvent.java From big-c with Apache License 2.0 | 6 votes |
public AppAttemptFinishedEvent( ApplicationAttemptId appAttemptId, String trackingUrl, String originalTrackingUrl, String diagnosticsInfo, FinalApplicationStatus appStatus, YarnApplicationAttemptState state, long finishedTime) { super(SystemMetricsEventType.APP_ATTEMPT_FINISHED, finishedTime); this.appAttemptId = appAttemptId; // This is the tracking URL after the application attempt is finished this.trackingUrl = trackingUrl; this.originalTrackingUrl = originalTrackingUrl; this.diagnosticsInfo = diagnosticsInfo; this.appStatus = appStatus; this.state = state; }
Example #7
Source File: AppAttemptFinishedEvent.java From hadoop with Apache License 2.0 | 6 votes |
public AppAttemptFinishedEvent( ApplicationAttemptId appAttemptId, String trackingUrl, String originalTrackingUrl, String diagnosticsInfo, FinalApplicationStatus appStatus, YarnApplicationAttemptState state, long finishedTime) { super(SystemMetricsEventType.APP_ATTEMPT_FINISHED, finishedTime); this.appAttemptId = appAttemptId; // This is the tracking URL after the application attempt is finished this.trackingUrl = trackingUrl; this.originalTrackingUrl = originalTrackingUrl; this.diagnosticsInfo = diagnosticsInfo; this.appStatus = appStatus; this.state = state; }
Example #8
Source File: ApexCliShutdownCommandTest.java From attic-apex-core with Apache License 2.0 | 6 votes |
private ApplicationReport mockRunningApplicationReport(String appId, String appName) { ApplicationReport app = mock(ApplicationReport.class); ApplicationId applicationId = mock(ApplicationId.class); when(applicationId.toString()).thenReturn(appId); when(app.getApplicationId()).thenReturn(applicationId); when(app.getName()).thenReturn(appName); when(app.getYarnApplicationState()).thenReturn(YarnApplicationState.RUNNING); when(app.getFinalApplicationStatus()).thenReturn(FinalApplicationStatus.UNDEFINED); when(app.getTrackingUrl()).thenReturn("http://example.com"); return app; }
Example #9
Source File: ApplicationFinishedEvent.java From big-c with Apache License 2.0 | 6 votes |
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; }
Example #10
Source File: TestRMAppAttemptTransitions.java From hadoop with Apache License 2.0 | 6 votes |
/** * {@link RMAppAttemptState#FINISHING} */ private void testAppAttemptFinishingState(Container container, FinalApplicationStatus finalStatus, String trackingUrl, String diagnostics) { assertEquals(RMAppAttemptState.FINISHING, applicationAttempt.getAppAttemptState()); assertEquals(diagnostics, applicationAttempt.getDiagnostics()); verifyUrl(trackingUrl, applicationAttempt.getOriginalTrackingUrl()); assertEquals(getProxyUrl(applicationAttempt), applicationAttempt.getTrackingUrl()); assertEquals(container, applicationAttempt.getMasterContainer()); assertEquals(finalStatus, applicationAttempt.getFinalApplicationStatus()); verifyTokenCount(applicationAttempt.getAppAttemptId(), 0); verifyAttemptFinalStateSaved(); }
Example #11
Source File: TestRMAppAttemptTransitions.java From hadoop with Apache License 2.0 | 6 votes |
@Test public void testFinishingToFinishing() { Container amContainer = allocateApplicationAttempt(); launchApplicationAttempt(amContainer); runApplicationAttempt(amContainer, "host", 8042, "oldtrackingurl", false); FinalApplicationStatus finalStatus = FinalApplicationStatus.SUCCEEDED; String trackingUrl = "mytrackingurl"; String diagnostics = "Successful"; unregisterApplicationAttempt(amContainer, finalStatus, trackingUrl, diagnostics); // container must be AM container to move from FINISHING to FINISHED NodeId anyNodeId = NodeId.newInstance("host", 1234); applicationAttempt.handle( new RMAppAttemptContainerFinishedEvent( applicationAttempt.getAppAttemptId(), BuilderUtils.newContainerStatus( BuilderUtils.newContainerId( applicationAttempt.getAppAttemptId(), 42), ContainerState.COMPLETE, "", 0), anyNodeId)); testAppAttemptFinishingState(amContainer, finalStatus, trackingUrl, diagnostics); }
Example #12
Source File: TestApplicatonReport.java From hadoop with Apache License 2.0 | 5 votes |
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 #13
Source File: TestRMAppAttemptTransitions.java From big-c with Apache License 2.0 | 5 votes |
/** * {@link RMAppAttemptState#FINISHED} */ private void testAppAttemptFinishedState(Container container, FinalApplicationStatus finalStatus, String trackingUrl, String diagnostics, int finishedContainerCount, boolean unmanagedAM) { assertEquals(RMAppAttemptState.FINISHED, applicationAttempt.getAppAttemptState()); assertEquals(diagnostics, applicationAttempt.getDiagnostics()); verifyUrl(trackingUrl, applicationAttempt.getOriginalTrackingUrl()); if (unmanagedAM) { verifyUrl(trackingUrl, applicationAttempt.getTrackingUrl()); } else { assertEquals(getProxyUrl(applicationAttempt), applicationAttempt.getTrackingUrl()); verifyAttemptFinalStateSaved(); } assertEquals(finishedContainerCount, applicationAttempt .getJustFinishedContainers().size()); Assert.assertEquals(0, getFinishedContainersSentToAM(applicationAttempt) .size()); assertEquals(container, applicationAttempt.getMasterContainer()); assertEquals(finalStatus, applicationAttempt.getFinalApplicationStatus()); verifyTokenCount(applicationAttempt.getAppAttemptId(), 1); assertFalse(transferStateFromPreviousAttempt); verifyApplicationAttemptFinished(RMAppAttemptState.FINISHED); }
Example #14
Source File: TestApplicationMasterServiceProtocolOnHA.java From big-c with Apache License 2.0 | 5 votes |
@Test(timeout = 15000) public void testFinishApplicationMasterOnHA() throws YarnException, IOException { FinishApplicationMasterRequest request = FinishApplicationMasterRequest.newInstance( FinalApplicationStatus.SUCCEEDED, "", ""); FinishApplicationMasterResponse response = amClient.finishApplicationMaster(request); Assert.assertEquals(response, this.cluster.createFakeFinishApplicationMasterResponse()); }
Example #15
Source File: ApplicationReportPBImpl.java From hadoop with Apache License 2.0 | 5 votes |
@Override public FinalApplicationStatus getFinalApplicationStatus() { ApplicationReportProtoOrBuilder p = viaProto ? proto : builder; if (!p.hasFinalApplicationStatus()) { return null; } return convertFromProtoFormat(p.getFinalApplicationStatus()); }
Example #16
Source File: TestRMAppAttemptTransitions.java From hadoop with Apache License 2.0 | 5 votes |
@Test public void testFinalSavingToFinishedWithContainerFinished() { Container amContainer = allocateApplicationAttempt(); launchApplicationAttempt(amContainer); runApplicationAttempt(amContainer, "host", 8042, "oldtrackingurl", false); FinalApplicationStatus finalStatus = FinalApplicationStatus.SUCCEEDED; String trackingUrl = "mytrackingurl"; String diagnostics = "Successful"; applicationAttempt.handle(new RMAppAttemptUnregistrationEvent( applicationAttempt.getAppAttemptId(), trackingUrl, finalStatus, diagnostics)); assertEquals(RMAppAttemptState.FINAL_SAVING, applicationAttempt.getAppAttemptState()); assertEquals(YarnApplicationAttemptState.RUNNING, applicationAttempt.createApplicationAttemptState()); // Container_finished event comes before Attempt_Saved event. NodeId anyNodeId = NodeId.newInstance("host", 1234); applicationAttempt.handle(new RMAppAttemptContainerFinishedEvent( applicationAttempt.getAppAttemptId(), BuilderUtils.newContainerStatus( amContainer.getId(), ContainerState.COMPLETE, "", 0), anyNodeId)); assertEquals(RMAppAttemptState.FINAL_SAVING, applicationAttempt.getAppAttemptState()); // send attempt_saved sendAttemptUpdateSavedEvent(applicationAttempt); testAppAttemptFinishedState(amContainer, finalStatus, trackingUrl, diagnostics, 0, false); }
Example #17
Source File: ApplicationReportPBImpl.java From big-c with Apache License 2.0 | 5 votes |
@Override public FinalApplicationStatus getFinalApplicationStatus() { ApplicationReportProtoOrBuilder p = viaProto ? proto : builder; if (!p.hasFinalApplicationStatus()) { return null; } return convertFromProtoFormat(p.getFinalApplicationStatus()); }
Example #18
Source File: TestRMAppAttemptTransitions.java From big-c with Apache License 2.0 | 5 votes |
@Test public void testFinalSavingToFinishedWithContainerFinished() { Container amContainer = allocateApplicationAttempt(); launchApplicationAttempt(amContainer); runApplicationAttempt(amContainer, "host", 8042, "oldtrackingurl", false); FinalApplicationStatus finalStatus = FinalApplicationStatus.SUCCEEDED; String trackingUrl = "mytrackingurl"; String diagnostics = "Successful"; applicationAttempt.handle(new RMAppAttemptUnregistrationEvent( applicationAttempt.getAppAttemptId(), trackingUrl, finalStatus, diagnostics)); assertEquals(RMAppAttemptState.FINAL_SAVING, applicationAttempt.getAppAttemptState()); assertEquals(YarnApplicationAttemptState.RUNNING, applicationAttempt.createApplicationAttemptState()); // Container_finished event comes before Attempt_Saved event. NodeId anyNodeId = NodeId.newInstance("host", 1234); applicationAttempt.handle(new RMAppAttemptContainerFinishedEvent( applicationAttempt.getAppAttemptId(), BuilderUtils.newContainerStatus( amContainer.getId(), ContainerState.COMPLETE, "", 0), anyNodeId)); assertEquals(RMAppAttemptState.FINAL_SAVING, applicationAttempt.getAppAttemptState()); // send attempt_saved sendAttemptUpdateSavedEvent(applicationAttempt); testAppAttemptFinishedState(amContainer, finalStatus, trackingUrl, diagnostics, 0, false); }
Example #19
Source File: RMAppAttemptUnregistrationEvent.java From hadoop with Apache License 2.0 | 5 votes |
public RMAppAttemptUnregistrationEvent(ApplicationAttemptId appAttemptId, String trackingUrl, FinalApplicationStatus finalStatus, String diagnostics) { super(appAttemptId, RMAppAttemptEventType.UNREGISTERED); this.finalTrackingUrl = trackingUrl; this.finalStatus = finalStatus; this.diagnostics = diagnostics; }
Example #20
Source File: TestClientServiceDelegate.java From big-c with Apache License 2.0 | 5 votes |
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 #21
Source File: ApplicationAttemptFinishData.java From hadoop with Apache License 2.0 | 5 votes |
@Public @Unstable public static ApplicationAttemptFinishData newInstance( ApplicationAttemptId appAttemptId, String diagnosticsInfo, String trackingURL, FinalApplicationStatus finalApplicationStatus, YarnApplicationAttemptState yarnApplicationAttemptState) { ApplicationAttemptFinishData appAttemptFD = Records.newRecord(ApplicationAttemptFinishData.class); appAttemptFD.setApplicationAttemptId(appAttemptId); appAttemptFD.setDiagnosticsInfo(diagnosticsInfo); appAttemptFD.setTrackingURL(trackingURL); appAttemptFD.setFinalApplicationStatus(finalApplicationStatus); appAttemptFD.setYarnApplicationAttemptState(yarnApplicationAttemptState); return appAttemptFD; }
Example #22
Source File: RMAppAttemptImpl.java From hadoop with Apache License 2.0 | 5 votes |
@Override public FinalApplicationStatus getFinalApplicationStatus() { this.readLock.lock(); try { return this.finalStatus; } finally { this.readLock.unlock(); } }
Example #23
Source File: BuilderUtils.java From hadoop with Apache License 2.0 | 5 votes |
public static ApplicationReport newApplicationReport( ApplicationId applicationId, ApplicationAttemptId applicationAttemptId, String user, String queue, String name, String host, int rpcPort, Token clientToAMToken, YarnApplicationState state, String diagnostics, String url, long startTime, long finishTime, FinalApplicationStatus finalStatus, ApplicationResourceUsageReport appResources, String origTrackingUrl, float progress, String appType, Token amRmToken, Set<String> tags) { ApplicationReport report = recordFactory .newRecordInstance(ApplicationReport.class); report.setApplicationId(applicationId); report.setCurrentApplicationAttemptId(applicationAttemptId); report.setUser(user); report.setQueue(queue); report.setName(name); report.setHost(host); report.setRpcPort(rpcPort); report.setClientToAMToken(clientToAMToken); report.setYarnApplicationState(state); report.setDiagnostics(diagnostics); report.setTrackingUrl(url); report.setStartTime(startTime); report.setFinishTime(finishTime); report.setFinalApplicationStatus(finalStatus); report.setApplicationResourceUsageReport(appResources); report.setOriginalTrackingUrl(origTrackingUrl); report.setProgress(progress); report.setApplicationType(appType); report.setAMRMToken(amRmToken); report.setApplicationTags(tags); return report; }
Example #24
Source File: ProtocolHATestBase.java From hadoop with Apache License 2.0 | 5 votes |
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 #25
Source File: ApplicationAttemptFinishData.java From big-c with Apache License 2.0 | 5 votes |
@Public @Unstable public static ApplicationAttemptFinishData newInstance( ApplicationAttemptId appAttemptId, String diagnosticsInfo, String trackingURL, FinalApplicationStatus finalApplicationStatus, YarnApplicationAttemptState yarnApplicationAttemptState) { ApplicationAttemptFinishData appAttemptFD = Records.newRecord(ApplicationAttemptFinishData.class); appAttemptFD.setApplicationAttemptId(appAttemptId); appAttemptFD.setDiagnosticsInfo(diagnosticsInfo); appAttemptFD.setTrackingURL(trackingURL); appAttemptFD.setFinalApplicationStatus(finalApplicationStatus); appAttemptFD.setYarnApplicationAttemptState(yarnApplicationAttemptState); return appAttemptFD; }
Example #26
Source File: TestAMRMClient.java From hadoop with Apache License 2.0 | 5 votes |
@Test (timeout=60000) public void testAMRMClient() throws YarnException, IOException { AMRMClient<ContainerRequest> amClient = null; try { // start am rm client amClient = AMRMClient.<ContainerRequest>createAMRMClient(); //setting an instance NMTokenCache amClient.setNMTokenCache(new NMTokenCache()); //asserting we are not using the singleton instance cache Assert.assertNotSame(NMTokenCache.getSingleton(), amClient.getNMTokenCache()); amClient.init(conf); amClient.start(); amClient.registerApplicationMaster("Host", 10000, ""); testAllocation((AMRMClientImpl<ContainerRequest>)amClient); amClient.unregisterApplicationMaster(FinalApplicationStatus.SUCCEEDED, null, null); } finally { if (amClient != null && amClient.getServiceState() == STATE.STARTED) { amClient.stop(); } } }
Example #27
Source File: ApplicationAttemptFinishDataPBImpl.java From big-c with Apache License 2.0 | 5 votes |
@Override public FinalApplicationStatus getFinalApplicationStatus() { ApplicationAttemptFinishDataProtoOrBuilder p = viaProto ? proto : builder; if (!p.hasFinalApplicationStatus()) { return null; } return convertFromProtoFormat(p.getFinalApplicationStatus()); }
Example #28
Source File: AMSimulator.java From big-c with Apache License 2.0 | 5 votes |
@Override public void lastStep() throws Exception { LOG.info(MessageFormat.format("Application {0} is shutting down.", appId)); // unregister tracking if (isTracked) { untrackApp(); } // unregister application master final FinishApplicationMasterRequest finishAMRequest = recordFactory .newRecordInstance(FinishApplicationMasterRequest.class); finishAMRequest.setFinalApplicationStatus(FinalApplicationStatus.SUCCEEDED); UserGroupInformation ugi = UserGroupInformation.createRemoteUser(appAttemptId.toString()); Token<AMRMTokenIdentifier> token = rm.getRMContext().getRMApps().get(appId) .getRMAppAttempt(appAttemptId).getAMRMToken(); ugi.addTokenIdentifier(token.decodeIdentifier()); ugi.doAs(new PrivilegedExceptionAction<Object>() { @Override public Object run() throws Exception { rm.getApplicationMasterService() .finishApplicationMaster(finishAMRequest); return null; } }); simulateFinishTimeMS = System.currentTimeMillis() - SLSRunner.getRunner().getStartTimeMS(); // record job running information ((ResourceSchedulerWrapper)rm.getResourceScheduler()) .addAMRuntime(appId, traceStartTimeMS, traceFinishTimeMS, simulateStartTimeMS, simulateFinishTimeMS); }
Example #29
Source File: TestRMAppAttemptTransitions.java From big-c with Apache License 2.0 | 5 votes |
@Test public void testUsageReport() { // scheduler has info on running apps ApplicationAttemptId attemptId = applicationAttempt.getAppAttemptId(); ApplicationResourceUsageReport appResUsgRpt = mock(ApplicationResourceUsageReport.class); when(appResUsgRpt.getMemorySeconds()).thenReturn(123456L); when(appResUsgRpt.getVcoreSeconds()).thenReturn(55544L); when(scheduler.getAppResourceUsageReport(any(ApplicationAttemptId.class))) .thenReturn(appResUsgRpt); // start and finish the attempt Container amContainer = allocateApplicationAttempt(); launchApplicationAttempt(amContainer); runApplicationAttempt(amContainer, "host", 8042, "oldtrackingurl", false); applicationAttempt.handle(new RMAppAttemptUnregistrationEvent(attemptId, "", FinalApplicationStatus.SUCCEEDED, "")); // expect usage stats to come from the scheduler report ApplicationResourceUsageReport report = applicationAttempt.getApplicationResourceUsageReport(); Assert.assertEquals(123456L, report.getMemorySeconds()); Assert.assertEquals(55544L, report.getVcoreSeconds()); // finish app attempt and remove it from scheduler when(appResUsgRpt.getMemorySeconds()).thenReturn(223456L); when(appResUsgRpt.getVcoreSeconds()).thenReturn(75544L); sendAttemptUpdateSavedEvent(applicationAttempt); NodeId anyNodeId = NodeId.newInstance("host", 1234); applicationAttempt.handle(new RMAppAttemptContainerFinishedEvent( attemptId, ContainerStatus.newInstance( amContainer.getId(), ContainerState.COMPLETE, "", 0), anyNodeId)); when(scheduler.getSchedulerAppInfo(eq(attemptId))).thenReturn(null); report = applicationAttempt.getApplicationResourceUsageReport(); Assert.assertEquals(223456, report.getMemorySeconds()); Assert.assertEquals(75544, report.getVcoreSeconds()); }
Example #30
Source File: TestHadoopShim28.java From tez with Apache License 2.0 | 5 votes |
@Test public void testApplyFinalApplicationStatusCorrection() { HadoopShim shim = new HadoopShim28(); // Session mode success/failure, change to ended Assert.assertEquals(FinalApplicationStatus.ENDED, shim.applyFinalApplicationStatusCorrection(FinalApplicationStatus.SUCCEEDED, true, false)); Assert.assertEquals(FinalApplicationStatus.ENDED, shim.applyFinalApplicationStatusCorrection(FinalApplicationStatus.FAILED, true, false)); // Non-session mode success/failure, retain success/failure Assert.assertEquals(FinalApplicationStatus.SUCCEEDED, shim.applyFinalApplicationStatusCorrection(FinalApplicationStatus.SUCCEEDED, false, false)); Assert.assertEquals(FinalApplicationStatus.FAILED, shim.applyFinalApplicationStatusCorrection(FinalApplicationStatus.FAILED, false, false)); // Session and non-session mode error, retain failed. Assert.assertEquals(FinalApplicationStatus.FAILED, shim.applyFinalApplicationStatusCorrection(FinalApplicationStatus.FAILED, true, true)); Assert.assertEquals(FinalApplicationStatus.FAILED, shim.applyFinalApplicationStatusCorrection(FinalApplicationStatus.FAILED, false, true)); // Session and non-session mode killed is killed. Assert.assertEquals(FinalApplicationStatus.KILLED, shim.applyFinalApplicationStatusCorrection(FinalApplicationStatus.KILLED, true, false)); Assert.assertEquals(FinalApplicationStatus.KILLED, shim.applyFinalApplicationStatusCorrection(FinalApplicationStatus.KILLED, false, false)); // Session and non-session mode undefined is undefined. Assert.assertEquals(FinalApplicationStatus.UNDEFINED, shim.applyFinalApplicationStatusCorrection(FinalApplicationStatus.UNDEFINED, true, false)); Assert.assertEquals(FinalApplicationStatus.UNDEFINED, shim.applyFinalApplicationStatusCorrection(FinalApplicationStatus.UNDEFINED, false, false)); }