public GetNewApplicationResponse getNewAppId() throws Exception { ApplicationClientProtocol client = getClientRMService(); return client.getNewApplication(Records .newRecord(GetNewApplicationRequest.class)); }
public GetNewApplicationResponse getNewAppId() throws Exception { ApplicationClientProtocol client = getClientRMService(); return client.getNewApplication(Records .newRecord(GetNewApplicationRequest.class)); }
public void updateReservationState(ReservationUpdateRequest request) throws IOException, YarnException { ApplicationClientProtocol client = getClientRMService(); client.updateReservation(request); drainEventsImplicitly(); }
public KillApplicationResponse killApp(ApplicationId appId) throws Exception { ApplicationClientProtocol client = getClientRMService(); KillApplicationRequest req = KillApplicationRequest.newInstance(appId); return client.forceKillApplication(req); }
public FailApplicationAttemptResponse failApplicationAttempt( ApplicationAttemptId attemptId) throws Exception { ApplicationClientProtocol client = getClientRMService(); FailApplicationAttemptRequest req = FailApplicationAttemptRequest.newInstance(attemptId); FailApplicationAttemptResponse response = client.failApplicationAttempt(req); drainEventsImplicitly(); return response; }
public void signalToContainer(ContainerId containerId, SignalContainerCommand command) throws Exception { ApplicationClientProtocol client = getClientRMService(); SignalContainerRequest req = SignalContainerRequest.newInstance(containerId, command); client.signalToContainer(req); drainEventsImplicitly(); }
public KillApplicationResponse killApp(ApplicationId appId) throws Exception { ApplicationClientProtocol client = getClientRMService(); KillApplicationRequest req = KillApplicationRequest.newInstance(appId); KillApplicationResponse response = client.forceKillApplication(req); drainEventsImplicitly(); return response; }
public ApplicationReport getApplicationReport(ApplicationId appId) throws YarnException, IOException { ApplicationClientProtocol client = getClientRMService(); GetApplicationReportResponse response = client.getApplicationReport(GetApplicationReportRequest .newInstance(appId)); return response.getApplicationReport(); }
public ApplicationReport getApplicationReport(ApplicationId appId) throws YarnException, IOException { ApplicationClientProtocol client = getClientRMService(); GetApplicationReportResponse response = client.getApplicationReport(GetApplicationReportRequest .newInstance(appId)); return response.getApplicationReport(); }
@Test public void testRMStartWithDecommissionedNode() throws Exception { String excludeFile = "excludeFile"; createExcludeFile(excludeFile); YarnConfiguration conf = new YarnConfiguration(); conf.set(YarnConfiguration.RM_NODES_EXCLUDE_FILE_PATH, excludeFile); MockRM rm = new MockRM(conf) { protected ClientRMService createClientRMService() { return new ClientRMService(this.rmContext, scheduler, this.rmAppManager, this.applicationACLsManager, this.queueACLsManager, this.getRMContext().getRMDelegationTokenSecretManager()); }; }; rm.start(); YarnRPC rpc = YarnRPC.create(conf); InetSocketAddress rmAddress = rm.getClientRMService().getBindAddress(); LOG.info("Connecting to ResourceManager at " + rmAddress); ApplicationClientProtocol client = (ApplicationClientProtocol) rpc .getProxy(ApplicationClientProtocol.class, rmAddress, conf); // Make call GetClusterNodesRequest request = GetClusterNodesRequest.newInstance(EnumSet.allOf(NodeState.class)); List<NodeReport> nodeReports = client.getClusterNodes(request).getNodeReports(); Assert.assertEquals(1, nodeReports.size()); rm.stop(); rpc.stopProxy(client, conf); new File(excludeFile).delete(); }
@Test public void testSubmitReservationAndCheckAfterFailover() throws Exception { startRMs(); addNodeCapacityToPlan(rm1, 102400, 100); ClientRMService clientService = rm1.getClientRMService(); ReservationId reservationID = getNewReservation(clientService) .getReservationId(); // create a reservation ReservationSubmissionRequest request = createReservationSubmissionRequest( reservationID); ReservationSubmissionResponse response = null; try { response = clientService.submitReservation(request); } catch (Exception e) { Assert.fail(e.getMessage()); } Assert.assertNotNull(response); Assert.assertNotNull(reservationID); LOG.info("Submit reservation response: " + reservationID); // Do the failover explicitFailover(); rm2.registerNode("127.0.0.1:1", 102400, 100); RMState state = rm2.getRMContext().getStateStore().loadState(); Map<ReservationId, ReservationAllocationStateProto> reservationStateMap = state.getReservationState().get(ReservationSystemTestUtil.reservationQ); Assert.assertNotNull(reservationStateMap); Assert.assertNotNull(reservationStateMap.get(reservationID)); }
@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 (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(timeout = 120000) public void testUpdatePriorityAndKillAppWithZeroClusterResource() throws Exception { int maxPriority = 10; int appPriority = 5; YarnConfiguration conf = new YarnConfiguration(); Assume.assumeFalse("FairScheduler does not support Application Priorities", conf.get(YarnConfiguration.RM_SCHEDULER) .equals(FairScheduler.class.getName())); conf.setInt(YarnConfiguration.MAX_CLUSTER_LEVEL_APPLICATION_PRIORITY, maxPriority); MockRM rm = new MockRM(conf); rm.init(conf); rm.start(); RMApp app1 = rm.submitApp(1024, Priority.newInstance(appPriority)); ClientRMService rmService = rm.getClientRMService(); testApplicationPriorityUpdation(rmService, app1, appPriority, appPriority); rm.killApp(app1.getApplicationId()); rm.waitForState(app1.getApplicationId(), RMAppState.KILLED); rm.stop(); }
@Test public void testDeleteReservationAndCheckAfterFailover() throws Exception { startRMs(); addNodeCapacityToPlan(rm1, 102400, 100); ClientRMService clientService = rm1.getClientRMService(); ReservationId reservationID = getNewReservation(clientService) .getReservationId(); // create a reservation ReservationSubmissionRequest request = createReservationSubmissionRequest( reservationID); ReservationSubmissionResponse response = null; try { response = clientService.submitReservation(request); } catch (Exception e) { Assert.fail(e.getMessage()); } Assert.assertNotNull(response); Assert.assertNotNull(reservationID); // Delete the reservation ReservationDeleteRequest deleteRequest = ReservationDeleteRequest.newInstance(reservationID); clientService.deleteReservation(deleteRequest); // Do the failover explicitFailover(); rm2.registerNode("127.0.0.1:1", 102400, 100); RMState state = rm2.getRMContext().getStateStore().loadState(); Assert.assertNull(state.getReservationState() .get(ReservationSystemTestUtil.reservationQ)); }
@Test(timeout = 60000) public void testUnManagedRMRestart() throws Exception { // Create RM MockRM rm1 = createMockRM(conf); MemoryRMStateStore memStore = (MemoryRMStateStore) rm1.getRMStateStore(); rm1.start(); // create app and launch the AM RMApp app0 = rm1.submitApp(null, "name", "user", new HashMap<>(), true, "default"); rm1.killApp(app0.getApplicationId()); rm1.waitForState(app0.getApplicationId(), RMAppState.KILLED); // start new RM MockRM rm2 = createMockRM(conf, memStore); rm2.start(); Assert.assertEquals(1, rm2.getRMContext().getRMApps().size()); ApplicationReport appReport = rm2.getClientRMService().getApplicationReport( GetApplicationReportRequest.newInstance(app0.getApplicationId())) .getApplicationReport(); Assert.assertEquals(true, appReport.isUnmanagedApp()); rm1.stop(); rm2.stop(); }
private ApplicationReport verifyAppReportAfterRMRestart(RMApp app, MockRM rm) throws Exception { GetApplicationReportRequest reportRequest = GetApplicationReportRequest.newInstance(app.getApplicationId()); GetApplicationReportResponse response = rm.getClientRMService().getApplicationReport(reportRequest); ApplicationReport report = response.getApplicationReport(); Assert.assertEquals(app.getStartTime(), report.getStartTime()); Assert.assertEquals(app.getFinishTime(), report.getFinishTime()); Assert.assertEquals(app.createApplicationState(), report.getYarnApplicationState()); Assert.assertTrue(1 == report.getProgress()); return response.getApplicationReport(); }
private ApplicationReport verifyAppReportAfterRMRestart(RMApp app, MockRM rm) throws Exception { GetApplicationReportRequest reportRequest = GetApplicationReportRequest.newInstance(app.getApplicationId()); GetApplicationReportResponse response = rm.getClientRMService().getApplicationReport(reportRequest); ApplicationReport report = response.getApplicationReport(); Assert.assertEquals(app.getStartTime(), report.getStartTime()); Assert.assertEquals(app.getFinishTime(), report.getFinishTime()); Assert.assertEquals(app.createApplicationState(), report.getYarnApplicationState()); Assert.assertTrue(1 == report.getProgress()); return response.getApplicationReport(); }
@Test (timeout = 60000) public void testInvalidatedAMHostPortOnAMRestart() throws Exception { MockRM rm1 = new MockRM(conf); rm1.start(); MockNM nm1 = new MockNM("127.0.0.1:1234", 15120, rm1.getResourceTrackerService()); nm1.registerNode(); // a failed app RMApp app2 = rm1.submitApp(200); MockAM am2 = MockRM.launchAndRegisterAM(app2, rm1, nm1); nm1 .nodeHeartbeat(am2.getApplicationAttemptId(), 1, ContainerState.COMPLETE); am2.waitForState(RMAppAttemptState.FAILED); rm1.waitForState(app2.getApplicationId(), RMAppState.ACCEPTED); // before new attempt is launched, the app report returns the invalid AM // host and port. GetApplicationReportRequest request1 = GetApplicationReportRequest.newInstance(app2.getApplicationId()); ApplicationReport report1 = rm1.getClientRMService().getApplicationReport(request1) .getApplicationReport(); Assert.assertEquals("N/A", report1.getHost()); Assert.assertEquals(-1, report1.getRpcPort()); }
@Test (timeout = 60000) public void testInvalidatedAMHostPortOnAMRestart() throws Exception { MockRM rm1 = new MockRM(conf); rm1.start(); MockNM nm1 = new MockNM("127.0.0.1:1234", 15120, rm1.getResourceTrackerService()); nm1.registerNode(); // a failed app RMApp app2 = rm1.submitApp(200); MockAM am2 = MockRM.launchAndRegisterAM(app2, rm1, nm1); nm1 .nodeHeartbeat(am2.getApplicationAttemptId(), 1, ContainerState.COMPLETE); rm1.waitForState(am2.getApplicationAttemptId(), RMAppAttemptState.FAILED); rm1.waitForState(app2.getApplicationId(), RMAppState.ACCEPTED); // before new attempt is launched, the app report returns the invalid AM // host and port. GetApplicationReportRequest request1 = GetApplicationReportRequest.newInstance(app2.getApplicationId()); ApplicationReport report1 = rm1.getClientRMService().getApplicationReport(request1) .getApplicationReport(); Assert.assertEquals("N/A", report1.getHost()); Assert.assertEquals(-1, report1.getRpcPort()); }