use of org.wso2.siddhi.core.event.ComplexEventChunk in project siddhi by wso2.
the class StreamPostStateProcessor method process.
protected void process(StateEvent stateEvent, ComplexEventChunk complexEventChunk) {
thisStatePreProcessor.stateChanged();
StreamEvent streamEvent = stateEvent.getStreamEvent(stateId);
stateEvent.setTimestamp(streamEvent.getTimestamp());
if (nextProcessor != null) {
complexEventChunk.reset();
this.isEventReturned = true;
}
if (nextStatePerProcessor != null) {
nextStatePerProcessor.addState(stateEvent);
}
if (nextEveryStatePerProcessor != null) {
nextEveryStatePerProcessor.addEveryState(stateEvent);
}
if (callbackPreStateProcessor != null) {
callbackPreStateProcessor.startStateReset();
}
}
use of org.wso2.siddhi.core.event.ComplexEventChunk in project siddhi by wso2.
the class StreamPreStateProcessor method processAndReturn.
@Override
public ComplexEventChunk<StateEvent> processAndReturn(ComplexEventChunk complexEventChunk) {
ComplexEventChunk<StateEvent> returnEventChunk = new ComplexEventChunk<StateEvent>(false);
complexEventChunk.reset();
// Sure only one will be sent
StreamEvent streamEvent = (StreamEvent) complexEventChunk.next();
for (Iterator<StateEvent> iterator = pendingStateEventList.iterator(); iterator.hasNext(); ) {
StateEvent stateEvent = iterator.next();
if (withinStates.size() > 0) {
if (isExpired(stateEvent, streamEvent.getTimestamp())) {
iterator.remove();
continue;
}
}
// if (Math.abs(stateEvent.getTimestamp() - streamEvent.getTimestamp()) > withinStates) {
// iterator.remove();
// // switch (stateType) {
// // case PATTERN:
// // stateEvent.setEvent(stateId, null);
// // break;
// // case SEQUENCE:
// // stateEvent.setEvent(stateId, null);
// // iterator.remove();
// // if (thisStatePostProcessor.callbackPreStateProcessor != null) {
// // thisStatePostProcessor.callbackPreStateProcessor.startStateReset();
// // }
// // break;
// // }
// continue;
// }
// }
stateEvent.setEvent(stateId, streamEventCloner.copyStreamEvent(streamEvent));
process(stateEvent);
if (this.thisLastProcessor.isEventReturned()) {
this.thisLastProcessor.clearProcessedEvent();
returnEventChunk.add(stateEvent);
}
if (stateChanged) {
iterator.remove();
} else {
switch(stateType) {
case PATTERN:
stateEvent.setEvent(stateId, null);
break;
case SEQUENCE:
stateEvent.setEvent(stateId, null);
iterator.remove();
if (thisStatePostProcessor.callbackPreStateProcessor != null) {
thisStatePostProcessor.callbackPreStateProcessor.startStateReset();
}
break;
}
}
}
return returnEventChunk;
}
use of org.wso2.siddhi.core.event.ComplexEventChunk in project siddhi by wso2.
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.wso2.siddhi.core.event.ComplexEventChunk in project siddhi by wso2.
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.wso2.siddhi.core.event.ComplexEventChunk in project siddhi by wso2.
the class CronWindowProcessor method process.
@Override
protected void process(ComplexEventChunk<StreamEvent> streamEventChunk, Processor nextProcessor, StreamEventCloner streamEventCloner) {
synchronized (this) {
while (streamEventChunk.hasNext()) {
StreamEvent streamEvent = streamEventChunk.next();
StreamEvent clonedStreamEvent = streamEventCloner.copyStreamEvent(streamEvent);
currentEventChunk.add(clonedStreamEvent);
streamEventChunk.remove();
}
}
}
Aggregations