@Override public ApplicationReport getApplicationReport(ApplicationId appId) throws YarnException, IOException { ApplicationReport report = yarnClient.getApplicationReport(appId); if (report.getYarnApplicationState() == null) { // The state can be null when the ResourceManager does not know about the app but the YARN // application history server has an incomplete entry for it. Treat this scenario as if the // application does not exist, since the final app status cannot be determined. This also // matches the behavior for this scenario if the history server was not configured. throw new ApplicationNotFoundException("YARN reports no state for application " + appId); } return report; }
@Test public void testFetchReportAHSDisabled() throws YarnException, IOException { try { testHelper(false); } catch (ApplicationNotFoundException e) { Assert.assertTrue(e.getMessage() == appNotFoundExceptionMsg); /* RM will not know of the app and Application History Service is disabled * So we will not try to get the report from AHS and RM will throw * ApplicationNotFoundException */ } Mockito.verify(appManager, Mockito.times(1)) .getApplicationReport(Mockito.any(GetApplicationReportRequest.class)); if (historyManager != null) { Assert.fail("HistoryManager should be null as AHS is disabled"); } }
@Test public void testFetchReportAHSDisabled() throws YarnException, IOException { try { testHelper(false); } catch (ApplicationNotFoundException e) { Assert.assertTrue(e.getMessage() == appNotFoundExceptionMsg); /* RM will not know of the app and Application History Service is disabled * So we will not try to get the report from AHS and RM will throw * ApplicationNotFoundException */ } Mockito.verify(appManager, Mockito.times(1)) .getApplicationReport(Mockito.any(GetApplicationReportRequest.class)); if (historyManager != null) { Assert.fail("HistoryManager should be null as AHS is disabled"); } }
@Override public int actionStop(String serviceName, boolean waitForAppStopped) throws YarnException, IOException { if (serviceName == null) { throw new NullPointerException(); } if (serviceName.equals("jenkins")) { return EXIT_SUCCESS; } else if (serviceName.equals("jenkins-second-stop")) { return EXIT_COMMAND_ARGUMENT_ERROR; } else { throw new ApplicationNotFoundException(""); } }
@Test public void testForceKillNonExistingApplication() throws YarnException { RMContext rmContext = mock(RMContext.class); when(rmContext.getRMApps()).thenReturn( new ConcurrentHashMap<ApplicationId, RMApp>()); ClientRMService rmService = new ClientRMService(rmContext, null, null, null, null, null); ApplicationId applicationId = BuilderUtils.newApplicationId(System.currentTimeMillis(), 0); KillApplicationRequest request = KillApplicationRequest.newInstance(applicationId); try { rmService.forceKillApplication(request); Assert.fail(); } catch (ApplicationNotFoundException ex) { Assert.assertEquals(ex.getMessage(), "Trying to kill an absent " + "application " + request.getApplicationId()); } }
@Override public ApplicationId actionStartAndGetId(String serviceName) throws YarnException, IOException { if (serviceName != null && serviceName.equals("jenkins")) { ApplicationId appId = ApplicationId.newInstance(System.currentTimeMillis(), 1); serviceAppId.put(serviceName, appId); return appId; } else { throw new ApplicationNotFoundException(""); } }
@Test public void testForceKillNonExistingApplication() throws YarnException { RMContext rmContext = mock(RMContext.class); when(rmContext.getRMApps()).thenReturn( new ConcurrentHashMap<ApplicationId, RMApp>()); ClientRMService rmService = new ClientRMService(rmContext, null, null, null, null, null); ApplicationId applicationId = BuilderUtils.newApplicationId(System.currentTimeMillis(), 0); KillApplicationRequest request = KillApplicationRequest.newInstance(applicationId); try { rmService.forceKillApplication(request); Assert.fail(); } catch (ApplicationNotFoundException ex) { Assert.assertEquals(ex.getMessage(), "Trying to kill an absent " + "application " + request.getApplicationId()); } }
private ApplicationReportExt getApplication(ApplicationId appId, ApplicationReportField field) throws YarnException, IOException { TimelineEntity entity = timelineDataManager.getEntity( ApplicationMetricsConstants.ENTITY_TYPE, appId.toString(), EnumSet.allOf(Field.class), UserGroupInformation.getLoginUser()); if (entity == null) { throw new ApplicationNotFoundException("The entity for application " + appId + " doesn't exist in the timeline store"); } else { return generateApplicationReport(entity, field); } }
@Test public void testNonExistingApplicationReport() throws YarnException { RMContext rmContext = mock(RMContext.class); when(rmContext.getRMApps()).thenReturn( new ConcurrentHashMap<ApplicationId, RMApp>()); ClientRMService rmService = new ClientRMService(rmContext, null, null, null, null, null); RecordFactory recordFactory = RecordFactoryProvider.getRecordFactory(null); GetApplicationReportRequest request = recordFactory .newRecordInstance(GetApplicationReportRequest.class); request.setApplicationId(ApplicationId.newInstance(0, 0)); try { rmService.getApplicationReport(request); Assert.fail(); } catch (ApplicationNotFoundException ex) { Assert.assertEquals(ex.getMessage(), "Application with id '" + request.getApplicationId() + "' doesn't exist in RM."); } }
private ApplicationReportExt getApplication(ApplicationId appId, ApplicationReportField field) throws YarnException, IOException { TimelineEntity entity = timelineDataManager.getEntity( ApplicationMetricsConstants.ENTITY_TYPE, appId.toString(), EnumSet.allOf(Field.class), UserGroupInformation.getLoginUser()); if (entity == null) { throw new ApplicationNotFoundException("The entity for application " + appId + " doesn't exist in the timeline store"); } else { return generateApplicationReport(entity, field); } }
@Test public void testNonExistingApplicationReport() throws YarnException { RMContext rmContext = mock(RMContext.class); when(rmContext.getRMApps()).thenReturn( new ConcurrentHashMap<ApplicationId, RMApp>()); ClientRMService rmService = new ClientRMService(rmContext, null, null, null, null, null); RecordFactory recordFactory = RecordFactoryProvider.getRecordFactory(null); GetApplicationReportRequest request = recordFactory .newRecordInstance(GetApplicationReportRequest.class); request.setApplicationId(ApplicationId.newInstance(0, 0)); try { rmService.getApplicationReport(request); Assert.fail(); } catch (ApplicationNotFoundException ex) { Assert.assertEquals(ex.getMessage(), "Application with id '" + request.getApplicationId() + "' doesn't exist in RM. Please check that the " + "job submission was successful."); } }
private ApplicationReportExt getApplication(ApplicationId appId, ApplicationReportField field) throws YarnException, IOException { TimelineEntity entity = timelineDataManager.getEntity( ApplicationMetricsConstants.ENTITY_TYPE, appId.toString(), EnumSet.allOf(Field.class), UserGroupInformation.getLoginUser()); if (entity == null) { throw new ApplicationNotFoundException("The entity for application " + appId + " doesn't exist in the timeline store"); } else { return generateApplicationReport(entity, field); } }
@Test public void testApplicationNotFound() throws IOException, YarnException { ApplicationId appId = null; appId = ApplicationId.newInstance(0, MAX_APPS + 1); GetApplicationReportRequest request = GetApplicationReportRequest.newInstance(appId); try { @SuppressWarnings("unused") GetApplicationReportResponse response = clientService.getApplicationReport(request); Assert.fail("Exception should have been thrown before we reach here."); } catch (ApplicationNotFoundException e) { //This exception is expected. Assert.assertTrue(e.getMessage().contains( "doesn't exist in the timeline store")); } catch (Exception e) { Assert.fail("Undesired exception caught"); } }
private ResourceMgrDelegate getRMDelegate() throws IOException { ResourceMgrDelegate rm = mock(ResourceMgrDelegate.class); try { ApplicationId appId = jobId.getAppId(); when(rm.getApplicationReport(appId)). thenThrow(new ApplicationNotFoundException(appId + " not found")); } catch (YarnException e) { throw new IOException(e); } return rm; }
fail("Should get an exception here"); } catch (ApplicationNotFoundException ex) { Assert.assertTrue(ex.getMessage().contains( "Trying to kill an absent application " + app0.getApplicationId()));
throw new ApplicationNotFoundException("Application with id '" + appId + "' doesn't exist in RM.");
fail("Should get an exception here"); } catch (ApplicationNotFoundException ex) { Assert.assertTrue(ex.getMessage().contains( "Trying to kill an absent application " + app0.getApplicationId()));
throw new ApplicationNotFoundException("Application with id '" + appId + "' doesn't exist in RM.");
@Test public void testGetApplicationAttempts() throws YarnException, IOException { ClientRMService rmService = createRMService(); RecordFactory recordFactory = RecordFactoryProvider.getRecordFactory(null); GetApplicationAttemptsRequest request = recordFactory .newRecordInstance(GetApplicationAttemptsRequest.class); ApplicationAttemptId attemptId = ApplicationAttemptId.newInstance( ApplicationId.newInstance(123456, 1), 1); request.setApplicationId(ApplicationId.newInstance(123456, 1)); try { GetApplicationAttemptsResponse response = rmService .getApplicationAttempts(request); Assert.assertEquals(1, response.getApplicationAttemptList().size()); Assert.assertEquals(attemptId, response.getApplicationAttemptList() .get(0).getApplicationAttemptId()); } catch (ApplicationNotFoundException ex) { Assert.fail(ex.getMessage()); } }
ApplicationId applicationId = request.getApplicationId(); if (applicationId == null) { throw new ApplicationNotFoundException("Invalid application id: null"); throw new ApplicationNotFoundException("Application with id '" + applicationId + "' doesn't exist in RM. Please check " + "that the job submission was successful.");