protected EventHandler<SchedulerEvent> createSchedulerEventDispatcher() { return new EventDispatcher(this.scheduler, "SchedulerEventDispatcher"); }
@Override public void handle(T event) { try { int qSize = eventQueue.size(); if (qSize !=0 && qSize %1000 == 0) { LOG.info("Size of " + getName() + " event-queue is " + qSize); } int remCapacity = eventQueue.remainingCapacity(); if (remCapacity < 1000) { LOG.info("Very low remaining capacity on " + getName() + "" + "event queue: " + remCapacity); } this.eventQueue.put(event); } catch (InterruptedException e) { LOG.info("Interrupted. Trying to exit gracefully."); } }
YarnConfiguration conf = new YarnConfiguration(); EventDispatcher schedulerDispatcher = new EventDispatcher(sched, sched.getClass().getName()); schedulerDispatcher.disableExitOnError(); rmDispatcher.register(SchedulerEventType.class, schedulerDispatcher); rmDispatcher.init(conf); rmDispatcher.start(); schedulerDispatcher.init(conf); schedulerDispatcher.start(); try { ApplicationAttemptId appAttemptId = mock(ApplicationAttemptId.class); Assert.fail(); } finally { schedulerDispatcher.stop(); rmDispatcher.stop();
private void createAndRegisterOpportunisticDispatcher( ApplicationMasterService service) { if (!isOpportunisticSchedulingEnabled(conf)) { return; } EventDispatcher oppContainerAllocEventDispatcher = new EventDispatcher( (OpportunisticContainerAllocatorAMService) service, OpportunisticContainerAllocatorAMService.class.getName()); // Add an event dispatcher for the // OpportunisticContainerAllocatorAMService to handle node // additions, updates and removals. Since the SchedulerEvent is currently // a super set of theses, we register interest for it. addService(oppContainerAllocEventDispatcher); rmDispatcher .register(SchedulerEventType.class, oppContainerAllocEventDispatcher); }
public EventDispatcher(EventHandler<T> handler, String name) { super(name); this.handler = handler; this.eventProcessor = new Thread(new EventProcessor()); this.eventProcessor.setName(getName() + ":Event Processor"); }