@SuppressWarnings("unchecked") protected void dispatch(Event event) { //all events go thru this loop if (LOG.isDebugEnabled()) { LOG.debug("Dispatching the event " + event.getClass().getName() + "." + event.toString()); } Class<? extends Enum> type = event.getType().getDeclaringClass(); try{ EventHandler handler = eventDispatchers.get(type); if(handler != null) { handler.handle(event); } else { throw new Exception("No handler for registered for " + type); } } catch (Throwable t) { //TODO Maybe log the state of the queue LOG.fatal("Error in dispatcher thread", t); // If serviceStop is called, we should exit this thread gracefully. if (exitOnDispatchException && (ShutdownHookManager.get().isShutdownInProgress()) == false && stopped == false) { Thread shutDownThread = new Thread(createShutDownThread()); shutDownThread.setName("AsyncDispatcher ShutDown handler"); shutDownThread.start(); } } }
protected void dispatch(Event event) { //all events go thru this loop if (LOG.isDebugEnabled()) { LOG.debug("Dispatching the event " + event.getClass().getName() + "." + event.toString()); } Class<? extends Enum> type = event.getType().getDeclaringClass(); try{ EventHandler handler = eventHandlers.get(type); if(handler != null) { handler.handle(event); } else { throw new Exception("No handler for registered for " + type); } } catch (Throwable t) { LOG.error("Error in dispatcher thread", t); // If serviceStop is called, we should exit this thread gracefully. if (exitOnDispatchException && (ShutdownHookManager.get().isShutdownInProgress()) == false && stopped == false) { Thread shutDownThread = new Thread(createShutDownThread()); shutDownThread.setName("AsyncDispatcher ShutDown handler"); shutDownThread.start(); } } }
protected void dispatch(Event event) { //all events go thru this loop if (LOG.isDebugEnabled()) { LOG.debug("Dispatching the event " + event.getClass().getName() + "." + event.toString()); } Class<? extends Enum> type = event.getType().getDeclaringClass(); try{ EventHandler handler = eventHandlers.get(type); if(handler != null) { handler.handle(event); } else { throw new Exception("No handler for registered for " + type); } } catch (Throwable t) { LOG.error("Error in dispatcher thread", t); // If serviceStop is called, we should exit this thread gracefully. if (exitOnDispatchException && (ShutdownHookManager.get().isShutdownInProgress()) == false && stopped == false) { Thread shutDownThread = new Thread(createShutDownThread()); shutDownThread.setName("AsyncDispatcher ShutDown handler"); shutDownThread.start(); } } }
@SuppressWarnings("unchecked") protected void dispatch(Event event) { //all events go thru this loop if (LOG.isDebugEnabled()) { LOG.debug("Dispatching the event " + event.getClass().getName() + "." + event.toString()); } Class<? extends Enum> type = event.getType().getDeclaringClass(); try{ EventHandler handler = eventDispatchers.get(type); if(handler != null) { handler.handle(event); } else { throw new Exception("No handler for registered for " + type); } } catch (Throwable t) { //TODO Maybe log the state of the queue LOG.fatal("Error in dispatcher thread", t); // If serviceStop is called, we should exit this thread gracefully. if (exitOnDispatchException && (ShutdownHookManager.get().isShutdownInProgress()) == false && stopped == false) { Thread shutDownThread = new Thread(createShutDownThread()); shutDownThread.setName("AsyncDispatcher ShutDown handler"); shutDownThread.start(); } } }
@SuppressWarnings("unchecked") protected void dispatch(Event event) { //all events go thru this loop if (LOG.isDebugEnabled()) { LOG.debug("Dispatching the event " + event.getClass().getName() + "." + event.toString()); } Class<? extends Enum> type = event.getType().getDeclaringClass(); try{ EventHandler handler = eventDispatchers.get(type); if(handler != null) { handler.handle(event); } else { throw new Exception("No handler for registered for " + type); } } catch (Throwable t) { //TODO Maybe log the state of the queue LOG.fatal("Error in dispatcher thread", t); // If serviceStop is called, we should exit this thread gracefully. if (exitOnDispatchException && (ShutdownHookManager.get().isShutdownInProgress()) == false && stopped == false) { stopped = true; Thread shutDownThread = new Thread(createShutDownThread()); shutDownThread.setName("AsyncDispatcher ShutDown handler"); shutDownThread.start(); } } }
@Override protected void dispatch(Event event) { if (event.getType() == eventType) { latch.countDown(); } super.dispatch(event); } }
@Override public void handle(Event event) { if (event instanceof RMAppEvent && event.getType() .equals(RMAppEventType.APP_SAVE_FAILED)) { appsavefailedEvnt = true; } }
@SuppressWarnings("rawtypes") @Override protected void dispatch(Event event) { if (event.getType() == RMFatalEventType.TRANSITION_TO_ACTIVE_FAILED) { eventreceived++; } else { super.dispatch(event); } }
@SuppressWarnings("rawtypes") @Override protected void dispatch(Event event) { if (event.getType() == RMFatalEventType.TRANSITION_TO_ACTIVE_FAILED) { eventreceived++; } else { super.dispatch(event); } }
Class<? extends Enum> type = event.getType().getDeclaringClass(); AsyncDispatcher registeredDispatcher = eventDispatchers.get(type); if (registeredDispatcher != null) {
@Override protected void dispatch(Event event) { LOG.info("Dispatching the event " + event.getClass().getName() + "." + event.toString()); Class<? extends Enum> type = event.getType().getDeclaringClass(); if (eventDispatchers.get(type) != null) { eventDispatchers.get(type).handle(event); } } @Override
@Override protected void dispatch(Event event) { LOG.info("Dispatching the event " + event.getClass().getName() + "." + event.toString()); Class<? extends Enum> type = event.getType().getDeclaringClass(); if (eventDispatchers.get(type) != null) { eventDispatchers.get(type).handle(event); } } @Override
@Override protected void dispatch(Event event) { LOG.info("Dispatching the event " + event.getClass().getName() + "." + event.toString()); Class<? extends Enum> type = event.getType().getDeclaringClass(); if (eventDispatchers.get(type) != null) { eventDispatchers.get(type).handle(event); } } @Override
@SuppressWarnings({ "rawtypes", "unchecked" }) private void dispatchDummyEvents(Dispatcher disp, int count) { for (int i = 0; i < count; i++) { Event event = mock(Event.class); when(event.getType()).thenReturn(DummyType.DUMMY); disp.getEventHandler().handle(event); } }
@Override public void handle(Event event) { if (event instanceof TaskAttemptEvent) if (event.getType() == TaskAttemptEventType.TA_RESCHEDULE) { TaskAttempt attempt = mockTask.getAttempt(((TaskAttemptEvent) event).getTaskAttemptID()); ((MockTaskAttemptImpl)attempt).setRescheduled(true); } } }
LOG.info(arg.getAllValues().get(i).toString()); Event currentEvent = arg.getAllValues().get(i); if (currentEvent.getType() == TaskAttemptEventType.TA_CONTAINER_CLEANED) { containerCleaned = true;
@Test(timeout=60000) public void testAppRejectionWithCancelledDelegationToken() throws Exception { MyFS dfs = (MyFS)FileSystem.get(conf); LOG.info("dfs="+(Object)dfs.hashCode() + ";conf="+conf.hashCode()); MyToken token = dfs.getDelegationToken("user1"); token.cancelToken(); Credentials ts = new Credentials(); ts.addToken(token.getKind(), token); // register the tokens for renewal ApplicationId appId = BuilderUtils.newApplicationId(0, 0); delegationTokenRenewer.addApplicationAsync(appId, ts, true, "user", new Configuration()); int waitCnt = 20; while (waitCnt-- >0) { if (!eventQueue.isEmpty()) { Event evt = eventQueue.take(); if (evt.getType() == RMAppEventType.APP_REJECTED) { Assert.assertTrue( ((RMAppEvent) evt).getApplicationId().equals(appId)); return; } } else { Thread.sleep(500); } } fail("App submission with a cancelled token should have failed"); }
@Test(timeout=60000) public void testAppRejectionWithCancelledDelegationToken() throws Exception { MyFS dfs = (MyFS)FileSystem.get(conf); LOG.info("dfs="+(Object)dfs.hashCode() + ";conf="+conf.hashCode()); MyToken token = dfs.getDelegationToken("user1"); token.cancelToken(); Credentials ts = new Credentials(); ts.addToken(token.getKind(), token); // register the tokens for renewal ApplicationId appId = BuilderUtils.newApplicationId(0, 0); delegationTokenRenewer.addApplicationAsync(appId, ts, true, "user"); int waitCnt = 20; while (waitCnt-- >0) { if (!eventQueue.isEmpty()) { Event evt = eventQueue.take(); if (evt.getType() == RMAppEventType.APP_REJECTED) { Assert.assertTrue( ((RMAppEvent) evt).getApplicationId().equals(appId)); return; } } else { Thread.sleep(500); } } fail("App submission with a cancelled token should have failed"); }