@Test public void testMoveRejectedByScheduler() throws Exception { failMove = true; // Submit application Application application = new Application("user1", resourceManager); application.submit(); // Wait for app to be accepted RMApp app = resourceManager.rmContext.getRMApps() .get(application.getApplicationId()); while (app.getState() != RMAppState.ACCEPTED) { Thread.sleep(100); } ClientRMService clientRMService = resourceManager.getClientRMService(); try { // FIFO scheduler does not support moves clientRMService.moveApplicationAcrossQueues( MoveApplicationAcrossQueuesRequest.newInstance( application.getApplicationId(), "newqueue")); fail("Should have hit exception"); } catch (YarnException ex) { assertEquals("Move not supported", ex.getCause().getMessage()); } }
@Test (timeout = 10000) public void testMoveSuccessful() throws Exception { MockRM rm1 = new MockRM(conf); rm1.start(); RMApp app = rm1.submitApp(1024); ClientRMService clientRMService = rm1.getClientRMService(); // FIFO scheduler does not support moves clientRMService .moveApplicationAcrossQueues(MoveApplicationAcrossQueuesRequest .newInstance(app.getApplicationId(), "newqueue")); RMApp rmApp = rm1.getRMContext().getRMApps().get(app.getApplicationId()); assertEquals("newqueue", rmApp.getQueue()); rm1.stop(); }
@Test public void testMoveRejectedByPermissions() throws Exception { failMove = true; // Submit application final Application application = new Application("user1", resourceManager); application.submit(); final ClientRMService clientRMService = resourceManager.getClientRMService(); try { UserGroupInformation.createRemoteUser("otheruser").doAs( new PrivilegedExceptionAction<MoveApplicationAcrossQueuesResponse>() { @Override public MoveApplicationAcrossQueuesResponse run() throws Exception { return clientRMService.moveApplicationAcrossQueues( MoveApplicationAcrossQueuesRequest.newInstance( application.getApplicationId(), "newqueue")); } }); fail("Should have hit exception"); } catch (Exception ex) { assertEquals(AccessControlException.class, ex.getCause().getCause().getClass()); } }
@Test public void testMoveRejectedByScheduler() throws Exception { failMove = true; // Submit application Application application = new Application("user1", resourceManager); application.submit(); ClientRMService clientRMService = resourceManager.getClientRMService(); try { // FIFO scheduler does not support moves clientRMService.moveApplicationAcrossQueues( MoveApplicationAcrossQueuesRequest.newInstance( application.getApplicationId(), "newqueue")); fail("Should have hit exception"); } catch (YarnException ex) { assertEquals("Move not supported", ex.getCause().getMessage()); } }
@Test (timeout = 5000) public void testMoveSuccessful() throws Exception { // Submit application Application application = new Application("user1", resourceManager); ApplicationId appId = application.getApplicationId(); application.submit(); // Wait for app to be accepted RMApp app = resourceManager.rmContext.getRMApps().get(appId); while (app.getState() != RMAppState.ACCEPTED) { Thread.sleep(100); } ClientRMService clientRMService = resourceManager.getClientRMService(); // FIFO scheduler does not support moves clientRMService.moveApplicationAcrossQueues( MoveApplicationAcrossQueuesRequest.newInstance(appId, "newqueue")); RMApp rmApp = resourceManager.getRMContext().getRMApps().get(appId); assertEquals("newqueue", rmApp.getQueue()); }
@Override public MoveApplicationAcrossQueuesResponse moveApplicationAcrossQueues( MoveApplicationAcrossQueuesRequest request) throws YarnException, IOException { MoveApplicationAcrossQueuesRequestProto requestProto = ((MoveApplicationAcrossQueuesRequestPBImpl) request).getProto(); try { return new MoveApplicationAcrossQueuesResponsePBImpl( proxy.moveApplicationAcrossQueues(null, requestProto)); } catch (ServiceException e) { RPCUtil.unwrapAndThrowException(e); return null; } }
@Test (timeout = 10000) public void testMoveTooLate() throws Exception { // Submit application Application application = new Application("user1", resourceManager); ApplicationId appId = application.getApplicationId(); application.submit(); ClientRMService clientRMService = resourceManager.getClientRMService(); // Kill the application clientRMService.forceKillApplication( KillApplicationRequest.newInstance(appId)); RMApp rmApp = resourceManager.getRMContext().getRMApps().get(appId); // wait until it's dead while (rmApp.getState() != RMAppState.KILLED) { Thread.sleep(100); } try { clientRMService.moveApplicationAcrossQueues( MoveApplicationAcrossQueuesRequest.newInstance(appId, "newqueue")); fail("Should have hit exception"); } catch (YarnException ex) { assertEquals(YarnException.class, ex.getClass()); assertEquals("App in KILLED state cannot be moved.", ex.getMessage()); } }
@Test (expected = ApplicationNotFoundException.class) public void testMoveAbsentApplication() 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); MoveApplicationAcrossQueuesRequest request = MoveApplicationAcrossQueuesRequest.newInstance(applicationId, "newqueue"); rmService.moveApplicationAcrossQueues(request); }
@Override public void moveApplicationAcrossQueues(ApplicationId appId, String queue) throws YarnException, IOException { MoveApplicationAcrossQueuesRequest request = MoveApplicationAcrossQueuesRequest.newInstance(appId, queue); rmClient.moveApplicationAcrossQueues(request); }
@Override public MoveApplicationAcrossQueuesResponse moveApplicationAcrossQueues( MoveApplicationAcrossQueuesRequest request) throws YarnException { resetStartFailoverFlag(true); // make sure failover has been triggered Assert.assertTrue(waittingForFailOver()); return Records.newRecord(MoveApplicationAcrossQueuesResponse.class); }
@Override public MoveApplicationAcrossQueuesResponse moveApplicationAcrossQueues( MoveApplicationAcrossQueuesRequest request) throws YarnException, IOException { return RecordFactoryProvider.getRecordFactory(null).newRecordInstance( MoveApplicationAcrossQueuesResponse.class); }