use of io.siddhi.core.event.stream.StreamEventFactory in project siddhi by wso2.
the class EventTestCase method testEventCreation.
@Test
public void testEventCreation() {
EventExchangeHolderFactory eventExchangeHolderFactory = new EventExchangeHolderFactory(2);
AssertJUnit.assertEquals(2, eventExchangeHolderFactory.newInstance().getEvent().getData().length);
StreamEventFactory streamEventFactory = new StreamEventFactory(2, 3, 4);
StreamEvent streamEvent = streamEventFactory.newInstance();
AssertJUnit.assertEquals(2, streamEvent.getBeforeWindowData().length);
AssertJUnit.assertEquals(3, streamEvent.getOnAfterWindowData().length);
AssertJUnit.assertEquals(4, streamEvent.getOutputData().length);
}
use of io.siddhi.core.event.stream.StreamEventFactory in project siddhi by wso2.
the class MultiProcessStreamReceiver method receive.
@Override
public void receive(List<Event> events) {
List<ReturnEventHolder> returnEventHolderList = new ArrayList<>(eventSequence.length);
synchronized (patternSyncObject) {
for (Event event : events) {
try {
multiProcessReturn.set(new ReturnEventHolder());
stabilizeStates(event.getTimestamp());
for (int anEventSequence : eventSequence) {
StreamEventConverter aStreamEventConverter = streamEventConverters[anEventSequence];
StreamEventFactory aStreamEventFactory = streamEventFactorys[anEventSequence];
StreamEvent newEvent = aStreamEventFactory.newInstance();
aStreamEventConverter.convertEvent(event, newEvent);
process(anEventSequence, newEvent);
if (multiProcessReturn.get() != null && multiProcessReturn.get().complexEventChunk != null) {
returnEventHolderList.add(multiProcessReturn.get());
multiProcessReturn.set(new ReturnEventHolder());
}
}
} finally {
multiProcessReturn.set(null);
}
}
}
for (ReturnEventHolder returnEventHolder : returnEventHolderList) {
outputRateLimiter.sendToCallBacks(returnEventHolder.complexEventChunk);
}
}
use of io.siddhi.core.event.stream.StreamEventFactory in project siddhi by wso2.
the class MultiProcessStreamReceiver method receive.
@Override
public void receive(ComplexEvent complexEvent) {
ComplexEvent aComplexEvent = complexEvent;
List<ReturnEventHolder> returnEventHolderList = new ArrayList<>(eventSequence.length);
synchronized (patternSyncObject) {
while (aComplexEvent != null) {
try {
multiProcessReturn.set(new ReturnEventHolder());
stabilizeStates(aComplexEvent.getTimestamp());
for (int anEventSequence : eventSequence) {
StreamEventConverter aStreamEventConverter = streamEventConverters[anEventSequence];
StreamEventFactory aStreamEventFactory = streamEventFactorys[anEventSequence];
StreamEvent newEvent = aStreamEventFactory.newInstance();
aStreamEventConverter.convertComplexEvent(aComplexEvent, newEvent);
process(anEventSequence, newEvent);
if (multiProcessReturn.get() != null && multiProcessReturn.get().complexEventChunk != null) {
returnEventHolderList.add(multiProcessReturn.get());
multiProcessReturn.set(new ReturnEventHolder());
}
}
} finally {
multiProcessReturn.set(null);
}
aComplexEvent = aComplexEvent.getNext();
}
for (ReturnEventHolder returnEventHolder : returnEventHolderList) {
outputRateLimiter.sendToCallBacks(returnEventHolder.complexEventChunk);
}
}
}
use of io.siddhi.core.event.stream.StreamEventFactory in project siddhi by wso2.
the class MultiProcessStreamReceiver method receive.
@Override
public void receive(long timestamp, Object[] data) {
List<ReturnEventHolder> returnEventHolderList = new ArrayList<>(eventSequence.length);
synchronized (patternSyncObject) {
try {
multiProcessReturn.set(new ReturnEventHolder());
stabilizeStates(timestamp);
for (int anEventSequence : eventSequence) {
StreamEventConverter aStreamEventConverter = streamEventConverters[anEventSequence];
StreamEventFactory aStreamEventFactory = streamEventFactorys[anEventSequence];
StreamEvent newEvent = aStreamEventFactory.newInstance();
aStreamEventConverter.convertData(timestamp, data, newEvent);
process(anEventSequence, newEvent);
if (multiProcessReturn.get() != null && multiProcessReturn.get().complexEventChunk != null) {
returnEventHolderList.add(multiProcessReturn.get());
multiProcessReturn.set(new ReturnEventHolder());
}
}
} finally {
multiProcessReturn.set(null);
}
}
for (ReturnEventHolder returnEventHolder : returnEventHolderList) {
outputRateLimiter.sendToCallBacks(returnEventHolder.complexEventChunk);
}
}
use of io.siddhi.core.event.stream.StreamEventFactory in project siddhi by wso2.
the class MultiProcessStreamReceiver method receive.
@Override
public void receive(Event event) {
List<ReturnEventHolder> returnEventHolderList = new ArrayList<>(eventSequence.length);
synchronized (patternSyncObject) {
try {
multiProcessReturn.set(new ReturnEventHolder());
stabilizeStates(event.getTimestamp());
for (int anEventSequence : eventSequence) {
StreamEventConverter aStreamEventConverter = streamEventConverters[anEventSequence];
StreamEventFactory aStreamEventFactory = streamEventFactorys[anEventSequence];
StreamEvent newEvent = aStreamEventFactory.newInstance();
aStreamEventConverter.convertEvent(event, newEvent);
process(anEventSequence, newEvent);
if (multiProcessReturn.get() != null && multiProcessReturn.get().complexEventChunk != null) {
returnEventHolderList.add(multiProcessReturn.get());
multiProcessReturn.set(new ReturnEventHolder());
}
}
} finally {
multiProcessReturn.set(null);
}
}
for (ReturnEventHolder returnEventHolder : returnEventHolderList) {
outputRateLimiter.sendToCallBacks(returnEventHolder.complexEventChunk);
}
}
Aggregations