use of org.wso2.carbon.apimgt.core.models.Event in project siddhi by wso2.
the class AggregationGroupByWindowedPerSnapshotOutputRateLimiter method process.
@Override
public void process(ComplexEventChunk complexEventChunk) {
complexEventChunk.reset();
List<ComplexEventChunk<ComplexEvent>> outputEventChunks = new ArrayList<ComplexEventChunk<ComplexEvent>>();
synchronized (this) {
complexEventChunk.reset();
String currentGroupByKey = null;
Map<Integer, Object> currentAggregateAttributeValueMap = null;
while (complexEventChunk.hasNext()) {
ComplexEvent event = complexEventChunk.next();
if (event.getType() == ComplexEvent.Type.TIMER) {
tryFlushEvents(outputEventChunks, event);
} else {
complexEventChunk.remove();
tryFlushEvents(outputEventChunks, event);
GroupedComplexEvent groupedComplexEvent = ((GroupedComplexEvent) event);
if (currentGroupByKey == null || !currentGroupByKey.equals(groupedComplexEvent.getGroupKey())) {
currentGroupByKey = groupedComplexEvent.getGroupKey();
currentAggregateAttributeValueMap = groupByAggregateAttributeValueMap.get(currentGroupByKey);
if (currentAggregateAttributeValueMap == null) {
currentAggregateAttributeValueMap = new HashMap<Integer, Object>(aggregateAttributePositionList.size());
groupByAggregateAttributeValueMap.put(currentGroupByKey, currentAggregateAttributeValueMap);
}
}
if (groupedComplexEvent.getType() == ComplexEvent.Type.CURRENT) {
eventList.add(groupedComplexEvent);
for (Integer position : aggregateAttributePositionList) {
currentAggregateAttributeValueMap.put(position, event.getOutputData()[position]);
}
} else if (groupedComplexEvent.getType() == ComplexEvent.Type.EXPIRED) {
for (Iterator<GroupedComplexEvent> iterator = eventList.iterator(); iterator.hasNext(); ) {
GroupedComplexEvent currentEvent = iterator.next();
if (comparator.compare(currentEvent.getComplexEvent(), groupedComplexEvent.getComplexEvent()) == 0) {
iterator.remove();
for (Integer position : aggregateAttributePositionList) {
currentAggregateAttributeValueMap.put(position, groupedComplexEvent.getOutputData()[position]);
}
break;
}
}
} else if (groupedComplexEvent.getType() == ComplexEvent.Type.RESET) {
eventList.clear();
groupByAggregateAttributeValueMap.clear();
}
}
}
}
for (ComplexEventChunk eventChunk : outputEventChunks) {
sendToCallBacks(eventChunk);
}
}
use of org.wso2.carbon.apimgt.core.models.Event in project siddhi by wso2.
the class AllAggregationGroupByWindowedPerSnapshotOutputRateLimiter method process.
@Override
public void process(ComplexEventChunk complexEventChunk) {
List<ComplexEventChunk<ComplexEvent>> outputEventChunks = new ArrayList<ComplexEventChunk<ComplexEvent>>();
complexEventChunk.reset();
synchronized (this) {
while (complexEventChunk.hasNext()) {
ComplexEvent event = complexEventChunk.next();
if (event.getType() == ComplexEvent.Type.TIMER) {
tryFlushEvents(outputEventChunks, event);
} else {
complexEventChunk.remove();
tryFlushEvents(outputEventChunks, event);
GroupedComplexEvent groupedComplexEvent = ((GroupedComplexEvent) event);
LastEventHolder lastEventHolder = groupByKeyEvents.get(groupedComplexEvent.getGroupKey());
if (lastEventHolder == null) {
lastEventHolder = new LastEventHolder();
groupByKeyEvents.put(groupedComplexEvent.getGroupKey(), lastEventHolder);
}
if (groupedComplexEvent.getType() == ComplexEvent.Type.CURRENT) {
lastEventHolder.addLastInEvent(groupedComplexEvent.getComplexEvent());
} else if (groupedComplexEvent.getType() == ComplexEvent.Type.EXPIRED) {
lastEventHolder.removeLastInEvent(groupedComplexEvent.getComplexEvent());
} else if (groupedComplexEvent.getType() == ComplexEvent.Type.RESET) {
groupByKeyEvents.clear();
}
}
}
}
for (ComplexEventChunk eventChunk : outputEventChunks) {
sendToCallBacks(eventChunk);
}
}
use of org.wso2.carbon.apimgt.core.models.Event in project siddhi by wso2.
the class AllAggregationPerSnapshotOutputRateLimiter method process.
@Override
public void process(ComplexEventChunk complexEventChunk) {
List<ComplexEventChunk<ComplexEvent>> outputEventChunks = new ArrayList<ComplexEventChunk<ComplexEvent>>();
complexEventChunk.reset();
synchronized (this) {
while (complexEventChunk.hasNext()) {
ComplexEvent event = complexEventChunk.next();
if (event.getType() == ComplexEvent.Type.TIMER) {
tryFlushEvents(outputEventChunks, event);
} else {
tryFlushEvents(outputEventChunks, event);
if (event.getType() == ComplexEvent.Type.CURRENT) {
complexEventChunk.remove();
lastEvent = event;
} else {
lastEvent = null;
}
}
}
}
for (ComplexEventChunk<ComplexEvent> eventChunk : outputEventChunks) {
sendToCallBacks(eventChunk);
}
}
use of org.wso2.carbon.apimgt.core.models.Event in project siddhi by wso2.
the class GroupByPerSnapshotOutputRateLimiter method process.
/**
* Sends the collected unique outputs per group by key upon arrival of timer event from scheduler.
*
* @param complexEventChunk Incoming {@link org.wso2.siddhi.core.event.ComplexEventChunk}
*/
@Override
public void process(ComplexEventChunk complexEventChunk) {
List<ComplexEventChunk<ComplexEvent>> outputEventChunks = new ArrayList<ComplexEventChunk<ComplexEvent>>();
complexEventChunk.reset();
synchronized (this) {
complexEventChunk.reset();
while (complexEventChunk.hasNext()) {
ComplexEvent event = complexEventChunk.next();
if (event.getType() == ComplexEvent.Type.TIMER) {
tryFlushEvents(outputEventChunks, event);
} else if (event.getType() == ComplexEvent.Type.CURRENT) {
complexEventChunk.remove();
tryFlushEvents(outputEventChunks, event);
GroupedComplexEvent groupedComplexEvent = ((GroupedComplexEvent) event);
groupByKeyEvents.put(groupedComplexEvent.getGroupKey(), groupedComplexEvent.getComplexEvent());
}
}
}
for (ComplexEventChunk eventChunk : outputEventChunks) {
sendToCallBacks(eventChunk);
}
}
use of org.wso2.carbon.apimgt.core.models.Event in project siddhi by wso2.
the class PerSnapshotOutputRateLimiter method process.
@Override
public void process(ComplexEventChunk complexEventChunk) {
List<ComplexEventChunk<ComplexEvent>> outputEventChunks = new ArrayList<ComplexEventChunk<ComplexEvent>>();
complexEventChunk.reset();
synchronized (this) {
while (complexEventChunk.hasNext()) {
ComplexEvent event = complexEventChunk.next();
if (event.getType() == ComplexEvent.Type.TIMER) {
tryFlushEvents(outputEventChunks, event);
} else if (event.getType() == ComplexEvent.Type.CURRENT) {
complexEventChunk.remove();
tryFlushEvents(outputEventChunks, event);
lastEvent = event;
} else {
tryFlushEvents(outputEventChunks, event);
}
}
}
for (ComplexEventChunk eventChunk : outputEventChunks) {
sendToCallBacks(eventChunk);
}
}
Aggregations