Example usage for org.apache.hadoop.yarn.event EventHandler handle

List of usage examples for org.apache.hadoop.yarn.event EventHandler handle

Introduction

In this page you can find the example usage for org.apache.hadoop.yarn.event EventHandler handle.

Prototype

void handle(T event);

Source Link

Usage

From source file:org.apache.tajo.master.TajoAsyncDispatcher.java

License:Apache License

@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());
    }//from  w w  w . j  a v  a2  s .  c  o  m
    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:" + event.getType(), t);
        if (exitOnDispatchException && (ShutdownHookManager.get().isShutdownInProgress()) == false) {
            LOG.info("Exiting, bye..");
            System.exit(-1);
        }
    } finally {
    }
}

From source file:org.apache.tez.common.AsyncDispatcher.java

License:Apache License

protected void dispatch(Event event) {
    //all events go thru this loop
    if (LOG.isDebugEnabled()) {
        LOG.debug("Dispatching the event " + event.getClass().getName() + "." + event.toString());
    }//from  ww  w. ja  v a  2  s  . c  om

    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.fatal("Error in dispatcher thread", t);
        // If serviceStop is called, we should exit this thread gracefully.
        if (exitOnDispatchException && (ShutdownHookManager.get().isShutdownInProgress()) == false
                && stopped == false) {
            LOG.info("Exiting, bbye..");
            System.exit(-1);
        }
    }
}

From source file:org.apache.tez.common.AsyncDispatcherConcurrent.java

License:Apache License

protected void dispatch(Event event) {
    //all events go thru this loop
    if (LOG.isDebugEnabled()) {
        LOG.debug("Dispatching the event " + event.getClass().getName() + "." + event.toString());
    }/*from  www .j  av a2  s  . c  o  m*/

    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();
        }
    }
}

From source file:org.apache.tez.common.DrainDispatcher.java

License:Apache License

@SuppressWarnings("unchecked")
@Override//w w w .  j  a  v a 2s . c om
public EventHandler getEventHandler() {
    final EventHandler actual = super.getEventHandler();
    return new EventHandler() {
        @Override
        public void handle(Event event) {
            synchronized (mutex) {
                actual.handle(event);
                drained = false;
            }
        }
    };
}