Search in sources :

Example 6 with EntryValveProcessor

use of org.wso2.siddhi.core.query.input.stream.single.EntryValveProcessor in project siddhi by wso2.

the class Window method init.

/**
 * Initialize the WindowEvent table by creating {@link WindowProcessor} to handle the events.
 *
 * @param tableMap       map of {@link Table}s
 * @param eventWindowMap map of EventWindows
 * @param queryName      name of the query window belongs to.
 */
public void init(Map<String, Table> tableMap, Map<String, Window> eventWindowMap, String queryName) {
    if (this.windowProcessor != null) {
        return;
    }
    // Create and initialize MetaStreamEvent
    MetaStreamEvent metaStreamEvent = new MetaStreamEvent();
    metaStreamEvent.addInputDefinition(windowDefinition);
    metaStreamEvent.setEventType(MetaStreamEvent.EventType.WINDOW);
    metaStreamEvent.initializeAfterWindowData();
    for (Attribute attribute : windowDefinition.getAttributeList()) {
        metaStreamEvent.addOutputData(attribute);
    }
    this.streamEventPool = new StreamEventPool(metaStreamEvent, 5);
    StreamEventCloner streamEventCloner = new StreamEventCloner(metaStreamEvent, this.streamEventPool);
    OutputStream.OutputEventType outputEventType = windowDefinition.getOutputEventType();
    boolean outputExpectsExpiredEvents = outputEventType != OutputStream.OutputEventType.CURRENT_EVENTS;
    WindowProcessor internalWindowProcessor = (WindowProcessor) SingleInputStreamParser.generateProcessor(windowDefinition.getWindow(), metaStreamEvent, new ArrayList<VariableExpressionExecutor>(), this.siddhiAppContext, tableMap, false, outputExpectsExpiredEvents, queryName);
    internalWindowProcessor.setStreamEventCloner(streamEventCloner);
    internalWindowProcessor.constructStreamEventPopulater(metaStreamEvent, 0);
    EntryValveProcessor entryValveProcessor = null;
    if (internalWindowProcessor instanceof SchedulingProcessor) {
        entryValveProcessor = new EntryValveProcessor(this.siddhiAppContext);
        Scheduler scheduler = SchedulerParser.parse(this.siddhiAppContext.getScheduledExecutorService(), entryValveProcessor, this.siddhiAppContext);
        scheduler.init(this.lockWrapper, queryName);
        scheduler.setStreamEventPool(streamEventPool);
        ((SchedulingProcessor) internalWindowProcessor).setScheduler(scheduler);
    }
    if (entryValveProcessor != null) {
        entryValveProcessor.setToLast(internalWindowProcessor);
        this.windowProcessor = entryValveProcessor;
    } else {
        this.windowProcessor = internalWindowProcessor;
    }
    // StreamPublishProcessor must be the last in chain so that it can publish the events to StreamJunction
    this.windowProcessor.setToLast(new StreamPublishProcessor(outputEventType));
    this.internalWindowProcessor = internalWindowProcessor;
}
Also used : Attribute(org.wso2.siddhi.query.api.definition.Attribute) Scheduler(org.wso2.siddhi.core.util.Scheduler) OutputStream(org.wso2.siddhi.query.api.execution.query.output.stream.OutputStream) ArrayList(java.util.ArrayList) SchedulingProcessor(org.wso2.siddhi.core.query.processor.SchedulingProcessor) StreamEventPool(org.wso2.siddhi.core.event.stream.StreamEventPool) StreamEventCloner(org.wso2.siddhi.core.event.stream.StreamEventCloner) EntryValveProcessor(org.wso2.siddhi.core.query.input.stream.single.EntryValveProcessor) WindowProcessor(org.wso2.siddhi.core.query.processor.stream.window.WindowProcessor) MetaStreamEvent(org.wso2.siddhi.core.event.stream.MetaStreamEvent)

Aggregations

EntryValveProcessor (org.wso2.siddhi.core.query.input.stream.single.EntryValveProcessor)5 Scheduler (org.wso2.siddhi.core.util.Scheduler)5 SchedulingProcessor (org.wso2.siddhi.core.query.processor.SchedulingProcessor)3 MetaStreamEvent (org.wso2.siddhi.core.event.stream.MetaStreamEvent)2 OperationNotSupportedException (org.wso2.siddhi.core.exception.OperationNotSupportedException)2 SingleStreamRuntime (org.wso2.siddhi.core.query.input.stream.single.SingleStreamRuntime)2 Processor (org.wso2.siddhi.core.query.processor.Processor)2 WindowProcessor (org.wso2.siddhi.core.query.processor.stream.window.WindowProcessor)2 AbstractMap (java.util.AbstractMap)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 MetaStateEvent (org.wso2.siddhi.core.event.state.MetaStateEvent)1 StreamEventCloner (org.wso2.siddhi.core.event.stream.StreamEventCloner)1 StreamEventPool (org.wso2.siddhi.core.event.stream.StreamEventPool)1 ProcessStreamReceiver (org.wso2.siddhi.core.query.input.ProcessStreamReceiver)1 AbsentLogicalPostStateProcessor (org.wso2.siddhi.core.query.input.stream.state.AbsentLogicalPostStateProcessor)1 AbsentLogicalPreStateProcessor (org.wso2.siddhi.core.query.input.stream.state.AbsentLogicalPreStateProcessor)1 AbsentStreamPostStateProcessor (org.wso2.siddhi.core.query.input.stream.state.AbsentStreamPostStateProcessor)1 AbsentStreamPreStateProcessor (org.wso2.siddhi.core.query.input.stream.state.AbsentStreamPreStateProcessor)1