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