use of io.siddhi.core.event.ComplexEventChunk 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.ComplexEventChunk 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);
}
}
use of io.siddhi.core.event.ComplexEventChunk in project siddhi by wso2.
the class AggregationWindowedPerSnapshotOutputRateLimiter method process.
@Override
public void process(ComplexEventChunk complexEventChunk) {
complexEventChunk.reset();
List<ComplexEventChunk> outputEventChunks = new LinkedList<>();
AggregationRateLimiterState state = stateHolder.getState();
try {
synchronized (state) {
while (complexEventChunk.hasNext()) {
ComplexEvent event = complexEventChunk.next();
if (event.getType() == ComplexEvent.Type.TIMER) {
tryFlushEvents(outputEventChunks, event, state);
} else {
complexEventChunk.remove();
tryFlushEvents(outputEventChunks, event, state);
if (event.getType() == ComplexEvent.Type.CURRENT) {
state.eventList.add(event);
for (Integer position : aggregateAttributePositionList) {
state.aggregateAttributeValueMap.put(position, event.getOutputData()[position]);
}
} else if (event.getType() == ComplexEvent.Type.EXPIRED) {
for (Iterator<ComplexEvent> iterator = state.eventList.iterator(); iterator.hasNext(); ) {
ComplexEvent complexEvent = iterator.next();
if (comparator.compare(event, complexEvent) == 0) {
iterator.remove();
for (Integer position : aggregateAttributePositionList) {
state.aggregateAttributeValueMap.put(position, event.getOutputData()[position]);
}
break;
}
}
} else if (event.getType() == ComplexEvent.Type.RESET) {
state.eventList.clear();
state.aggregateAttributeValueMap.clear();
}
}
}
}
} finally {
stateHolder.returnState(state);
}
sendToCallBacks(outputEventChunks);
}
use of io.siddhi.core.event.ComplexEventChunk in project siddhi by wso2.
the class PerSnapshotOutputRateLimiter method process.
@Override
public void process(ComplexEventChunk complexEventChunk) {
List<ComplexEventChunk> outputEventChunks = new LinkedList<>();
complexEventChunk.reset();
RateLimiterState state = stateHolder.getState();
try {
synchronized (state) {
while (complexEventChunk.hasNext()) {
ComplexEvent event = complexEventChunk.next();
if (event.getType() == ComplexEvent.Type.TIMER) {
tryFlushEvents(outputEventChunks, event, state);
} else if (event.getType() == ComplexEvent.Type.CURRENT) {
complexEventChunk.remove();
tryFlushEvents(outputEventChunks, event, state);
state.lastEvent = event;
} else {
tryFlushEvents(outputEventChunks, event, state);
}
}
}
} finally {
stateHolder.returnState(state);
}
sendToCallBacks(outputEventChunks);
}
use of io.siddhi.core.event.ComplexEventChunk in project siddhi by wso2.
the class WindowedPerSnapshotOutputRateLimiter method process.
@Override
public void process(ComplexEventChunk complexEventChunk) {
List<ComplexEventChunk> outputEventChunks = new LinkedList<>();
complexEventChunk.reset();
RateLimiterState state = stateHolder.getState();
try {
synchronized (state) {
while (complexEventChunk.hasNext()) {
ComplexEvent event = complexEventChunk.next();
if (event instanceof GroupedComplexEvent) {
event = ((GroupedComplexEvent) event).getComplexEvent();
}
if (event.getType() == ComplexEvent.Type.TIMER) {
tryFlushEvents(outputEventChunks, event, state);
} else if (event.getType() == ComplexEvent.Type.CURRENT) {
complexEventChunk.remove();
tryFlushEvents(outputEventChunks, event, state);
state.eventList.add(event);
} else if (event.getType() == ComplexEvent.Type.EXPIRED) {
tryFlushEvents(outputEventChunks, event, state);
for (Iterator<ComplexEvent> iterator = state.eventList.iterator(); iterator.hasNext(); ) {
ComplexEvent currentEvent = iterator.next();
if (comparator.compare(currentEvent, event) == 0) {
iterator.remove();
break;
}
}
} else if (event.getType() == ComplexEvent.Type.RESET) {
tryFlushEvents(outputEventChunks, event, state);
state.eventList.clear();
}
}
}
} finally {
stateHolder.returnState(state);
}
sendToCallBacks(outputEventChunks);
}
Aggregations