Search in sources :

Example 1 with IHandler

use of org.aion.evtmgr.IHandler in project aion by aionnetwork.

the class EventMgrA0 method registerEvent.

/*
     * (non-Javadoc)
     * 
     * @see org.aion.evt.api.IEventMgr#registerEvent(java.util.List)
     */
@Override
public boolean registerEvent(List<IEvent> _evt) {
    synchronized (this) {
        for (IEvent e : _evt) {
            if (LOG.isTraceEnabled()) {
                LOG.trace("EVTMGR.registerEvent EventType [{}] CallbackType [{}]", e.getEventType(), e.getCallbackType());
            }
            IHandler hdr = this.getHandler(e.getEventType());
            if (hdr == null) {
                if (LOG.isErrorEnabled()) {
                    LOG.error("EVTMGR.registerEvent can't find the handler base on the EventType [{}]", e.getEventType());
                }
                return false;
            }
            hdr.addEvent(e);
        }
    }
    return true;
}
Also used : IEvent(org.aion.evtmgr.IEvent) IHandler(org.aion.evtmgr.IHandler)

Example 2 with IHandler

use of org.aion.evtmgr.IHandler in project aion by aionnetwork.

the class EventMgrA0 method unregisterEvent.

/*
     * (non-Javadoc)
     * 
     * @see org.aion.evt.api.IEventMgr#unregisterEvent(java.util.List)
     */
@Override
public boolean unregisterEvent(List<IEvent> _evt) {
    synchronized (this) {
        for (IEvent e : _evt) {
            if (LOG.isTraceEnabled()) {
                LOG.trace("EVTMGR.unregisterEvent EventType [{}]", e.getEventType());
            }
            IHandler hdr = this.getHandler(e.getEventType());
            if (hdr == null) {
                if (LOG.isErrorEnabled()) {
                    LOG.error("EVTMGR.unregisterEvent can't find the handler base on the EventType [{}]", e.getEventType());
                }
                return false;
            }
            hdr.removeEvent(e);
        }
    }
    return true;
}
Also used : IEvent(org.aion.evtmgr.IEvent) IHandler(org.aion.evtmgr.IHandler)

Example 3 with IHandler

use of org.aion.evtmgr.IHandler in project aion by aionnetwork.

the class AionPendingStateImpl method init.

public void init(final AionBlockchainImpl blockchain) {
    this.blockchain = blockchain;
    this.transactionStore = blockchain.getTransactionStore();
    this.evtMgr = blockchain.getEventMgr();
    this.pendingTxCache = new PendingTxCache(CfgAion.inst().getTx().getCacheMax());
    this.pendingState = repository.startTracking();
    ees = new EventExecuteService(1000, "EpPS", Thread.MAX_PRIORITY, LOG);
    ees.setFilter(setEvtFilter());
    regBlockEvents();
    IHandler blkHandler = this.evtMgr.getHandler(2);
    if (blkHandler != null) {
        blkHandler.eventCallback(new EventCallback(ees, LOG));
    }
    ees.start(new EpPS());
}
Also used : EventExecuteService(org.aion.evtmgr.impl.es.EventExecuteService) IHandler(org.aion.evtmgr.IHandler) EventCallback(org.aion.evtmgr.impl.callback.EventCallback)

Example 4 with IHandler

use of org.aion.evtmgr.IHandler in project aion by aionnetwork.

the class AionPoW method registerCallback.

/**
 * Registers callback for the
 * {@link org.aion.evtmgr.impl.evt.EventConsensus.CALLBACK#ON_SOLUTION}
 * event.
 */
public void registerCallback() {
    IHandler consensusHandler = eventMgr.getHandler(IHandler.TYPE.CONSENSUS.getValue());
    consensusHandler.eventCallback(new EventCallback(ees, LOG));
    IHandler blockHandler = eventMgr.getHandler(IHandler.TYPE.BLOCK0.getValue());
    blockHandler.eventCallback(new EventCallback(ees, LOG));
    IHandler transactionHandler = eventMgr.getHandler(IHandler.TYPE.TX0.getValue());
    transactionHandler.eventCallback(new EventCallback(ees, LOG));
}
Also used : IHandler(org.aion.evtmgr.IHandler) EventCallback(org.aion.evtmgr.impl.callback.EventCallback)

Aggregations

IHandler (org.aion.evtmgr.IHandler)4 IEvent (org.aion.evtmgr.IEvent)2 EventCallback (org.aion.evtmgr.impl.callback.EventCallback)2 EventExecuteService (org.aion.evtmgr.impl.es.EventExecuteService)1