Search in sources :

Example 1 with Action

use of edu.iu.dsc.tws.task.window.constant.Action in project twister2 by DSC-SPIDAL.

the class WindowManager method scanEvents.

public List<Event<T>> scanEvents(boolean fullScan) {
    List<IMessage<T>> eventsToExpire = new ArrayList<>();
    List<Event<T>> eventsToProcess = new ArrayList<>();
    try {
        lock.lock();
        Iterator<Event<T>> it = queue.iterator();
        while (it.hasNext()) {
            Event<T> windowEvent = it.next();
            Action action = evictionPolicy.evict(windowEvent);
            if (action == Action.EXPIRE) {
                eventsToExpire.add(windowEvent.get());
                it.remove();
            } else if (!fullScan || action == Action.STOP) {
                break;
            } else if (action == Action.PROCESS) {
                eventsToProcess.add(windowEvent);
            }
        }
        expiredEvents.addAll(eventsToExpire);
    } finally {
        lock.unlock();
    }
    eventsSinceLastExpiration.set(0);
    if (!eventsToExpire.isEmpty()) {
        if (debug) {
            LOG.severe(String.format("OnExpiry called on WindowLifeCycleListener"));
        }
        IWindowMessage<T> eventsToExpireIWindow = bundleExpiredWindowIMessage(eventsToExpire);
        windowLifeCycleListener.onExpiry(eventsToExpireIWindow);
    }
    return eventsToProcess;
}
Also used : Action(edu.iu.dsc.tws.task.window.constant.Action) IMessage(edu.iu.dsc.tws.api.compute.IMessage) ArrayList(java.util.ArrayList) Event(edu.iu.dsc.tws.task.window.api.Event)

Aggregations

IMessage (edu.iu.dsc.tws.api.compute.IMessage)1 Event (edu.iu.dsc.tws.task.window.api.Event)1 Action (edu.iu.dsc.tws.task.window.constant.Action)1 ArrayList (java.util.ArrayList)1