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;
}
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;
}
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();
}
}
}
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);
}
}
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();
}
}
}
Aggregations