use of org.wso2.siddhi.core.event.ComplexEventChunk in project siddhi by wso2.
the class ProcessStreamReceiver method receive.
@Override
public void receive(Event event) {
if (event != null) {
StreamEvent borrowedEvent = streamEventPool.borrowEvent();
streamEventConverter.convertEvent(event, borrowedEvent);
if (siddhiDebugger != null) {
siddhiDebugger.checkBreakPoint(queryName, SiddhiDebugger.QueryTerminal.IN, borrowedEvent);
}
process(new ComplexEventChunk<StreamEvent>(borrowedEvent, borrowedEvent, this.batchProcessingAllowed));
}
}
use of org.wso2.siddhi.core.event.ComplexEventChunk in project siddhi by wso2.
the class ProcessStreamReceiver method receive.
@Override
public void receive(ComplexEvent complexEvents) {
if (siddhiDebugger != null) {
siddhiDebugger.checkBreakPoint(queryName, SiddhiDebugger.QueryTerminal.IN, complexEvents);
}
StreamEvent firstEvent = streamEventPool.borrowEvent();
streamEventConverter.convertComplexEvent(complexEvents, firstEvent);
StreamEvent currentEvent = firstEvent;
complexEvents = complexEvents.getNext();
while (complexEvents != null) {
StreamEvent nextEvent = streamEventPool.borrowEvent();
streamEventConverter.convertComplexEvent(complexEvents, nextEvent);
currentEvent.setNext(nextEvent);
currentEvent = nextEvent;
complexEvents = complexEvents.getNext();
}
process(new ComplexEventChunk<StreamEvent>(firstEvent, currentEvent, this.batchProcessingAllowed));
}
use of org.wso2.siddhi.core.event.ComplexEventChunk in project siddhi by wso2.
the class ProcessStreamReceiver method receive.
@Override
public void receive(long timestamp, Object[] data) {
StreamEvent borrowedEvent = streamEventPool.borrowEvent();
streamEventConverter.convertData(timestamp, data, borrowedEvent);
// Send to debugger
if (siddhiDebugger != null) {
siddhiDebugger.checkBreakPoint(queryName, SiddhiDebugger.QueryTerminal.IN, borrowedEvent);
}
process(new ComplexEventChunk<StreamEvent>(borrowedEvent, borrowedEvent, this.batchProcessingAllowed));
}
use of org.wso2.siddhi.core.event.ComplexEventChunk in project siddhi by wso2.
the class AbsentLogicalPostStateProcessor method process.
protected void process(StateEvent stateEvent, ComplexEventChunk complexEventChunk) {
// Mark the state changed
thisStatePreProcessor.stateChanged();
// Update the timestamp
StreamEvent streamEvent = stateEvent.getStreamEvent(stateId);
// This is the notification to AbsentStreamPreStateProcessor that this event has been processed
this.isEventReturned = true;
((AbsentPreStateProcessor) thisStatePreProcessor).updateLastArrivalTime(streamEvent.getTimestamp());
}
use of org.wso2.siddhi.core.event.ComplexEventChunk in project siddhi by wso2.
the class AbsentLogicalPreStateProcessor method process.
@Override
public void process(ComplexEventChunk complexEventChunk) {
if (!this.active) {
return;
}
this.lock.lock();
boolean notProcessed = true;
try {
long currentTime = complexEventChunk.getFirst().getTimestamp();
if (currentTime >= this.lastArrivalTime + waitingTime) {
ComplexEventChunk<StateEvent> retEventChunk = new ComplexEventChunk<>(false);
Iterator<StateEvent> iterator;
if (isStartState && stateType == StateInputStream.Type.SEQUENCE && newAndEveryStateEventList.isEmpty() && pendingStateEventList.isEmpty()) {
StateEvent stateEvent = stateEventPool.borrowEvent();
addState(stateEvent);
} else if (stateType == StateInputStream.Type.SEQUENCE && !newAndEveryStateEventList.isEmpty()) {
this.resetState();
}
this.updateState();
iterator = pendingStateEventList.iterator();
while (iterator.hasNext()) {
StateEvent stateEvent = iterator.next();
// Remove expired events based on within
if (withinStates.size() > 0) {
if (isExpired(stateEvent, currentTime)) {
iterator.remove();
continue;
}
}
// Collect the events that came before the waiting time
if (waitingTimePassed(currentTime, stateEvent)) {
iterator.remove();
if (logicalType == LogicalStateElement.Type.OR && stateEvent.getStreamEvent(partnerStatePreProcessor.getStateId()) == null) {
// OR Partner not received
stateEvent.addEvent(stateId, streamEventPool.borrowEvent());
retEventChunk.add(stateEvent);
} else if (logicalType == LogicalStateElement.Type.AND && stateEvent.getStreamEvent(partnerStatePreProcessor.getStateId()) != null) {
// AND partner received but didn't send out
retEventChunk.add(stateEvent);
} else if (logicalType == LogicalStateElement.Type.AND && stateEvent.getStreamEvent(partnerStatePreProcessor.getStateId()) == null) {
// AND partner didn't receive
// Let the partner to process or not
stateEvent.addEvent(stateId, streamEventPool.borrowEvent());
}
}
}
retEventChunk.reset();
notProcessed = retEventChunk.getFirst() == null;
while (retEventChunk.hasNext()) {
StateEvent stateEvent = retEventChunk.next();
retEventChunk.remove();
sendEvent(stateEvent);
}
this.lastArrivalTime = 0;
}
} finally {
this.lock.unlock();
}
if (thisStatePostProcessor.nextEveryStatePerProcessor != null || (notProcessed && isStartState)) {
// If every or (notProcessed and startState), schedule again
long nextBreak;
if (lastArrivalTime == 0) {
nextBreak = siddhiAppContext.getTimestampGenerator().currentTime() + waitingTime;
} else {
nextBreak = lastArrivalTime + waitingTime;
}
this.scheduler.notifyAt(nextBreak);
}
}
Aggregations