Search in sources :

Example 16 with LockWrapper

use of org.wso2.siddhi.core.util.lock.LockWrapper in project siddhi by wso2.

the class AggregationWindowedPerSnapshotOutputRateLimiter method start.

@Override
public void start() {
    scheduler = SchedulerParser.parse(scheduledExecutorService, this, siddhiAppContext);
    scheduler.setStreamEventPool(new StreamEventPool(0, 0, 0, 5));
    scheduler.init(lockWrapper, queryName);
    long currentTime = System.currentTimeMillis();
    scheduledTime = currentTime + value;
    scheduler.notifyAt(scheduledTime);
}
Also used : StreamEventPool(org.wso2.siddhi.core.event.stream.StreamEventPool)

Example 17 with LockWrapper

use of org.wso2.siddhi.core.util.lock.LockWrapper in project siddhi by wso2.

the class PerSnapshotOutputRateLimiter method start.

@Override
public void start() {
    scheduler = SchedulerParser.parse(scheduledExecutorService, this, siddhiAppContext);
    scheduler.setStreamEventPool(new StreamEventPool(0, 0, 0, 5));
    scheduler.init(lockWrapper, queryName);
    long currentTime = System.currentTimeMillis();
    scheduledTime = currentTime + value;
    scheduler.notifyAt(scheduledTime);
}
Also used : StreamEventPool(org.wso2.siddhi.core.event.stream.StreamEventPool)

Example 18 with LockWrapper

use of org.wso2.siddhi.core.util.lock.LockWrapper in project siddhi by wso2.

the class Scheduler method sendTimerEvents.

/**
 * Go through the timestamps stored in the {@link #toNotifyQueue} and send the TIMER events for the expired events.
 */
protected void sendTimerEvents() {
    Long toNotifyTime = toNotifyQueue.peek();
    long currentTime = siddhiAppContext.getTimestampGenerator().currentTime();
    while (toNotifyTime != null && toNotifyTime - currentTime <= 0) {
        toNotifyQueue.poll();
        StreamEvent timerEvent = streamEventPool.borrowEvent();
        timerEvent.setType(StreamEvent.Type.TIMER);
        timerEvent.setTimestamp(toNotifyTime);
        streamEventChunk.add(timerEvent);
        if (lockWrapper != null) {
            lockWrapper.lock();
        }
        threadBarrier.pass();
        try {
            if (siddhiAppContext.isStatsEnabled() && latencyTracker != null) {
                try {
                    latencyTracker.markIn();
                    singleThreadEntryValve.process(streamEventChunk);
                } finally {
                    latencyTracker.markOut();
                }
            } else {
                singleThreadEntryValve.process(streamEventChunk);
            }
        } finally {
            if (lockWrapper != null) {
                lockWrapper.unlock();
            }
        }
        streamEventChunk.clear();
        toNotifyTime = toNotifyQueue.peek();
        currentTime = siddhiAppContext.getTimestampGenerator().currentTime();
    }
}
Also used : StreamEvent(org.wso2.siddhi.core.event.stream.StreamEvent)

Aggregations

StreamEventPool (org.wso2.siddhi.core.event.stream.StreamEventPool)13 MetaStreamEvent (org.wso2.siddhi.core.event.stream.MetaStreamEvent)4 ReentrantLock (java.util.concurrent.locks.ReentrantLock)3 MetaStateEvent (org.wso2.siddhi.core.event.state.MetaStateEvent)3 StreamRuntime (org.wso2.siddhi.core.query.input.stream.StreamRuntime)3 SingleStreamRuntime (org.wso2.siddhi.core.query.input.stream.single.SingleStreamRuntime)3 LockWrapper (org.wso2.siddhi.core.util.lock.LockWrapper)3 ArrayList (java.util.ArrayList)2 VariableExpressionExecutor (org.wso2.siddhi.core.executor.VariableExpressionExecutor)2 OutputCallback (org.wso2.siddhi.core.query.output.callback.OutputCallback)2 OutputRateLimiter (org.wso2.siddhi.core.query.output.ratelimit.OutputRateLimiter)2 QuerySelector (org.wso2.siddhi.core.query.selector.QuerySelector)2 LatencyTracker (org.wso2.siddhi.core.util.statistics.LatencyTracker)2 Element (org.wso2.siddhi.query.api.annotation.Element)2 AggregationRuntime (org.wso2.siddhi.core.aggregation.AggregationRuntime)1 IncrementalAggregationProcessor (org.wso2.siddhi.core.aggregation.IncrementalAggregationProcessor)1 IncrementalExecutor (org.wso2.siddhi.core.aggregation.IncrementalExecutor)1 RecreateInMemoryData (org.wso2.siddhi.core.aggregation.RecreateInMemoryData)1 ComplexEvent (org.wso2.siddhi.core.event.ComplexEvent)1 StateEventCloner (org.wso2.siddhi.core.event.state.StateEventCloner)1