use of org.wso2.siddhi.core.event.stream.StreamEvent in project siddhi by wso2.
the class AbsentStreamPostStateProcessor method process.
/**
* This method just mark the state changed but does not send the stateEvent to the next processors.
*
* @param stateEvent the state event
* @param complexEventChunk the ComplexEventChunk
*/
protected void process(StateEvent stateEvent, ComplexEventChunk complexEventChunk) {
// Mark the state changed
thisStatePreProcessor.stateChanged();
// Update the timestamp
StreamEvent streamEvent = stateEvent.getStreamEvent(stateId);
stateEvent.setTimestamp(streamEvent.getTimestamp());
// This is the notification to AbsentStreamPreStateProcessor that this event has been processed
this.isEventReturned = true;
if (thisStatePreProcessor.isStartState) {
if (nextEveryStatePerProcessor != null && nextEveryStatePerProcessor == thisStatePreProcessor) {
// nextEveryStatePerProcessor refers the AbsentStreamPreStateProcessor
nextEveryStatePerProcessor.addEveryState(stateEvent);
}
}
((AbsentPreStateProcessor) thisStatePreProcessor).updateLastArrivalTime(streamEvent.getTimestamp());
}
use of org.wso2.siddhi.core.event.stream.StreamEvent in project siddhi by wso2.
the class CountPostStateProcessor method process.
protected void process(StateEvent stateEvent, ComplexEventChunk complexEventChunk) {
StreamEvent streamEvent = stateEvent.getStreamEvent(stateId);
int streamEvents = 1;
while (streamEvent.getNext() != null) {
streamEvents++;
streamEvent = streamEvent.getNext();
}
((CountPreStateProcessor) thisStatePreProcessor).successCondition();
stateEvent.setTimestamp(streamEvent.getTimestamp());
if (streamEvents >= minCount) {
if (thisStatePreProcessor.stateType == StateInputStream.Type.SEQUENCE) {
if (nextStatePerProcessor != null) {
nextStatePerProcessor.addState(stateEvent);
}
if (streamEvents != maxCount) {
thisStatePreProcessor.addState(stateEvent);
}
} else if (streamEvents == minCount) {
processMinCountReached(stateEvent, complexEventChunk);
}
if (streamEvents == maxCount) {
thisStatePreProcessor.stateChanged();
}
}
}
use of org.wso2.siddhi.core.event.stream.StreamEvent in project siddhi by wso2.
the class CountPreStateProcessor 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 (removeIfNextStateProcessed(stateEvent, iterator, stateId + 1)) {
continue;
}
if (removeIfNextStateProcessed(stateEvent, iterator, stateId + 2)) {
continue;
}
stateEvent.addEvent(stateId, streamEventCloner.copyStreamEvent(streamEvent));
successCondition = false;
process(stateEvent);
if (this.thisLastProcessor.isEventReturned()) {
this.thisLastProcessor.clearProcessedEvent();
returnEventChunk.add(stateEvent);
}
if (stateChanged) {
iterator.remove();
}
if (!successCondition) {
switch(stateType) {
case PATTERN:
stateEvent.removeLastEvent(stateId);
break;
case SEQUENCE:
stateEvent.removeLastEvent(stateId);
iterator.remove();
break;
}
}
}
return returnEventChunk;
}
use of org.wso2.siddhi.core.event.stream.StreamEvent in project siddhi by wso2.
the class LogicalPreStateProcessor 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 (logicalType == LogicalStateElement.Type.OR && stateEvent.getStreamEvent(partnerStatePreProcessor.getStateId()) != null) {
iterator.remove();
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();
break;
}
}
}
return returnEventChunk;
}
use of org.wso2.siddhi.core.event.stream.StreamEvent 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();
}
}
Aggregations