use of org.ballerinalang.siddhi.core.event.ComplexEvent in project ballerina by ballerina-lang.
the class FilterProcessor method process.
@Override
public void process(ComplexEventChunk complexEventChunk) {
complexEventChunk.reset();
while (complexEventChunk.hasNext()) {
ComplexEvent complexEvent = complexEventChunk.next();
Object result = conditionExecutor.execute(complexEvent);
if (result == null || !(Boolean) result) {
complexEventChunk.remove();
}
}
if (complexEventChunk.getFirst() != null) {
this.next.process(complexEventChunk);
}
}
use of org.ballerinalang.siddhi.core.event.ComplexEvent in project ballerina by ballerina-lang.
the class LogStreamProcessor method process.
@Override
protected void process(ComplexEventChunk<StreamEvent> streamEventChunk, Processor nextProcessor, StreamEventCloner streamEventCloner, ComplexEventPopulater complexEventPopulater) {
while (streamEventChunk.hasNext()) {
ComplexEvent complexEvent = streamEventChunk.next();
switch(attributeExpressionLength) {
case 0:
log.info(logPrefix + complexEvent);
break;
case 1:
if (isLogEventExpressionExecutor != null) {
if ((Boolean) isLogEventExpressionExecutor.execute(complexEvent)) {
log.info(logPrefix + complexEvent);
} else {
log.info(logPrefix + "Event Arrived");
}
} else {
log.info(logPrefix + logMessageExpressionExecutor.execute(complexEvent) + ", " + complexEvent);
}
break;
case 2:
if (isLogEventExpressionExecutor != null) {
if ((Boolean) isLogEventExpressionExecutor.execute(complexEvent)) {
log.info(logPrefix + logMessageExpressionExecutor.execute(complexEvent) + ", " + complexEvent);
} else {
log.info(logPrefix + logMessageExpressionExecutor.execute(complexEvent));
}
} else {
LogPriority tempLogPriority = logPriority;
if (logPriorityExpressionExecutor != null) {
tempLogPriority = LogPriority.valueOf((String) logPriorityExpressionExecutor.execute(complexEvent));
}
String message = logPrefix + logMessageExpressionExecutor.execute(complexEvent) + ", " + complexEvent;
logMessage(tempLogPriority, message);
}
break;
default:
String message;
if ((Boolean) isLogEventExpressionExecutor.execute(complexEvent)) {
message = logPrefix + logMessageExpressionExecutor.execute(complexEvent) + ", " + complexEvent;
} else {
message = logPrefix + logMessageExpressionExecutor.execute(complexEvent);
}
LogPriority tempLogPriority = logPriority;
if (logPriorityExpressionExecutor != null) {
tempLogPriority = LogPriority.valueOf((String) logPriorityExpressionExecutor.execute(complexEvent));
}
logMessage(tempLogPriority, message);
}
}
nextProcessor.process(streamEventChunk);
}
use of org.ballerinalang.siddhi.core.event.ComplexEvent in project ballerina by ballerina-lang.
the class StreamFunctionProcessor method processEventChunk.
@Override
protected void processEventChunk(ComplexEventChunk<StreamEvent> streamEventChunk, Processor nextProcessor, StreamEventCloner streamEventCloner, ComplexEventPopulater complexEventPopulater) {
while (streamEventChunk.hasNext()) {
ComplexEvent complexEvent = streamEventChunk.next();
Object[] outputData;
switch(attributeExpressionLength) {
case 0:
outputData = process((Object) null);
complexEventPopulater.populateComplexEvent(complexEvent, outputData);
break;
case 1:
outputData = process(attributeExpressionExecutors[0].execute(complexEvent));
complexEventPopulater.populateComplexEvent(complexEvent, outputData);
break;
default:
Object[] inputData = new Object[attributeExpressionLength];
for (int i = 0; i < attributeExpressionLength; i++) {
inputData[i] = attributeExpressionExecutors[i].execute(complexEvent);
}
outputData = process(inputData);
complexEventPopulater.populateComplexEvent(complexEvent, outputData);
}
}
nextProcessor.process(streamEventChunk);
}
use of org.ballerinalang.siddhi.core.event.ComplexEvent in project ballerina by ballerina-lang.
the class FirstGroupByPerEventOutputRateLimiter method process.
@Override
public void process(ComplexEventChunk complexEventChunk) {
complexEventChunk.reset();
ArrayList<ComplexEventChunk<ComplexEvent>> outputEventChunks = new ArrayList<ComplexEventChunk<ComplexEvent>>();
synchronized (this) {
while (complexEventChunk.hasNext()) {
ComplexEvent event = complexEventChunk.next();
if (event.getType() == ComplexEvent.Type.CURRENT || event.getType() == ComplexEvent.Type.EXPIRED) {
complexEventChunk.remove();
GroupedComplexEvent groupedComplexEvent = ((GroupedComplexEvent) event);
if (!groupByKeys.contains(groupedComplexEvent.getGroupKey())) {
groupByKeys.add(groupedComplexEvent.getGroupKey());
allComplexEventChunk.add(groupedComplexEvent.getComplexEvent());
}
if (++counter == value) {
if (allComplexEventChunk.getFirst() != null) {
ComplexEventChunk<ComplexEvent> outputEventChunk = new ComplexEventChunk<ComplexEvent>(complexEventChunk.isBatch());
outputEventChunk.add(allComplexEventChunk.getFirst());
outputEventChunks.add(outputEventChunk);
allComplexEventChunk.clear();
counter = 0;
groupByKeys.clear();
} else {
counter = 0;
groupByKeys.clear();
}
}
}
}
}
for (ComplexEventChunk eventChunk : outputEventChunks) {
sendToCallBacks(eventChunk);
}
}
use of org.ballerinalang.siddhi.core.event.ComplexEvent in project ballerina by ballerina-lang.
the class FirstPerEventOutputRateLimiter method process.
@Override
public void process(ComplexEventChunk complexEventChunk) {
complexEventChunk.reset();
ArrayList<ComplexEventChunk<ComplexEvent>> outputEventChunks = new ArrayList<ComplexEventChunk<ComplexEvent>>();
synchronized (this) {
while (complexEventChunk.hasNext()) {
ComplexEvent event = complexEventChunk.next();
if (event.getType() == ComplexEvent.Type.CURRENT || event.getType() == ComplexEvent.Type.EXPIRED) {
if (counter == 0) {
complexEventChunk.remove();
ComplexEventChunk<ComplexEvent> firstPerEventChunk = new ComplexEventChunk<ComplexEvent>(complexEventChunk.isBatch());
firstPerEventChunk.add(event);
outputEventChunks.add(firstPerEventChunk);
}
if (++counter == value) {
counter = 0;
}
}
}
}
for (ComplexEventChunk eventChunk : outputEventChunks) {
sendToCallBacks(eventChunk);
}
}
Aggregations