Package com.alipay.bluewhale.core.event

Source Code of com.alipay.bluewhale.core.event.EventManagerImpExecute

package com.alipay.bluewhale.core.event;

import org.apache.log4j.Logger;

import com.alipay.bluewhale.core.callback.RunnableCallback;
import com.alipay.bluewhale.core.utils.StormUtils;

public class EventManagerImpExecute implements Runnable {
    private static Logger LOG = Logger.getLogger(EventManagerImpExecute.class);

    public EventManagerImpExecute(EventManagerImp manager) {
        this.manager = manager;
    }

    EventManagerImp manager;
    Exception       error = null;

    @Override
    public void run() {
        try {
            while (manager.isRunning()) {
                RunnableCallback r = null;
                try {
                    r = manager.take();
                } catch (InterruptedException e) {
                    LOG.info("Failed to get ArgsRunable from EventManager queue");
                }

                if (r == null) {
                    continue;
                }

                r.run();
                Exception e = r.error();
                if (e != null) {
                    throw e;
                }
                manager.proccessinc();

            }
           
        } catch (InterruptedException e) {
            error = e;
            LOG.error("Event Manager interrupted", e);
        } catch (Exception e) {
            LOG.error("Error when processing event ",e);
            StormUtils.halt_process(20, "Error when processing an event");
        }
    }

}
TOP

Related Classes of com.alipay.bluewhale.core.event.EventManagerImpExecute

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.