Search in sources :

Example 1 with SingleStreamRuntime

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

the class SiddhiAppRuntime method debug.

public synchronized SiddhiDebugger debug() {
    siddhiDebugger = new SiddhiDebugger(siddhiAppContext);
    List<StreamRuntime> streamRuntime = new ArrayList<>();
    List<OutputCallback> streamCallbacks = new ArrayList<>();
    for (QueryRuntime queryRuntime : queryProcessorMap.values()) {
        streamRuntime.add(queryRuntime.getStreamRuntime());
        streamCallbacks.add(queryRuntime.getOutputCallback());
    }
    for (StreamRuntime streamRuntime1 : streamRuntime) {
        for (SingleStreamRuntime singleStreamRuntime : streamRuntime1.getSingleStreamRuntimes()) {
            singleStreamRuntime.getProcessStreamReceiver().setSiddhiDebugger(siddhiDebugger);
        }
    }
    for (OutputCallback callback : streamCallbacks) {
        callback.setSiddhiDebugger(siddhiDebugger);
    }
    start();
    running = true;
    return siddhiDebugger;
}
Also used : SiddhiDebugger(org.wso2.siddhi.core.debugger.SiddhiDebugger) QueryRuntime(org.wso2.siddhi.core.query.QueryRuntime) StoreQueryRuntime(org.wso2.siddhi.core.query.StoreQueryRuntime) SingleStreamRuntime(org.wso2.siddhi.core.query.input.stream.single.SingleStreamRuntime) ArrayList(java.util.ArrayList) StreamRuntime(org.wso2.siddhi.core.query.input.stream.StreamRuntime) SingleStreamRuntime(org.wso2.siddhi.core.query.input.stream.single.SingleStreamRuntime) OutputCallback(org.wso2.siddhi.core.query.output.callback.OutputCallback)

Example 2 with SingleStreamRuntime

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

the class JoinStreamRuntime method clone.

@Override
public StreamRuntime clone(String key) {
    JoinStreamRuntime joinStreamRuntime = new JoinStreamRuntime(siddhiAppContext, metaStateEvent);
    for (SingleStreamRuntime singleStreamRuntime : singleStreamRuntimeList) {
        joinStreamRuntime.addRuntime((SingleStreamRuntime) singleStreamRuntime.clone(key));
    }
    SingleStreamRuntime leftSingleStreamRuntime = joinStreamRuntime.getSingleStreamRuntimes().get(0);
    SingleStreamRuntime rightSingleStreamRuntime = joinStreamRuntime.getSingleStreamRuntimes().get(1);
    Processor lastLeftProcessor = leftSingleStreamRuntime.getProcessorChain();
    while (!(lastLeftProcessor instanceof JoinProcessor)) {
        lastLeftProcessor = lastLeftProcessor.getNextProcessor();
    }
    JoinProcessor leftPreJoinProcessor = (JoinProcessor) lastLeftProcessor;
    WindowProcessor leftWindowProcessor = (WindowProcessor) leftPreJoinProcessor.getNextProcessor();
    JoinProcessor leftPostJoinProcessor = (JoinProcessor) leftWindowProcessor.getNextProcessor();
    Processor lastRightProcessor = rightSingleStreamRuntime.getProcessorChain();
    while (!(lastRightProcessor instanceof JoinProcessor)) {
        lastRightProcessor = lastRightProcessor.getNextProcessor();
    }
    JoinProcessor rightPreJoinProcessor = (JoinProcessor) lastRightProcessor;
    WindowProcessor rightWindowProcessor = (WindowProcessor) rightPreJoinProcessor.getNextProcessor();
    JoinProcessor rightPostJoinProcessor = (JoinProcessor) rightWindowProcessor.getNextProcessor();
    rightPostJoinProcessor.setFindableProcessor((FindableProcessor) leftWindowProcessor);
    rightPreJoinProcessor.setFindableProcessor((FindableProcessor) leftWindowProcessor);
    leftPreJoinProcessor.setFindableProcessor((FindableProcessor) rightWindowProcessor);
    leftPostJoinProcessor.setFindableProcessor((FindableProcessor) rightWindowProcessor);
    return joinStreamRuntime;
}
Also used : FindableProcessor(org.wso2.siddhi.core.query.processor.stream.window.FindableProcessor) Processor(org.wso2.siddhi.core.query.processor.Processor) WindowProcessor(org.wso2.siddhi.core.query.processor.stream.window.WindowProcessor) SingleStreamRuntime(org.wso2.siddhi.core.query.input.stream.single.SingleStreamRuntime) WindowProcessor(org.wso2.siddhi.core.query.processor.stream.window.WindowProcessor)

Example 3 with SingleStreamRuntime

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

the class SingleStreamRuntime method clone.

@Override
public StreamRuntime clone(String key) {
    ProcessStreamReceiver clonedProcessStreamReceiver = this.processStreamReceiver.clone(key);
    EntryValveProcessor entryValveProcessor = null;
    SchedulingProcessor schedulingProcessor;
    Processor clonedProcessorChain = null;
    if (processorChain != null) {
        if (!(processorChain instanceof QuerySelector || processorChain instanceof OutputRateLimiter)) {
            clonedProcessorChain = processorChain.cloneProcessor(key);
            if (clonedProcessorChain instanceof EntryValveProcessor) {
                entryValveProcessor = (EntryValveProcessor) clonedProcessorChain;
            }
        }
        Processor processor = processorChain.getNextProcessor();
        while (processor != null) {
            if (!(processor instanceof QuerySelector || processor instanceof OutputRateLimiter)) {
                Processor clonedProcessor = processor.cloneProcessor(key);
                clonedProcessorChain.setToLast(clonedProcessor);
                if (clonedProcessor instanceof EntryValveProcessor) {
                    entryValveProcessor = (EntryValveProcessor) clonedProcessor;
                } else if (clonedProcessor instanceof SchedulingProcessor) {
                    schedulingProcessor = (SchedulingProcessor) clonedProcessor;
                    schedulingProcessor.setScheduler(((SchedulingProcessor) processor).getScheduler().clone(key, entryValveProcessor));
                }
            }
            processor = processor.getNextProcessor();
        }
    }
    return new SingleStreamRuntime(clonedProcessStreamReceiver, clonedProcessorChain, metaComplexEvent);
}
Also used : ProcessStreamReceiver(org.wso2.siddhi.core.query.input.ProcessStreamReceiver) SchedulingProcessor(org.wso2.siddhi.core.query.processor.SchedulingProcessor) Processor(org.wso2.siddhi.core.query.processor.Processor) SchedulingProcessor(org.wso2.siddhi.core.query.processor.SchedulingProcessor) OutputRateLimiter(org.wso2.siddhi.core.query.output.ratelimit.OutputRateLimiter) QuerySelector(org.wso2.siddhi.core.query.selector.QuerySelector)

Example 4 with SingleStreamRuntime

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

the class LogicalInnerStateRuntime method clone.

@Override
public InnerStateRuntime clone(String key) {
    InnerStateRuntime clonedInnerStateRuntime1 = innerStateRuntime1.clone(key);
    InnerStateRuntime clonedInnerStateRuntime2 = innerStateRuntime2.clone(key);
    LogicalPreStateProcessor logicalPreStateProcessor1 = (LogicalPreStateProcessor) clonedInnerStateRuntime1.getFirstProcessor();
    LogicalPostStateProcessor logicalPostStateProcessor1 = (LogicalPostStateProcessor) clonedInnerStateRuntime1.getLastProcessor();
    LogicalPreStateProcessor logicalPreStateProcessor2 = (LogicalPreStateProcessor) clonedInnerStateRuntime2.getFirstProcessor();
    LogicalPostStateProcessor logicalPostStateProcessor2 = (LogicalPostStateProcessor) clonedInnerStateRuntime2.getLastProcessor();
    logicalPostStateProcessor1.setPartnerPreStateProcessor(logicalPreStateProcessor2);
    logicalPostStateProcessor2.setPartnerPreStateProcessor(logicalPreStateProcessor1);
    logicalPostStateProcessor1.setPartnerPostStateProcessor(logicalPostStateProcessor2);
    logicalPostStateProcessor2.setPartnerPostStateProcessor(logicalPostStateProcessor1);
    logicalPreStateProcessor1.setPartnerStatePreProcessor(logicalPreStateProcessor2);
    logicalPreStateProcessor2.setPartnerStatePreProcessor(logicalPreStateProcessor1);
    LogicalInnerStateRuntime logicalInnerStateRuntime = new LogicalInnerStateRuntime(clonedInnerStateRuntime1, clonedInnerStateRuntime2, stateType);
    logicalInnerStateRuntime.firstProcessor = clonedInnerStateRuntime1.getFirstProcessor();
    logicalInnerStateRuntime.lastProcessor = clonedInnerStateRuntime2.getLastProcessor();
    logicalInnerStateRuntime.getSingleStreamRuntimeList().addAll(clonedInnerStateRuntime2.getSingleStreamRuntimeList());
    logicalInnerStateRuntime.getSingleStreamRuntimeList().addAll(clonedInnerStateRuntime1.getSingleStreamRuntimeList());
    List<SingleStreamRuntime> runtimeList = logicalInnerStateRuntime.getSingleStreamRuntimeList();
    for (int i = 0; i < runtimeList.size(); i++) {
        String streamId = runtimeList.get(i).getProcessStreamReceiver().getStreamId();
        for (int j = i; j < runtimeList.size(); j++) {
            if (streamId.equals(runtimeList.get(j).getProcessStreamReceiver().getStreamId())) {
                runtimeList.get(j).setProcessStreamReceiver(runtimeList.get(i).getProcessStreamReceiver());
            }
        }
    }
    return logicalInnerStateRuntime;
}
Also used : SingleStreamRuntime(org.wso2.siddhi.core.query.input.stream.single.SingleStreamRuntime) LogicalPreStateProcessor(org.wso2.siddhi.core.query.input.stream.state.LogicalPreStateProcessor) LogicalPostStateProcessor(org.wso2.siddhi.core.query.input.stream.state.LogicalPostStateProcessor)

Example 5 with SingleStreamRuntime

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

the class StreamInnerStateRuntime method clone.

@Override
public InnerStateRuntime clone(String key) {
    StreamInnerStateRuntime streamInnerStateRuntime = new StreamInnerStateRuntime(stateType);
    for (SingleStreamRuntime singleStreamRuntime : singleStreamRuntimeList) {
        streamInnerStateRuntime.singleStreamRuntimeList.add((SingleStreamRuntime) singleStreamRuntime.clone(key));
    }
    Processor processor = streamInnerStateRuntime.singleStreamRuntimeList.get(0).getProcessorChain();
    streamInnerStateRuntime.firstProcessor = (StreamPreStateProcessor) processor;
    while (processor != null) {
        if (processor instanceof StreamPostStateProcessor) {
            streamInnerStateRuntime.lastProcessor = (StreamPostStateProcessor) processor;
            break;
        } else {
            processor = processor.getNextProcessor();
        }
    }
    ((StreamPostStateProcessor) streamInnerStateRuntime.lastProcessor).setThisStatePreProcessor((StreamPreStateProcessor) streamInnerStateRuntime.firstProcessor);
    ((StreamPreStateProcessor) streamInnerStateRuntime.firstProcessor).setThisStatePostProcessor((StreamPostStateProcessor) streamInnerStateRuntime.lastProcessor);
    ((StreamPreStateProcessor) streamInnerStateRuntime.firstProcessor).setThisLastProcessor((StreamPostStateProcessor) streamInnerStateRuntime.lastProcessor);
    return streamInnerStateRuntime;
}
Also used : StreamPreStateProcessor(org.wso2.siddhi.core.query.input.stream.state.StreamPreStateProcessor) StreamPostStateProcessor(org.wso2.siddhi.core.query.input.stream.state.StreamPostStateProcessor) PreStateProcessor(org.wso2.siddhi.core.query.input.stream.state.PreStateProcessor) Processor(org.wso2.siddhi.core.query.processor.Processor) PostStateProcessor(org.wso2.siddhi.core.query.input.stream.state.PostStateProcessor) StreamPostStateProcessor(org.wso2.siddhi.core.query.input.stream.state.StreamPostStateProcessor) SingleStreamRuntime(org.wso2.siddhi.core.query.input.stream.single.SingleStreamRuntime) StreamPreStateProcessor(org.wso2.siddhi.core.query.input.stream.state.StreamPreStateProcessor)

Aggregations

SingleStreamRuntime (org.wso2.siddhi.core.query.input.stream.single.SingleStreamRuntime)14 MetaStreamEvent (org.wso2.siddhi.core.event.stream.MetaStreamEvent)8 Processor (org.wso2.siddhi.core.query.processor.Processor)6 MetaStateEvent (org.wso2.siddhi.core.event.state.MetaStateEvent)5 VariableExpressionExecutor (org.wso2.siddhi.core.executor.VariableExpressionExecutor)5 ProcessStreamReceiver (org.wso2.siddhi.core.query.input.ProcessStreamReceiver)5 ArrayList (java.util.ArrayList)4 SiddhiAppCreationException (org.wso2.siddhi.core.exception.SiddhiAppCreationException)4 QueryRuntime (org.wso2.siddhi.core.query.QueryRuntime)4 StreamRuntime (org.wso2.siddhi.core.query.input.stream.StreamRuntime)4 AggregationRuntime (org.wso2.siddhi.core.aggregation.AggregationRuntime)3 OperationNotSupportedException (org.wso2.siddhi.core.exception.OperationNotSupportedException)3 ExpressionExecutor (org.wso2.siddhi.core.executor.ExpressionExecutor)3 JoinProcessor (org.wso2.siddhi.core.query.input.stream.join.JoinProcessor)3 StreamPreStateProcessor (org.wso2.siddhi.core.query.input.stream.state.StreamPreStateProcessor)3 SchedulingProcessor (org.wso2.siddhi.core.query.processor.SchedulingProcessor)3 FindableProcessor (org.wso2.siddhi.core.query.processor.stream.window.FindableProcessor)3 WindowProcessor (org.wso2.siddhi.core.query.processor.stream.window.WindowProcessor)3 Scheduler (org.wso2.siddhi.core.util.Scheduler)3 List (java.util.List)2