Search in sources :

Example 1 with Scheduler

use of org.wso2.siddhi.core.util.Scheduler in project siddhi by wso2.

the class AllAggregationGroupByWindowedPerSnapshotOutputRateLimiter 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 2 with Scheduler

use of org.wso2.siddhi.core.util.Scheduler in project siddhi by wso2.

the class AllAggregationPerSnapshotOutputRateLimiter 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 3 with Scheduler

use of org.wso2.siddhi.core.util.Scheduler in project siddhi by wso2.

the class GroupByPerSnapshotOutputRateLimiter method process.

/**
 * Sends the collected unique outputs per group by key upon arrival of timer event from scheduler.
 *
 * @param complexEventChunk Incoming {@link org.wso2.siddhi.core.event.ComplexEventChunk}
 */
@Override
public void process(ComplexEventChunk complexEventChunk) {
    List<ComplexEventChunk<ComplexEvent>> outputEventChunks = new ArrayList<ComplexEventChunk<ComplexEvent>>();
    complexEventChunk.reset();
    synchronized (this) {
        complexEventChunk.reset();
        while (complexEventChunk.hasNext()) {
            ComplexEvent event = complexEventChunk.next();
            if (event.getType() == ComplexEvent.Type.TIMER) {
                tryFlushEvents(outputEventChunks, event);
            } else if (event.getType() == ComplexEvent.Type.CURRENT) {
                complexEventChunk.remove();
                tryFlushEvents(outputEventChunks, event);
                GroupedComplexEvent groupedComplexEvent = ((GroupedComplexEvent) event);
                groupByKeyEvents.put(groupedComplexEvent.getGroupKey(), groupedComplexEvent.getComplexEvent());
            }
        }
    }
    for (ComplexEventChunk eventChunk : outputEventChunks) {
        sendToCallBacks(eventChunk);
    }
}
Also used : GroupedComplexEvent(org.wso2.siddhi.core.event.GroupedComplexEvent) ComplexEvent(org.wso2.siddhi.core.event.ComplexEvent) ComplexEventChunk(org.wso2.siddhi.core.event.ComplexEventChunk) ArrayList(java.util.ArrayList) GroupedComplexEvent(org.wso2.siddhi.core.event.GroupedComplexEvent)

Example 4 with Scheduler

use of org.wso2.siddhi.core.util.Scheduler in project siddhi by wso2.

the class GroupByPerSnapshotOutputRateLimiter 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 5 with Scheduler

use of org.wso2.siddhi.core.util.Scheduler in project siddhi by wso2.

the class AbsentLogicalPreStateProcessor method cloneProcessor.

@Override
public PreStateProcessor cloneProcessor(String key) {
    AbsentLogicalPreStateProcessor logicalPreStateProcessor = new AbsentLogicalPreStateProcessor(logicalType, stateType, withinStates, waitingTimeConstant);
    cloneProperties(logicalPreStateProcessor, key);
    logicalPreStateProcessor.init(siddhiAppContext, queryName);
    // Set the scheduler
    siddhiAppContext.addEternalReferencedHolder(logicalPreStateProcessor);
    EntryValveProcessor entryValveProcessor = new EntryValveProcessor(siddhiAppContext);
    entryValveProcessor.setToLast(logicalPreStateProcessor);
    Scheduler scheduler = SchedulerParser.parse(siddhiAppContext.getScheduledExecutorService(), entryValveProcessor, siddhiAppContext);
    logicalPreStateProcessor.setScheduler(scheduler);
    return logicalPreStateProcessor;
}
Also used : Scheduler(org.wso2.siddhi.core.util.Scheduler) EntryValveProcessor(org.wso2.siddhi.core.query.input.stream.single.EntryValveProcessor)

Aggregations

StreamEventPool (org.wso2.siddhi.core.event.stream.StreamEventPool)13 Scheduler (org.wso2.siddhi.core.util.Scheduler)6 EntryValveProcessor (org.wso2.siddhi.core.query.input.stream.single.EntryValveProcessor)5 ArrayList (java.util.ArrayList)4 MetaStreamEvent (org.wso2.siddhi.core.event.stream.MetaStreamEvent)3 SingleStreamRuntime (org.wso2.siddhi.core.query.input.stream.single.SingleStreamRuntime)3 SubstitutionScheduler (org.wso2.carbon.bpmn.people.substitution.scheduler.SubstitutionScheduler)2 OperationNotSupportedException (org.wso2.siddhi.core.exception.OperationNotSupportedException)2 SiddhiAppCreationException (org.wso2.siddhi.core.exception.SiddhiAppCreationException)2 SchedulingProcessor (org.wso2.siddhi.core.query.processor.SchedulingProcessor)2 WindowProcessor (org.wso2.siddhi.core.query.processor.stream.window.WindowProcessor)2 Attribute (org.wso2.siddhi.query.api.definition.Attribute)2 ThreadFactoryBuilder (com.google.common.util.concurrent.ThreadFactoryBuilder)1 AbstractMap (java.util.AbstractMap)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 ExecutorService (java.util.concurrent.ExecutorService)1 ThreadFactory (java.util.concurrent.ThreadFactory)1 ReentrantLock (java.util.concurrent.locks.ReentrantLock)1 SimpleSchedulerConfig (org.wso2.carbon.bpel.config.SimpleSchedulerConfig)1