@Override protected AsyncDispatcher createDispatcher() { dispatcher = new DrainDispatcher(); return dispatcher; }
@Override protected Dispatcher createDispatcher() { return new DrainDispatcher(); } protected ContainerAllocator createContainerAllocator(
@Override protected Dispatcher createDispatcher() { return new DrainDispatcher(); } protected ContainerAllocator createContainerAllocator(
@Override protected Dispatcher createDispatcher() { return new DrainDispatcher(); }
@Override protected Dispatcher createDispatcher() { return new DrainDispatcher(); }
@Override protected Dispatcher createDispatcher() { return new DrainDispatcher(); }
private void startRM(final YarnConfiguration conf) { dispatcher = new DrainDispatcher(); rm = new MockRM(conf) { @Override protected Dispatcher createDispatcher() { return dispatcher; } }; rm.start(); }
private void startRM(final YarnConfiguration conf) { dispatcher = new DrainDispatcher(); rm = new MockRM(conf) { @Override protected Dispatcher createDispatcher() { return dispatcher; } }; rm.start(); }
@Test(timeout=10000) public void testDispatchStopOnTimeout() throws Exception { BlockingQueue<Event> eventQueue = new LinkedBlockingQueue<Event>(); eventQueue = spy(eventQueue); // simulate dispatcher is not drained. when(eventQueue.isEmpty()).thenReturn(false); YarnConfiguration conf = new YarnConfiguration(); conf.setInt(YarnConfiguration.DISPATCHER_DRAIN_EVENTS_TIMEOUT, 2000); DrainDispatcher disp = new DrainDispatcher(eventQueue); disp.init(conf); disp.setDrainEventsOnStop(); disp.start(); disp.waitForEventThreadToWait(); disp.close(); }
@Test(timeout=10000) public void testDispatchStopOnTimeout() throws Exception { BlockingQueue<Event> eventQueue = new LinkedBlockingQueue<Event>(); eventQueue = spy(eventQueue); // simulate dispatcher is not drained. when(eventQueue.isEmpty()).thenReturn(false); YarnConfiguration conf = new YarnConfiguration(); conf.setInt(YarnConfiguration.DISPATCHER_DRAIN_EVENTS_TIMEOUT, 2000); DrainDispatcher disp = new DrainDispatcher(eventQueue); disp.init(conf); disp.setDrainEventsOnStop(); disp.start(); disp.waitForEventThreadToWait(); disp.close(); } }
@Test(timeout=10000) public void testDispatchStopOnTimeout() throws Exception { BlockingQueue<Event> eventQueue = new LinkedBlockingQueue<Event>(); eventQueue = spy(eventQueue); // simulate dispatcher is not drained. when(eventQueue.isEmpty()).thenReturn(false); YarnConfiguration conf = new YarnConfiguration(); conf.setInt(YarnConfiguration.DISPATCHER_DRAIN_EVENTS_TIMEOUT, 2000); DrainDispatcher disp = new DrainDispatcher(eventQueue); disp.init(conf); disp.setDrainEventsOnStop(); disp.start(); disp.waitForEventThreadToWait(); disp.close(); } }
@SuppressWarnings({ "unchecked", "rawtypes" }) @Test(timeout=10000) public void testDispatcherOnCloseIfQueueEmpty() throws Exception { BlockingQueue<Event> eventQueue = spy(new LinkedBlockingQueue<Event>()); Event event = mock(Event.class); doThrow(new InterruptedException()).when(eventQueue).put(event); DrainDispatcher disp = new DrainDispatcher(eventQueue); disp.init(new Configuration()); disp.setDrainEventsOnStop(); disp.start(); // Wait for event handler thread to start and begin waiting for events. disp.waitForEventThreadToWait(); try { disp.getEventHandler().handle(event); Assert.fail("Expected YarnRuntimeException"); } catch (YarnRuntimeException e) { Assert.assertTrue(e.getCause() instanceof InterruptedException); } // Queue should be empty and dispatcher should not hang on close Assert.assertTrue("Event Queue should have been empty", eventQueue.isEmpty()); disp.close(); }
@SuppressWarnings({ "unchecked", "rawtypes" }) @Test(timeout=10000) public void testDispatcherOnCloseIfQueueEmpty() throws Exception { BlockingQueue<Event> eventQueue = spy(new LinkedBlockingQueue<Event>()); Event event = mock(Event.class); doThrow(new InterruptedException()).when(eventQueue).put(event); DrainDispatcher disp = new DrainDispatcher(eventQueue); disp.init(new Configuration()); disp.setDrainEventsOnStop(); disp.start(); // Wait for event handler thread to start and begin waiting for events. disp.waitForEventThreadToWait(); try { disp.getEventHandler().handle(event); Assert.fail("Expected YarnRuntimeException"); } catch (YarnRuntimeException e) { Assert.assertTrue(e.getCause() instanceof InterruptedException); } // Queue should be empty and dispatcher should not hang on close Assert.assertTrue("Event Queue should have been empty", eventQueue.isEmpty()); disp.close(); }
@SuppressWarnings({ "unchecked", "rawtypes" }) @Test(timeout=10000) public void testDispatcherOnCloseIfQueueEmpty() throws Exception { BlockingQueue<Event> eventQueue = spy(new LinkedBlockingQueue<Event>()); Event event = mock(Event.class); doThrow(new InterruptedException()).when(eventQueue).put(event); DrainDispatcher disp = new DrainDispatcher(eventQueue); disp.init(new Configuration()); disp.setDrainEventsOnStop(); disp.start(); // Wait for event handler thread to start and begin waiting for events. disp.waitForEventThreadToWait(); try { disp.getEventHandler().handle(event); Assert.fail("Expected YarnRuntimeException"); } catch (YarnRuntimeException e) { Assert.assertTrue(e.getCause() instanceof InterruptedException); } // Queue should be empty and dispatcher should not hang on close Assert.assertTrue("Event Queue should have been empty", eventQueue.isEmpty()); disp.close(); }
@Before public void setUp() { dispatcher = new DrainDispatcher(); this.rm = new MockRM() { @Override public void init(Configuration conf) { conf.set( CapacitySchedulerConfiguration.MAXIMUM_APPLICATION_MASTERS_RESOURCE_PERCENT, "1.0"); super.init(conf); } @Override protected EventHandler<SchedulerEvent> createSchedulerEventDispatcher() { return new SchedulerEventDispatcher(this.scheduler) { @Override public void handle(SchedulerEvent event) { scheduler.handle(event); } }; } @Override protected Dispatcher createDispatcher() { return dispatcher; } }; rm.start(); amService = rm.getApplicationMasterService(); }
conf.set(MRJobConfig.MR_AM_COMMITTER_CANCEL_TIMEOUT_MS, "1000"); DrainDispatcher dispatcher = new DrainDispatcher(); dispatcher.init(conf); dispatcher.start();
@SuppressWarnings({ "rawtypes" }) @Test(timeout=10000) public void testDrainDispatcherDrainEventsOnStop() throws Exception { YarnConfiguration conf = new YarnConfiguration(); conf.setInt(YarnConfiguration.DISPATCHER_DRAIN_EVENTS_TIMEOUT, 2000); BlockingQueue<Event> queue = new LinkedBlockingQueue<Event>(); DrainDispatcher disp = new DrainDispatcher(queue); disp.init(conf); disp.register(DummyType.class, new DummyHandler()); disp.setDrainEventsOnStop(); disp.start(); disp.waitForEventThreadToWait(); dispatchDummyEvents(disp, 2); disp.close(); assertEquals(0, queue.size()); } }
UserGroupInformation.setConfiguration(conf); rmDispatcher = new DrainDispatcher(); ContainerAllocationExpirer containerAllocationExpirer = mock(ContainerAllocationExpirer.class);
final DrainDispatcher dispatcher = new DrainDispatcher(); MockRM rm1 = new MockRM(conf, memStore) { @Override final DrainDispatcher dispatcher2 = new DrainDispatcher(); MockRM rm2 = new MockRM(conf, memStore) { @Override
final DrainDispatcher dispatcher = new DrainDispatcher(); MockRM rm = new MockRM(){ @Override