Search in sources :

Example 6 with SiddhiAppRuntimeException

use of org.ballerinalang.siddhi.core.exception.SiddhiAppRuntimeException in project ballerina by ballerina-lang.

the class IncrementalExecutor method execute.

@Override
public void execute(ComplexEventChunk streamEventChunk) {
    LOG.debug("Event Chunk received by " + this.duration + " incremental executor: " + streamEventChunk.toString());
    streamEventChunk.reset();
    while (streamEventChunk.hasNext()) {
        StreamEvent streamEvent = (StreamEvent) streamEventChunk.next();
        streamEventChunk.remove();
        String timeZone = getTimeZone(streamEvent);
        long timestamp = getTimestamp(streamEvent, timeZone);
        startTimeOfAggregates = IncrementalTimeConverterUtil.getStartTimeOfAggregates(timestamp, duration, timeZone);
        if (isRootAndLoadedFromTable) {
            // arise when replaying data.
            if (timestamp < nextEmitTime) {
                continue;
            } else {
                isRootAndLoadedFromTable = false;
            }
        }
        if (bufferSize > 0 && isRoot) {
            try {
                mutex.acquire();
                dispatchBufferedAggregateEvents(startTimeOfAggregates);
            } catch (InterruptedException e) {
                Thread.currentThread().interrupt();
                throw new SiddhiAppRuntimeException("Error when dispatching events from buffer", e);
            } finally {
                mutex.release();
            }
            if (streamEvent.getType() == ComplexEvent.Type.CURRENT) {
                if (!eventOlderThanBuffer) {
                    processAggregates(streamEvent);
                } else if (!ignoreEventsOlderThanBuffer) {
                    // Incoming event is older than buffer
                    startTimeOfAggregates = minTimestampInBuffer;
                    processAggregates(streamEvent);
                }
            }
        } else {
            if (timestamp >= nextEmitTime) {
                nextEmitTime = IncrementalTimeConverterUtil.getNextEmitTime(timestamp, duration, timeZone);
                dispatchAggregateEvents(startTimeOfAggregates);
                if (!isProcessingOnExternalTime) {
                    sendTimerEvent(timeZone);
                }
            }
            if (streamEvent.getType() == ComplexEvent.Type.CURRENT) {
                if (nextEmitTime == IncrementalTimeConverterUtil.getNextEmitTime(timestamp, duration, timeZone)) {
                    // This condition checks whether incoming event belongs to current processing event's time slot
                    processAggregates(streamEvent);
                } else if (!ignoreEventsOlderThanBuffer) {
                    // Incoming event is older than current processing event.
                    startTimeOfAggregates = minTimestampInBuffer;
                    processAggregates(streamEvent);
                }
            }
        }
    }
}
Also used : MetaStreamEvent(org.ballerinalang.siddhi.core.event.stream.MetaStreamEvent) StreamEvent(org.ballerinalang.siddhi.core.event.stream.StreamEvent) SiddhiAppRuntimeException(org.ballerinalang.siddhi.core.exception.SiddhiAppRuntimeException)

Example 7 with SiddhiAppRuntimeException

use of org.ballerinalang.siddhi.core.exception.SiddhiAppRuntimeException in project ballerina by ballerina-lang.

the class WindowWindowProcessor method cloneProcessor.

@Override
public Processor cloneProcessor(String key) {
    try {
        WindowWindowProcessor streamProcessor = new WindowWindowProcessor(window);
        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 : ExpressionExecutor(org.ballerinalang.siddhi.core.executor.ExpressionExecutor) VariableExpressionExecutor(org.ballerinalang.siddhi.core.executor.VariableExpressionExecutor) SiddhiAppRuntimeException(org.ballerinalang.siddhi.core.exception.SiddhiAppRuntimeException) SiddhiAppRuntimeException(org.ballerinalang.siddhi.core.exception.SiddhiAppRuntimeException)

Example 8 with SiddhiAppRuntimeException

use of org.ballerinalang.siddhi.core.exception.SiddhiAppRuntimeException in project ballerina by ballerina-lang.

the class AttributeAggregator method cloneAggregator.

public AttributeAggregator cloneAggregator(String key) {
    try {
        AttributeAggregator attributeAggregator = this.getClass().newInstance();
        ExpressionExecutor[] innerExpressionExecutors = new ExpressionExecutor[attributeSize];
        for (int i = 0; i < attributeSize; i++) {
            innerExpressionExecutors[i] = attributeExpressionExecutors[i].cloneExecutor(key);
        }
        attributeAggregator.elementId = elementId + "-" + key;
        attributeAggregator.initAggregator(innerExpressionExecutors, siddhiAppContext, configReader);
        return attributeAggregator;
    } catch (Exception e) {
        throw new SiddhiAppRuntimeException("Exception in cloning " + this.getClass().getCanonicalName(), e);
    }
}
Also used : ExpressionExecutor(org.ballerinalang.siddhi.core.executor.ExpressionExecutor) SiddhiAppRuntimeException(org.ballerinalang.siddhi.core.exception.SiddhiAppRuntimeException) SiddhiAppCreationException(org.ballerinalang.siddhi.core.exception.SiddhiAppCreationException) SiddhiAppRuntimeException(org.ballerinalang.siddhi.core.exception.SiddhiAppRuntimeException)

Example 9 with SiddhiAppRuntimeException

use of org.ballerinalang.siddhi.core.exception.SiddhiAppRuntimeException in project ballerina by ballerina-lang.

the class TableWindowProcessor method cloneProcessor.

@Override
public Processor cloneProcessor(String key) {
    try {
        TableWindowProcessor streamProcessor = new TableWindowProcessor(table);
        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 : ExpressionExecutor(org.ballerinalang.siddhi.core.executor.ExpressionExecutor) VariableExpressionExecutor(org.ballerinalang.siddhi.core.executor.VariableExpressionExecutor) SiddhiAppRuntimeException(org.ballerinalang.siddhi.core.exception.SiddhiAppRuntimeException) SiddhiAppRuntimeException(org.ballerinalang.siddhi.core.exception.SiddhiAppRuntimeException)

Example 10 with SiddhiAppRuntimeException

use of org.ballerinalang.siddhi.core.exception.SiddhiAppRuntimeException in project ballerina by ballerina-lang.

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.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.ballerinalang.siddhi.core.executor.ExpressionExecutor) SiddhiAppRuntimeException(org.ballerinalang.siddhi.core.exception.SiddhiAppRuntimeException) SiddhiAppCreationException(org.ballerinalang.siddhi.core.exception.SiddhiAppCreationException) SiddhiAppRuntimeException(org.ballerinalang.siddhi.core.exception.SiddhiAppRuntimeException)

Aggregations

SiddhiAppRuntimeException (org.ballerinalang.siddhi.core.exception.SiddhiAppRuntimeException)13 ExpressionExecutor (org.ballerinalang.siddhi.core.executor.ExpressionExecutor)7 SiddhiAppCreationException (org.ballerinalang.siddhi.core.exception.SiddhiAppCreationException)6 ReturnAttribute (org.ballerinalang.siddhi.annotation.ReturnAttribute)3 MetaStreamEvent (org.ballerinalang.siddhi.core.event.stream.MetaStreamEvent)3 StreamEvent (org.ballerinalang.siddhi.core.event.stream.StreamEvent)3 VariableExpressionExecutor (org.ballerinalang.siddhi.core.executor.VariableExpressionExecutor)3 Attribute (org.ballerinalang.siddhi.query.api.definition.Attribute)3 ComplexEventChunk (org.ballerinalang.siddhi.core.event.ComplexEventChunk)2 IncrementalDataAggregator (org.ballerinalang.siddhi.core.aggregation.IncrementalDataAggregator)1 ComplexEvent (org.ballerinalang.siddhi.core.event.ComplexEvent)1 Event (org.ballerinalang.siddhi.core.event.Event)1 IncrementalUnixTimeFunctionExecutor (org.ballerinalang.siddhi.core.executor.incremental.IncrementalUnixTimeFunctionExecutor)1 Table (org.ballerinalang.siddhi.core.table.Table)1 TimePeriod (org.ballerinalang.siddhi.query.api.aggregation.TimePeriod)1 Expression (org.ballerinalang.siddhi.query.api.expression.Expression)1