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