Search in sources :

Example 1 with SiddhiAppRuntimeException

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

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 : 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 2 with SiddhiAppRuntimeException

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

the class MaxIncrementalAttributeAggregator method init.

@Override
public void init(String attributeName, Attribute.Type attributeType) {
    if (attributeName == null) {
        throw new SiddhiAppCreationException("Max incremental attribute aggregation cannot be executed " + "when no parameters are given");
    }
    if (attributeType.equals(Attribute.Type.INT) || attributeType.equals(Attribute.Type.LONG) || attributeType.equals(Attribute.Type.DOUBLE) || attributeType.equals(Attribute.Type.FLOAT)) {
        this.baseAttributes = new Attribute[] { new Attribute("AGG_MAX_".concat(attributeName), attributeType) };
        this.baseAttributesInitialValues = new Expression[] { Expression.variable(attributeName) };
        this.returnType = attributeType;
        assert baseAttributes.length == baseAttributesInitialValues.length;
    } else {
        throw new SiddhiAppRuntimeException("Max aggregation cannot be executed on attribute type " + attributeType.toString());
    }
}
Also used : Attribute(org.ballerinalang.siddhi.query.api.definition.Attribute) ReturnAttribute(org.ballerinalang.siddhi.annotation.ReturnAttribute) SiddhiAppCreationException(org.ballerinalang.siddhi.core.exception.SiddhiAppCreationException) SiddhiAppRuntimeException(org.ballerinalang.siddhi.core.exception.SiddhiAppRuntimeException)

Example 3 with SiddhiAppRuntimeException

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

the class PassThroughSourceMapper method mapAndProcess.

@Override
protected void mapAndProcess(Object eventObject, InputEventHandler inputEventHandler) throws InterruptedException {
    if (eventObject != null) {
        if (eventObject instanceof Event[]) {
            inputEventHandler.sendEvents((Event[]) eventObject);
        } else if (eventObject instanceof Event) {
            inputEventHandler.sendEvent((Event) eventObject);
        } else if (eventObject instanceof Object[]) {
            Event event = new Event(-1, (Object[]) eventObject);
            inputEventHandler.sendEvent(event);
        } else {
            throw new SiddhiAppRuntimeException("Event object must be either Event[], Event or Object[] " + "but found " + eventObject.getClass().getCanonicalName());
        }
    }
}
Also used : SiddhiAppRuntimeException(org.ballerinalang.siddhi.core.exception.SiddhiAppRuntimeException) Event(org.ballerinalang.siddhi.core.event.Event)

Example 4 with SiddhiAppRuntimeException

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

the class FunctionExecutor method cloneExecutor.

@Override
public ExpressionExecutor cloneExecutor(String key) {
    try {
        FunctionExecutor functionExecutor = this.getClass().newInstance();
        ExpressionExecutor[] innerExpressionExecutors = new ExpressionExecutor[attributeSize];
        for (int i = 0; i < attributeSize; i++) {
            innerExpressionExecutors[i] = attributeExpressionExecutors[i].cloneExecutor(key);
        }
        functionExecutor.elementId = elementId + "-" + key;
        functionExecutor.functionId = functionId;
        functionExecutor.initExecutor(innerExpressionExecutors, siddhiAppContext, queryName, configReader);
        return functionExecutor;
    } 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 5 with SiddhiAppRuntimeException

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

the class IncrementalAggregationProcessor method process.

@Override
public void process(ComplexEventChunk complexEventChunk) {
    ComplexEventChunk<StreamEvent> streamEventChunk = new ComplexEventChunk<>(complexEventChunk.isBatch());
    try {
        int noOfEvents = 0;
        if (latencyTrackerInsert != null && siddhiAppContext.isStatsEnabled()) {
            latencyTrackerInsert.markIn();
        }
        while (complexEventChunk.hasNext()) {
            ComplexEvent complexEvent = complexEventChunk.next();
            StreamEvent borrowedEvent = streamEventPool.borrowEvent();
            for (int i = 0; i < incomingExpressionExecutors.size(); i++) {
                ExpressionExecutor expressionExecutor = incomingExpressionExecutors.get(i);
                Object outputData = expressionExecutor.execute(complexEvent);
                if (expressionExecutor instanceof IncrementalUnixTimeFunctionExecutor && outputData == null) {
                    throw new SiddhiAppRuntimeException("Cannot retrieve the timestamp of event");
                }
                borrowedEvent.setOutputData(outputData, i);
            }
            streamEventChunk.add(borrowedEvent);
            noOfEvents++;
        }
        incrementalExecutor.execute(streamEventChunk);
        if (throughputTrackerInsert != null && siddhiAppContext.isStatsEnabled()) {
            throughputTrackerInsert.eventsIn(noOfEvents);
        }
    } finally {
        if (latencyTrackerInsert != null && siddhiAppContext.isStatsEnabled()) {
            latencyTrackerInsert.markOut();
        }
    }
}
Also used : ComplexEvent(org.ballerinalang.siddhi.core.event.ComplexEvent) ComplexEventChunk(org.ballerinalang.siddhi.core.event.ComplexEventChunk) ExpressionExecutor(org.ballerinalang.siddhi.core.executor.ExpressionExecutor) MetaStreamEvent(org.ballerinalang.siddhi.core.event.stream.MetaStreamEvent) StreamEvent(org.ballerinalang.siddhi.core.event.stream.StreamEvent) SiddhiAppRuntimeException(org.ballerinalang.siddhi.core.exception.SiddhiAppRuntimeException) IncrementalUnixTimeFunctionExecutor(org.ballerinalang.siddhi.core.executor.incremental.IncrementalUnixTimeFunctionExecutor)

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