use of io.siddhi.core.event.ComplexEvent in project siddhi by wso2.
the class InsertIntoTableCallback method send.
@Override
public void send(ComplexEventChunk complexEventChunk, int noOfEvents) {
if (getSiddhiDebugger() != null) {
getSiddhiDebugger().checkBreakPoint(getQueryName(), SiddhiDebugger.QueryTerminal.OUT, complexEventChunk.getFirst());
}
if (convertToStreamEvent) {
ComplexEventChunk<StreamEvent> streamEventChunk = new ComplexEventChunk<StreamEvent>();
complexEventChunk.reset();
while (complexEventChunk.hasNext()) {
ComplexEvent complexEvent = complexEventChunk.next();
StreamEvent borrowEvent = streamEventFactory.newInstance();
streamEventConverter.convertData(complexEvent.getTimestamp(), complexEvent.getOutputData(), complexEvent.getType(), borrowEvent);
streamEventChunk.add(borrowEvent);
}
table.addEvents(streamEventChunk, noOfEvents);
} else {
table.addEvents((ComplexEventChunk<StreamEvent>) complexEventChunk, noOfEvents);
}
}
use of io.siddhi.core.event.ComplexEvent in project siddhi by wso2.
the class InsertIntoWindowEndPartitionCallback method send.
/**
* Add the event into the {@link Window}
*
* @param complexEventChunk the event to add
* @param noOfEvents number of events
*/
@Override
public void send(ComplexEventChunk complexEventChunk, int noOfEvents) {
if (getSiddhiDebugger() != null) {
getSiddhiDebugger().checkBreakPoint(getQueryName(), SiddhiDebugger.QueryTerminal.OUT, complexEventChunk.getFirst());
}
// If events are inserted directly from another window, expired events can arrive
complexEventChunk.reset();
if (complexEventChunk.getFirst() != null) {
String flowId = SiddhiAppContext.getCurrentFlowId();
SiddhiAppContext.stopPartitionFlow();
try {
while (complexEventChunk.hasNext()) {
ComplexEvent complexEvent = complexEventChunk.next();
if (complexEvent.getType() == ComplexEvent.Type.EXPIRED) {
complexEvent.setType(ComplexEvent.Type.CURRENT);
}
}
window.add(complexEventChunk);
} finally {
SiddhiAppContext.startPartitionFlow(flowId);
}
}
}
use of io.siddhi.core.event.ComplexEvent in project siddhi by wso2.
the class OutputRateLimiter method process.
public void process(List<ComplexEventChunk> complexEventChunks) {
ComplexEventChunk<ComplexEvent> complexEventChunk = new ComplexEventChunk<>();
for (ComplexEventChunk aComplexEventChunk : complexEventChunks) {
complexEventChunk.addAll(aComplexEventChunk);
}
process(complexEventChunk);
}
use of io.siddhi.core.event.ComplexEvent in project siddhi by wso2.
the class OutputRateLimiter method sendToCallBacks.
public void sendToCallBacks(ComplexEventChunk complexEventChunk) {
MultiProcessStreamReceiver.ReturnEventHolder returnEventHolder = MultiProcessStreamReceiver.getMultiProcessReturn().get();
if (Level.BASIC.compareTo(siddhiQueryContext.getSiddhiAppContext().getRootMetricsLevel()) <= 0 && latencyTracker != null) {
latencyTracker.markOut();
}
if (returnEventHolder != null) {
returnEventHolder.setReturnEvents(complexEventChunk);
return;
} else if (lockWrapper != null) {
lockWrapper.unlock();
}
if (Level.BASIC.compareTo(siddhiQueryContext.getSiddhiAppContext().getRootMetricsLevel()) <= 0 && latencyTracker != null) {
latencyTracker.markOut();
}
if (lockWrapper != null) {
lockWrapper.unlock();
}
if (!queryCallbacks.isEmpty()) {
for (QueryCallback callback : queryCallbacks) {
callback.receiveStreamEvent(complexEventChunk);
}
}
if (outputCallback != null && complexEventChunk.getFirst() != null) {
complexEventChunk.reset();
int noOfEvents = 0;
while (complexEventChunk.hasNext()) {
ComplexEvent complexEvent = complexEventChunk.next();
if (complexEvent.getType() == ComplexEvent.Type.EXPIRED) {
complexEvent.setType(ComplexEvent.Type.CURRENT);
noOfEvents++;
} else if (complexEvent.getType() == ComplexEvent.Type.RESET) {
complexEventChunk.remove();
} else {
noOfEvents++;
}
}
if (complexEventChunk.getFirst() != null) {
outputCallback.send(complexEventChunk, noOfEvents);
}
}
}
use of io.siddhi.core.event.ComplexEvent in project siddhi by wso2.
the class FirstPerEventOutputRateLimiter method process.
@Override
public void process(ComplexEventChunk complexEventChunk) {
complexEventChunk.reset();
ComplexEventChunk<ComplexEvent> outputEventChunk = new ComplexEventChunk<>();
RateLimiterState state = stateHolder.getState();
try {
synchronized (state) {
while (complexEventChunk.hasNext()) {
ComplexEvent event = complexEventChunk.next();
complexEventChunk.remove();
state.counter++;
if (state.counter == 1) {
outputEventChunk.add(event);
} else if (state.counter == value) {
state.counter = 0;
}
}
}
} finally {
stateHolder.returnState(state);
}
outputEventChunk.reset();
if (outputEventChunk.hasNext()) {
sendToCallBacks(outputEventChunk);
}
}
Aggregations