Search in sources :

Example 1 with ComplexEventPopulater

use of org.wso2.siddhi.core.event.stream.populater.ComplexEventPopulater in project siddhi by wso2.

the class AbstractStreamProcessor method cloneProcessor.

@Override
public Processor cloneProcessor(String key) {
    try {
        AbstractStreamProcessor abstractStreamProcessor = this.getClass().newInstance();
        abstractStreamProcessor.inputDefinition = inputDefinition;
        ExpressionExecutor[] innerExpressionExecutors = new ExpressionExecutor[attributeExpressionLength];
        ExpressionExecutor[] attributeExpressionExecutors1 = this.attributeExpressionExecutors;
        for (int i = 0; i < attributeExpressionLength; i++) {
            innerExpressionExecutors[i] = attributeExpressionExecutors1[i].cloneExecutor(key);
        }
        abstractStreamProcessor.attributeExpressionExecutors = innerExpressionExecutors;
        abstractStreamProcessor.attributeExpressionLength = attributeExpressionLength;
        abstractStreamProcessor.additionalAttributes = additionalAttributes;
        abstractStreamProcessor.complexEventPopulater = complexEventPopulater;
        abstractStreamProcessor.siddhiAppContext = siddhiAppContext;
        abstractStreamProcessor.elementId = elementId + "-" + key;
        abstractStreamProcessor.configReader = configReader;
        abstractStreamProcessor.outputExpectsExpiredEvents = outputExpectsExpiredEvents;
        abstractStreamProcessor.queryName = queryName;
        abstractStreamProcessor.siddhiAppContext.getSnapshotService().addSnapshotable(queryName, abstractStreamProcessor);
        abstractStreamProcessor.siddhiAppContext.addEternalReferencedHolder(abstractStreamProcessor);
        abstractStreamProcessor.init(inputDefinition, attributeExpressionExecutors, configReader, siddhiAppContext, outputExpectsExpiredEvents);
        abstractStreamProcessor.start();
        return abstractStreamProcessor;
    } catch (Exception e) {
        throw new SiddhiAppRuntimeException("Exception in cloning " + this.getClass().getCanonicalName(), e);
    }
}
Also used : ExpressionExecutor(org.wso2.siddhi.core.executor.ExpressionExecutor) SiddhiAppRuntimeException(org.wso2.siddhi.core.exception.SiddhiAppRuntimeException) SiddhiAppCreationException(org.wso2.siddhi.core.exception.SiddhiAppCreationException) SiddhiAppRuntimeException(org.wso2.siddhi.core.exception.SiddhiAppRuntimeException)

Example 2 with ComplexEventPopulater

use of org.wso2.siddhi.core.event.stream.populater.ComplexEventPopulater in project siddhi by wso2.

the class AggregateWindowProcessor method cloneProcessor.

@Override
public Processor cloneProcessor(String key) {
    try {
        AggregateWindowProcessor streamProcessor = new AggregateWindowProcessor(aggregationRuntime, within, per);
        streamProcessor.inputDefinition = inputDefinition;
        ExpressionExecutor[] innerExpressionExecutors = new ExpressionExecutor[attributeExpressionLength];
        ExpressionExecutor[] attributeExpressionExecutors1 = this.attributeExpressionExecutors;
        for (int i = 0; i < attributeExpressionLength; i++) {
            innerExpressionExecutors[i] = attributeExpressionExecutors1[i].cloneExecutor(key);
        }
        streamProcessor.attributeExpressionExecutors = innerExpressionExecutors;
        streamProcessor.attributeExpressionLength = attributeExpressionLength;
        streamProcessor.additionalAttributes = additionalAttributes;
        streamProcessor.complexEventPopulater = complexEventPopulater;
        streamProcessor.init(inputDefinition, attributeExpressionExecutors, configReader, siddhiAppContext, outputExpectsExpiredEvents);
        streamProcessor.start();
        return streamProcessor;
    } catch (Exception e) {
        throw new SiddhiAppRuntimeException("Exception in cloning " + this.getClass().getCanonicalName(), e);
    }
}
Also used : VariableExpressionExecutor(org.wso2.siddhi.core.executor.VariableExpressionExecutor) ExpressionExecutor(org.wso2.siddhi.core.executor.ExpressionExecutor) SiddhiAppRuntimeException(org.wso2.siddhi.core.exception.SiddhiAppRuntimeException) SiddhiAppRuntimeException(org.wso2.siddhi.core.exception.SiddhiAppRuntimeException)

Example 3 with ComplexEventPopulater

use of org.wso2.siddhi.core.event.stream.populater.ComplexEventPopulater in project siddhi by wso2.

the class StoreQueryParser method constructStoreQueryRuntime.

private static StoreQueryRuntime constructStoreQueryRuntime(AggregationRuntime aggregation, StoreQuery storeQuery, SiddhiAppContext siddhiAppContext, Map<String, Table> tableMap, String queryName, Within within, Expression per, Expression onCondition, MetaStreamEvent metaStreamEvent, List<VariableExpressionExecutor> variableExpressionExecutors) {
    int metaPosition;
    metaStreamEvent.setEventType(EventType.AGGREGATE);
    initMetaStreamEvent(metaStreamEvent, aggregation.getAggregationDefinition());
    MatchingMetaInfoHolder metaStreamInfoHolder = generateMatchingMetaInfoHolder(metaStreamEvent, aggregation.getAggregationDefinition());
    CompiledCondition compiledCondition = aggregation.compileExpression(onCondition, within, per, metaStreamInfoHolder, variableExpressionExecutors, tableMap, queryName, siddhiAppContext);
    metaStreamInfoHolder = ((IncrementalAggregateCompileCondition) compiledCondition).getAlteredMatchingMetaInfoHolder();
    FindStoreQueryRuntime findStoreQueryRuntime = new FindStoreQueryRuntime(aggregation, compiledCondition, queryName, metaStreamEvent);
    metaPosition = 1;
    populateFindStoreQueryRuntime(findStoreQueryRuntime, metaStreamInfoHolder, storeQuery.getSelector(), variableExpressionExecutors, siddhiAppContext, tableMap, queryName, metaPosition);
    ComplexEventPopulater complexEventPopulater = StreamEventPopulaterFactory.constructEventPopulator(metaStreamInfoHolder.getMetaStateEvent().getMetaStreamEvent(0), 0, ((IncrementalAggregateCompileCondition) compiledCondition).getAdditionalAttributes());
    ((IncrementalAggregateCompileCondition) compiledCondition).setComplexEventPopulater(complexEventPopulater);
    return findStoreQueryRuntime;
}
Also used : CompiledCondition(org.wso2.siddhi.core.util.collection.operator.CompiledCondition) MatchingMetaInfoHolder(org.wso2.siddhi.core.util.collection.operator.MatchingMetaInfoHolder) IncrementalAggregateCompileCondition(org.wso2.siddhi.core.util.collection.operator.IncrementalAggregateCompileCondition) FindStoreQueryRuntime(org.wso2.siddhi.core.query.FindStoreQueryRuntime) ComplexEventPopulater(org.wso2.siddhi.core.event.stream.populater.ComplexEventPopulater)

Example 4 with ComplexEventPopulater

use of org.wso2.siddhi.core.event.stream.populater.ComplexEventPopulater in project carbon-apimgt by wso2.

the class EmitOnStateChange method process.

@Override
protected void process(ComplexEventChunk<StreamEvent> streamEventChunk, Processor nextProcessor, StreamEventCloner streamEventCloner, ComplexEventPopulater complexEventPopulater) {
    while (streamEventChunk.hasNext()) {
        StreamEvent event = streamEventChunk.next();
        Boolean currentThrottleState = (Boolean) isThrottledExpressionExecutor.execute(event);
        String key = (String) keyExpressionExecutor.execute(event);
        Boolean lastThrottleState = throttleStateMap.get(key);
        if (lastThrottleState == currentThrottleState && !currentThrottleState) {
            streamEventChunk.remove();
        } else {
            throttleStateMap.put(key, currentThrottleState);
        }
    }
    nextProcessor.process(streamEventChunk);
}
Also used : StreamEvent(org.wso2.siddhi.core.event.stream.StreamEvent)

Example 5 with ComplexEventPopulater

use of org.wso2.siddhi.core.event.stream.populater.ComplexEventPopulater in project siddhi by wso2.

the class QueryParserHelper method initSingleStreamRuntime.

private static void initSingleStreamRuntime(SingleStreamRuntime singleStreamRuntime, int streamEventChainIndex, MetaComplexEvent metaComplexEvent, StateEventPool stateEventPool, LockWrapper lockWrapper, String queryName) {
    MetaStreamEvent metaStreamEvent;
    if (metaComplexEvent instanceof MetaStateEvent) {
        metaStreamEvent = ((MetaStateEvent) metaComplexEvent).getMetaStreamEvent(streamEventChainIndex);
    } else {
        metaStreamEvent = (MetaStreamEvent) metaComplexEvent;
    }
    StreamEventPool streamEventPool = new StreamEventPool(metaStreamEvent, 5);
    ProcessStreamReceiver processStreamReceiver = singleStreamRuntime.getProcessStreamReceiver();
    processStreamReceiver.setMetaStreamEvent(metaStreamEvent);
    processStreamReceiver.setStreamEventPool(streamEventPool);
    processStreamReceiver.setLockWrapper(lockWrapper);
    processStreamReceiver.init();
    Processor processor = singleStreamRuntime.getProcessorChain();
    while (processor != null) {
        if (processor instanceof SchedulingProcessor) {
            ((SchedulingProcessor) processor).getScheduler().setStreamEventPool(streamEventPool);
            ((SchedulingProcessor) processor).getScheduler().init(lockWrapper, queryName);
        }
        if (processor instanceof AbstractStreamProcessor) {
            ((AbstractStreamProcessor) processor).setStreamEventCloner(new StreamEventCloner(metaStreamEvent, streamEventPool));
            ((AbstractStreamProcessor) processor).constructStreamEventPopulater(metaStreamEvent, streamEventChainIndex);
        }
        if (stateEventPool != null && processor instanceof JoinProcessor) {
            if (((JoinProcessor) processor).getCompiledCondition() instanceof IncrementalAggregateCompileCondition) {
                IncrementalAggregateCompileCondition compiledCondition = (IncrementalAggregateCompileCondition) ((JoinProcessor) processor).getCompiledCondition();
                ComplexEventPopulater complexEventPopulater = StreamEventPopulaterFactory.constructEventPopulator(metaStreamEvent, 0, compiledCondition.getAdditionalAttributes());
                compiledCondition.setComplexEventPopulater(complexEventPopulater);
            }
            ((JoinProcessor) processor).setStateEventPool(stateEventPool);
            ((JoinProcessor) processor).setJoinLock(lockWrapper);
        }
        if (stateEventPool != null && processor instanceof StreamPreStateProcessor) {
            ((StreamPreStateProcessor) processor).setStateEventPool(stateEventPool);
            ((StreamPreStateProcessor) processor).setStreamEventPool(streamEventPool);
            ((StreamPreStateProcessor) processor).setStreamEventCloner(new StreamEventCloner(metaStreamEvent, streamEventPool));
            if (metaComplexEvent instanceof MetaStateEvent) {
                ((StreamPreStateProcessor) processor).setStateEventCloner(new StateEventCloner(((MetaStateEvent) metaComplexEvent), stateEventPool));
            }
        }
        processor = processor.getNextProcessor();
    }
}
Also used : ProcessStreamReceiver(org.wso2.siddhi.core.query.input.ProcessStreamReceiver) StreamPreStateProcessor(org.wso2.siddhi.core.query.input.stream.state.StreamPreStateProcessor) Processor(org.wso2.siddhi.core.query.processor.Processor) JoinProcessor(org.wso2.siddhi.core.query.input.stream.join.JoinProcessor) AbstractStreamProcessor(org.wso2.siddhi.core.query.processor.stream.AbstractStreamProcessor) SchedulingProcessor(org.wso2.siddhi.core.query.processor.SchedulingProcessor) AbstractStreamProcessor(org.wso2.siddhi.core.query.processor.stream.AbstractStreamProcessor) IncrementalAggregateCompileCondition(org.wso2.siddhi.core.util.collection.operator.IncrementalAggregateCompileCondition) ComplexEventPopulater(org.wso2.siddhi.core.event.stream.populater.ComplexEventPopulater) StreamPreStateProcessor(org.wso2.siddhi.core.query.input.stream.state.StreamPreStateProcessor) MetaStateEvent(org.wso2.siddhi.core.event.state.MetaStateEvent) SchedulingProcessor(org.wso2.siddhi.core.query.processor.SchedulingProcessor) StreamEventPool(org.wso2.siddhi.core.event.stream.StreamEventPool) StreamEventCloner(org.wso2.siddhi.core.event.stream.StreamEventCloner) JoinProcessor(org.wso2.siddhi.core.query.input.stream.join.JoinProcessor) StateEventCloner(org.wso2.siddhi.core.event.state.StateEventCloner) MetaStreamEvent(org.wso2.siddhi.core.event.stream.MetaStreamEvent)

Aggregations

SiddhiAppRuntimeException (org.wso2.siddhi.core.exception.SiddhiAppRuntimeException)4 ExpressionExecutor (org.wso2.siddhi.core.executor.ExpressionExecutor)4 StreamEvent (org.wso2.siddhi.core.event.stream.StreamEvent)3 VariableExpressionExecutor (org.wso2.siddhi.core.executor.VariableExpressionExecutor)3 ComplexEvent (org.wso2.siddhi.core.event.ComplexEvent)2 ComplexEventPopulater (org.wso2.siddhi.core.event.stream.populater.ComplexEventPopulater)2 IncrementalAggregateCompileCondition (org.wso2.siddhi.core.util.collection.operator.IncrementalAggregateCompileCondition)2 ArrayList (java.util.ArrayList)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 MetaStateEvent (org.wso2.siddhi.core.event.state.MetaStateEvent)1 StateEventCloner (org.wso2.siddhi.core.event.state.StateEventCloner)1 MetaStreamEvent (org.wso2.siddhi.core.event.stream.MetaStreamEvent)1 StreamEventCloner (org.wso2.siddhi.core.event.stream.StreamEventCloner)1 StreamEventPool (org.wso2.siddhi.core.event.stream.StreamEventPool)1 SiddhiAppCreationException (org.wso2.siddhi.core.exception.SiddhiAppCreationException)1 FindStoreQueryRuntime (org.wso2.siddhi.core.query.FindStoreQueryRuntime)1 ProcessStreamReceiver (org.wso2.siddhi.core.query.input.ProcessStreamReceiver)1 JoinProcessor (org.wso2.siddhi.core.query.input.stream.join.JoinProcessor)1 StreamPreStateProcessor (org.wso2.siddhi.core.query.input.stream.state.StreamPreStateProcessor)1 Processor (org.wso2.siddhi.core.query.processor.Processor)1