Search in sources :

Example 1 with SiddhiAppRuntimeException

use of io.siddhi.core.exception.SiddhiAppRuntimeException in project siddhi by wso2.

the class ExpressionBatchWindowProcessor method constructExpression.

private MetaStateEvent constructExpression(MetaStreamEvent metaStreamEvent, SiddhiQueryContext siddhiQueryContext) {
    Expression expression = SiddhiCompiler.parseExpression(expressionString);
    MetaStreamEvent metaStreamEventFirst = new MetaStreamEventWrapper(metaStreamEvent);
    metaStreamEventFirst.setInputReferenceId("first");
    MetaStreamEvent metaStreamEventLast = new MetaStreamEventWrapper(metaStreamEvent);
    metaStreamEventLast.setInputReferenceId("last");
    MetaStateEvent metaStateEvent = new MetaStateEvent(new MetaStreamEvent[] { metaStreamEvent, metaStreamEventFirst, metaStreamEventLast });
    variableExpressionExecutors = new ArrayList<>();
    SiddhiQueryContext exprQueryContext = new SiddhiOnDemandQueryContext(siddhiQueryContext.getSiddhiAppContext(), siddhiQueryContext.getName(), expressionString);
    expressionExecutor = ExpressionParser.parseExpression(expression, metaStateEvent, 0, new HashMap<>(), variableExpressionExecutors, false, 0, ProcessingMode.SLIDE, true, exprQueryContext);
    if (expressionExecutor.getReturnType() != Attribute.Type.BOOL) {
        throw new SiddhiAppRuntimeException("Expression ('" + expressionString + "') does not return Bool");
    }
    return metaStateEvent;
}
Also used : SiddhiQueryContext(io.siddhi.core.config.SiddhiQueryContext) Expression(io.siddhi.query.api.expression.Expression) HashMap(java.util.HashMap) SiddhiAppRuntimeException(io.siddhi.core.exception.SiddhiAppRuntimeException) SiddhiOnDemandQueryContext(io.siddhi.core.config.SiddhiOnDemandQueryContext) MetaStreamEvent(io.siddhi.core.event.stream.MetaStreamEvent) MetaStateEvent(io.siddhi.core.event.state.MetaStateEvent)

Example 2 with SiddhiAppRuntimeException

use of io.siddhi.core.exception.SiddhiAppRuntimeException in project siddhi by wso2.

the class ExpressionWindowProcessor method constructExpression.

private MetaStateEvent constructExpression(MetaStreamEvent metaStreamEvent, SiddhiQueryContext siddhiQueryContext) {
    Expression expression = SiddhiCompiler.parseExpression(expressionString);
    MetaStreamEvent metaStreamEventFirst = new MetaStreamEventWrapper(metaStreamEvent);
    metaStreamEventFirst.setInputReferenceId("first");
    MetaStreamEvent metaStreamEventLast = new MetaStreamEventWrapper(metaStreamEvent);
    metaStreamEventLast.setInputReferenceId("last");
    MetaStateEvent metaStateEvent = new MetaStateEvent(new MetaStreamEvent[] { metaStreamEvent, metaStreamEventFirst, metaStreamEventLast });
    variableExpressionExecutors = new ArrayList<>();
    SiddhiQueryContext exprQueryContext = new SiddhiOnDemandQueryContext(siddhiQueryContext.getSiddhiAppContext(), siddhiQueryContext.getName(), expressionString);
    expressionExecutor = ExpressionParser.parseExpression(expression, metaStateEvent, 0, new HashMap<>(), variableExpressionExecutors, false, 0, ProcessingMode.SLIDE, true, exprQueryContext);
    if (expressionExecutor.getReturnType() != Attribute.Type.BOOL) {
        throw new SiddhiAppRuntimeException("Expression ('" + expressionString + "') does not return Bool");
    }
    return metaStateEvent;
}
Also used : SiddhiQueryContext(io.siddhi.core.config.SiddhiQueryContext) Expression(io.siddhi.query.api.expression.Expression) HashMap(java.util.HashMap) SiddhiAppRuntimeException(io.siddhi.core.exception.SiddhiAppRuntimeException) SiddhiOnDemandQueryContext(io.siddhi.core.config.SiddhiOnDemandQueryContext) MetaStreamEvent(io.siddhi.core.event.stream.MetaStreamEvent) MetaStateEvent(io.siddhi.core.event.state.MetaStateEvent)

Example 3 with SiddhiAppRuntimeException

use of io.siddhi.core.exception.SiddhiAppRuntimeException in project siddhi by wso2.

the class PartitionStateHolder method returnAllStates.

@Override
public void returnAllStates(Map states) {
    for (Iterator<Map.Entry<String, Map<String, State>>> statesIterator = ((Set<Map.Entry<String, Map<String, State>>>) states.entrySet()).iterator(); statesIterator.hasNext(); ) {
        Map.Entry<String, Map<String, State>> statesEntry = statesIterator.next();
        for (Iterator<Map.Entry<String, State>> stateIterator = statesEntry.getValue().entrySet().iterator(); stateIterator.hasNext(); ) {
            Map.Entry<String, State> stateEntry = stateIterator.next();
            State state = stateEntry.getValue();
            if (state.activeUseCount == 0) {
                try {
                    if (state.canDestroy()) {
                        stateIterator.remove();
                    }
                } catch (Throwable t) {
                    log.error("Dropping partition state for partition key '" + statesEntry.getKey() + "' and the group by key '" + stateEntry.getKey() + "', due to error! " + t.getMessage(), t);
                    stateIterator.remove();
                }
            } else if (state.activeUseCount < 0) {
                throw new SiddhiAppRuntimeException("State active count has reached less then zero for " + "partition key '" + statesEntry.getKey() + "' and the group by key '" + stateEntry.getKey() + "', current value is " + state.activeUseCount);
            }
        }
        if (statesEntry.getValue().isEmpty()) {
            statesIterator.remove();
        }
    }
}
Also used : Set(java.util.Set) SiddhiAppRuntimeException(io.siddhi.core.exception.SiddhiAppRuntimeException) Map(java.util.Map) HashMap(java.util.HashMap)

Example 4 with SiddhiAppRuntimeException

use of io.siddhi.core.exception.SiddhiAppRuntimeException in project siddhi by wso2.

the class SiddhiAppRuntimeImpl method removeCallback.

public void removeCallback(StreamCallback streamCallback) {
    if (streamCallback.getStreamId() == null) {
        throw new SiddhiAppRuntimeException("Cannot find streamID in the streamCallback");
    }
    String streamId = streamCallback.getStreamId();
    StreamJunction streamJunction = streamJunctionMap.get(streamId);
    if (streamJunction != null) {
        streamJunction.unsubscribe(streamCallback);
    }
}
Also used : StreamJunction(io.siddhi.core.stream.StreamJunction) SiddhiAppRuntimeException(io.siddhi.core.exception.SiddhiAppRuntimeException)

Example 5 with SiddhiAppRuntimeException

use of io.siddhi.core.exception.SiddhiAppRuntimeException in project siddhi by wso2.

the class IncrementalAggregationProcessor method process.

@Override
public void process(ComplexEventChunk complexEventChunk) {
    ComplexEventChunk<StreamEvent> streamEventChunk = new ComplexEventChunk<>();
    try {
        int noOfEvents = 0;
        if (latencyTrackerInsert != null && Level.BASIC.compareTo(siddhiAppContext.getRootMetricsLevel()) <= 0) {
            latencyTrackerInsert.markIn();
        }
        while (complexEventChunk.hasNext()) {
            ComplexEvent complexEvent = complexEventChunk.next();
            if (!isFirstEventArrived) {
                aggregationRuntime.initialiseExecutors(true);
                isFirstEventArrived = true;
            }
            StreamEvent newEvent = streamEventFactory.newInstance();
            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");
                }
                newEvent.setOutputData(outputData, i);
            }
            streamEventChunk.add(newEvent);
            noOfEvents++;
        }
        aggregationRuntime.processEvents(streamEventChunk);
        if (throughputTrackerInsert != null && Level.BASIC.compareTo(siddhiAppContext.getRootMetricsLevel()) <= 0) {
            throughputTrackerInsert.eventsIn(noOfEvents);
        }
    } finally {
        if (latencyTrackerInsert != null && Level.BASIC.compareTo(siddhiAppContext.getRootMetricsLevel()) <= 0) {
            latencyTrackerInsert.markOut();
        }
    }
}
Also used : ComplexEvent(io.siddhi.core.event.ComplexEvent) ComplexEventChunk(io.siddhi.core.event.ComplexEventChunk) ExpressionExecutor(io.siddhi.core.executor.ExpressionExecutor) StreamEvent(io.siddhi.core.event.stream.StreamEvent) MetaStreamEvent(io.siddhi.core.event.stream.MetaStreamEvent) SiddhiAppRuntimeException(io.siddhi.core.exception.SiddhiAppRuntimeException) IncrementalUnixTimeFunctionExecutor(io.siddhi.core.executor.incremental.IncrementalUnixTimeFunctionExecutor)

Aggregations

SiddhiAppRuntimeException (io.siddhi.core.exception.SiddhiAppRuntimeException)19 HashMap (java.util.HashMap)7 MetaStreamEvent (io.siddhi.core.event.stream.MetaStreamEvent)5 StreamEvent (io.siddhi.core.event.stream.StreamEvent)5 Attribute (io.siddhi.query.api.definition.Attribute)5 ReturnAttribute (io.siddhi.annotation.ReturnAttribute)4 SiddhiAppCreationException (io.siddhi.core.exception.SiddhiAppCreationException)4 Expression (io.siddhi.query.api.expression.Expression)4 Map (java.util.Map)4 ComplexEventChunk (io.siddhi.core.event.ComplexEventChunk)3 MetaStateEvent (io.siddhi.core.event.state.MetaStateEvent)3 Set (java.util.Set)3 SiddhiOnDemandQueryContext (io.siddhi.core.config.SiddhiOnDemandQueryContext)2 SiddhiQueryContext (io.siddhi.core.config.SiddhiQueryContext)2 ComplexEvent (io.siddhi.core.event.ComplexEvent)2 StateEvent (io.siddhi.core.event.state.StateEvent)2 ExpressionExecutor (io.siddhi.core.executor.ExpressionExecutor)2 TreeMap (java.util.TreeMap)2 IncrementalDataAggregator (io.siddhi.core.aggregation.IncrementalDataAggregator)1 OutOfOrderEventsDataAggregator (io.siddhi.core.aggregation.OutOfOrderEventsDataAggregator)1