org.apache.hadoop.yarn.event.AbstractEvent Java Examples
The following examples show how to use
org.apache.hadoop.yarn.event.AbstractEvent.
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: TestRM.java From hadoop with Apache License 2.0 | 4 votes |
/** * Validate killing an application when it is at accepted state. * @throws Exception exception */ @Test (timeout = 60000) public void testApplicationKillAtAcceptedState() throws Exception { final Dispatcher dispatcher = new AsyncDispatcher() { @Override public EventHandler getEventHandler() { class EventArgMatcher extends ArgumentMatcher<AbstractEvent> { @Override public boolean matches(Object argument) { if (argument instanceof RMAppAttemptEvent) { if (((RMAppAttemptEvent) argument).getType().equals( RMAppAttemptEventType.KILL)) { return true; } } return false; } } EventHandler handler = spy(super.getEventHandler()); doNothing().when(handler).handle(argThat(new EventArgMatcher())); return handler; } }; MockRM rm = new MockRM(conf) { @Override protected Dispatcher createDispatcher() { return dispatcher; } }; // test metrics QueueMetrics metrics = rm.getResourceScheduler().getRootQueueMetrics(); int appsKilled = metrics.getAppsKilled(); int appsSubmitted = metrics.getAppsSubmitted(); rm.start(); MockNM nm1 = new MockNM("127.0.0.1:1234", 15120, rm.getResourceTrackerService()); nm1.registerNode(); // a failed app RMApp application = rm.submitApp(200); MockAM am = MockRM.launchAM(application, rm, nm1); am.waitForState(RMAppAttemptState.LAUNCHED); nm1.nodeHeartbeat(am.getApplicationAttemptId(), 1, ContainerState.RUNNING); rm.waitForState(application.getApplicationId(), RMAppState.ACCEPTED); // Now kill the application before new attempt is launched, the app report // returns the invalid AM host and port. KillApplicationRequest request = KillApplicationRequest.newInstance(application.getApplicationId()); rm.getClientRMService().forceKillApplication(request); // Specific test for YARN-1689 follows // Now let's say a race causes AM to register now. This should not crash RM. am.registerAppAttempt(false); // We explicitly intercepted the kill-event to RMAppAttempt, so app should // still be in KILLING state. rm.waitForState(application.getApplicationId(), RMAppState.KILLING); // AM should now be in running rm.waitForState(am.getApplicationAttemptId(), RMAppAttemptState.RUNNING); // Simulate that appAttempt is killed. rm.getRMContext().getDispatcher().getEventHandler().handle( new RMAppEvent(application.getApplicationId(), RMAppEventType.ATTEMPT_KILLED)); rm.waitForState(application.getApplicationId(), RMAppState.KILLED); // test metrics metrics = rm.getResourceScheduler().getRootQueueMetrics(); Assert.assertEquals(appsKilled + 1, metrics.getAppsKilled()); Assert.assertEquals(appsSubmitted + 1, metrics.getAppsSubmitted()); }
Example #2
Source File: TestRM.java From hadoop with Apache License 2.0 | 4 votes |
@Test (timeout = 30000) public void testKillFinishingApp() throws Exception{ // this dispatcher ignores RMAppAttemptEventType.KILL event final Dispatcher dispatcher = new AsyncDispatcher() { @Override public EventHandler getEventHandler() { class EventArgMatcher extends ArgumentMatcher<AbstractEvent> { @Override public boolean matches(Object argument) { if (argument instanceof RMAppAttemptEvent) { if (((RMAppAttemptEvent) argument).getType().equals( RMAppAttemptEventType.KILL)) { return true; } } return false; } } EventHandler handler = spy(super.getEventHandler()); doNothing().when(handler).handle(argThat(new EventArgMatcher())); return handler; } }; MockRM rm1 = new MockRM(conf){ @Override protected Dispatcher createDispatcher() { return dispatcher; } }; rm1.start(); MockNM nm1 = new MockNM("127.0.0.1:1234", 8192, rm1.getResourceTrackerService()); nm1.registerNode(); RMApp app1 = rm1.submitApp(200); MockAM am1 = MockRM.launchAndRegisterAM(app1, rm1, nm1); rm1.killApp(app1.getApplicationId()); FinishApplicationMasterRequest req = FinishApplicationMasterRequest.newInstance( FinalApplicationStatus.SUCCEEDED, "", ""); am1.unregisterAppAttempt(req,true); rm1.waitForState(am1.getApplicationAttemptId(), RMAppAttemptState.FINISHING); nm1.nodeHeartbeat(am1.getApplicationAttemptId(), 1, ContainerState.COMPLETE); rm1.waitForState(am1.getApplicationAttemptId(), RMAppAttemptState.FINISHED); rm1.waitForState(app1.getApplicationId(), RMAppState.FINISHED); }
Example #3
Source File: TestRM.java From hadoop with Apache License 2.0 | 4 votes |
@Test (timeout = 30000) public void testKillFailingApp() throws Exception{ // this dispatcher ignores RMAppAttemptEventType.KILL event final Dispatcher dispatcher = new AsyncDispatcher() { @Override public EventHandler getEventHandler() { class EventArgMatcher extends ArgumentMatcher<AbstractEvent> { @Override public boolean matches(Object argument) { if (argument instanceof RMAppAttemptEvent) { if (((RMAppAttemptEvent) argument).getType().equals( RMAppAttemptEventType.KILL)) { return true; } } return false; } } EventHandler handler = spy(super.getEventHandler()); doNothing().when(handler).handle(argThat(new EventArgMatcher())); return handler; } }; MockRM rm1 = new MockRM(conf){ @Override protected Dispatcher createDispatcher() { return dispatcher; } }; rm1.start(); MockNM nm1 = new MockNM("127.0.0.1:1234", 8192, rm1.getResourceTrackerService()); nm1.registerNode(); RMApp app1 = rm1.submitApp(200); MockAM am1 = MockRM.launchAndRegisterAM(app1, rm1, nm1); rm1.killApp(app1.getApplicationId()); // fail the app by sending container_finished event. nm1.nodeHeartbeat(am1.getApplicationAttemptId(), 1, ContainerState.COMPLETE); rm1.waitForState(am1.getApplicationAttemptId(), RMAppAttemptState.FAILED); // app is killed, not launching a new attempt rm1.waitForState(app1.getApplicationId(), RMAppState.KILLED); }
Example #4
Source File: TestRM.java From big-c with Apache License 2.0 | 4 votes |
/** * Validate killing an application when it is at accepted state. * @throws Exception exception */ @Test (timeout = 60000) public void testApplicationKillAtAcceptedState() throws Exception { final Dispatcher dispatcher = new AsyncDispatcher() { @Override public EventHandler getEventHandler() { class EventArgMatcher extends ArgumentMatcher<AbstractEvent> { @Override public boolean matches(Object argument) { if (argument instanceof RMAppAttemptEvent) { if (((RMAppAttemptEvent) argument).getType().equals( RMAppAttemptEventType.KILL)) { return true; } } return false; } } EventHandler handler = spy(super.getEventHandler()); doNothing().when(handler).handle(argThat(new EventArgMatcher())); return handler; } }; MockRM rm = new MockRM(conf) { @Override protected Dispatcher createDispatcher() { return dispatcher; } }; // test metrics QueueMetrics metrics = rm.getResourceScheduler().getRootQueueMetrics(); int appsKilled = metrics.getAppsKilled(); int appsSubmitted = metrics.getAppsSubmitted(); rm.start(); MockNM nm1 = new MockNM("127.0.0.1:1234", 15120, rm.getResourceTrackerService()); nm1.registerNode(); // a failed app RMApp application = rm.submitApp(200); MockAM am = MockRM.launchAM(application, rm, nm1); am.waitForState(RMAppAttemptState.LAUNCHED); nm1.nodeHeartbeat(am.getApplicationAttemptId(), 1, ContainerState.RUNNING); rm.waitForState(application.getApplicationId(), RMAppState.ACCEPTED); // Now kill the application before new attempt is launched, the app report // returns the invalid AM host and port. KillApplicationRequest request = KillApplicationRequest.newInstance(application.getApplicationId()); rm.getClientRMService().forceKillApplication(request); // Specific test for YARN-1689 follows // Now let's say a race causes AM to register now. This should not crash RM. am.registerAppAttempt(false); // We explicitly intercepted the kill-event to RMAppAttempt, so app should // still be in KILLING state. rm.waitForState(application.getApplicationId(), RMAppState.KILLING); // AM should now be in running rm.waitForState(am.getApplicationAttemptId(), RMAppAttemptState.RUNNING); // Simulate that appAttempt is killed. rm.getRMContext().getDispatcher().getEventHandler().handle( new RMAppEvent(application.getApplicationId(), RMAppEventType.ATTEMPT_KILLED)); rm.waitForState(application.getApplicationId(), RMAppState.KILLED); // test metrics metrics = rm.getResourceScheduler().getRootQueueMetrics(); Assert.assertEquals(appsKilled + 1, metrics.getAppsKilled()); Assert.assertEquals(appsSubmitted + 1, metrics.getAppsSubmitted()); }
Example #5
Source File: TestRM.java From big-c with Apache License 2.0 | 4 votes |
@Test (timeout = 30000) public void testKillFinishingApp() throws Exception{ // this dispatcher ignores RMAppAttemptEventType.KILL event final Dispatcher dispatcher = new AsyncDispatcher() { @Override public EventHandler getEventHandler() { class EventArgMatcher extends ArgumentMatcher<AbstractEvent> { @Override public boolean matches(Object argument) { if (argument instanceof RMAppAttemptEvent) { if (((RMAppAttemptEvent) argument).getType().equals( RMAppAttemptEventType.KILL)) { return true; } } return false; } } EventHandler handler = spy(super.getEventHandler()); doNothing().when(handler).handle(argThat(new EventArgMatcher())); return handler; } }; MockRM rm1 = new MockRM(conf){ @Override protected Dispatcher createDispatcher() { return dispatcher; } }; rm1.start(); MockNM nm1 = new MockNM("127.0.0.1:1234", 8192, rm1.getResourceTrackerService()); nm1.registerNode(); RMApp app1 = rm1.submitApp(200); MockAM am1 = MockRM.launchAndRegisterAM(app1, rm1, nm1); rm1.killApp(app1.getApplicationId()); FinishApplicationMasterRequest req = FinishApplicationMasterRequest.newInstance( FinalApplicationStatus.SUCCEEDED, "", ""); am1.unregisterAppAttempt(req,true); rm1.waitForState(am1.getApplicationAttemptId(), RMAppAttemptState.FINISHING); nm1.nodeHeartbeat(am1.getApplicationAttemptId(), 1, ContainerState.COMPLETE); rm1.waitForState(am1.getApplicationAttemptId(), RMAppAttemptState.FINISHED); rm1.waitForState(app1.getApplicationId(), RMAppState.FINISHED); }
Example #6
Source File: TestRM.java From big-c with Apache License 2.0 | 4 votes |
@Test (timeout = 30000) public void testKillFailingApp() throws Exception{ // this dispatcher ignores RMAppAttemptEventType.KILL event final Dispatcher dispatcher = new AsyncDispatcher() { @Override public EventHandler getEventHandler() { class EventArgMatcher extends ArgumentMatcher<AbstractEvent> { @Override public boolean matches(Object argument) { if (argument instanceof RMAppAttemptEvent) { if (((RMAppAttemptEvent) argument).getType().equals( RMAppAttemptEventType.KILL)) { return true; } } return false; } } EventHandler handler = spy(super.getEventHandler()); doNothing().when(handler).handle(argThat(new EventArgMatcher())); return handler; } }; MockRM rm1 = new MockRM(conf){ @Override protected Dispatcher createDispatcher() { return dispatcher; } }; rm1.start(); MockNM nm1 = new MockNM("127.0.0.1:1234", 8192, rm1.getResourceTrackerService()); nm1.registerNode(); RMApp app1 = rm1.submitApp(200); MockAM am1 = MockRM.launchAndRegisterAM(app1, rm1, nm1); rm1.killApp(app1.getApplicationId()); // fail the app by sending container_finished event. nm1.nodeHeartbeat(am1.getApplicationAttemptId(), 1, ContainerState.COMPLETE); rm1.waitForState(am1.getApplicationAttemptId(), RMAppAttemptState.FAILED); // app is killed, not launching a new attempt rm1.waitForState(app1.getApplicationId(), RMAppState.KILLED); }