use of org.ballerinalang.siddhi.core.event.stream.StreamEventPool in project ballerina by ballerina-lang.
the class ComplexEventChunkTestCase method eventChunkRemoveTest5.
@Test(expectedExceptions = IllegalStateException.class)
public void eventChunkRemoveTest5() {
StreamEvent streamEvent1 = new StreamEvent(0, 0, 3);
streamEvent1.setOutputData(new Object[] { "IBM", 700L, 100L });
StreamEvent streamEvent2 = new StreamEvent(0, 0, 3);
streamEvent2.setOutputData(new Object[] { "WSO2", 700L, 100L });
streamEvent1.setNext(streamEvent2);
StreamEventPool streamEventPool = new StreamEventPool(0, 0, 3, 5);
ConversionStreamEventChunk streamEventChunk = new ConversionStreamEventChunk(streamEventConverter, streamEventPool);
streamEventChunk.convertAndAssign(streamEvent1);
streamEventChunk.remove();
streamEventChunk.remove();
}
use of org.ballerinalang.siddhi.core.event.stream.StreamEventPool in project ballerina by ballerina-lang.
the class EventTestCase method testPassThroughStreamEventConverter.
@Test
public void testPassThroughStreamEventConverter() {
Attribute symbol = new Attribute("symbol", Attribute.Type.STRING);
Attribute price = new Attribute("price", Attribute.Type.DOUBLE);
Attribute volume = new Attribute("volume", Attribute.Type.INT);
MetaStreamEvent metaStreamEvent = new MetaStreamEvent();
metaStreamEvent.addOutputDataAllowingDuplicate(symbol);
metaStreamEvent.addOutputDataAllowingDuplicate(price);
metaStreamEvent.addOutputDataAllowingDuplicate(volume);
StreamDefinition streamDefinition = StreamDefinition.id("cseEventStream").attribute("symbol", Attribute.Type.STRING).attribute("price", Attribute.Type.DOUBLE).attribute("volume", Attribute.Type.INT);
Event event = new Event(System.currentTimeMillis(), new Object[] { "WSO2", 200.0, 50 });
metaStreamEvent.addInputDefinition(streamDefinition);
StreamEventConverter converter = StreamEventConverterFactory.constructEventConverter(metaStreamEvent);
StreamEventPool eventPool = new StreamEventPool(metaStreamEvent, 5);
StreamEvent borrowedEvent = eventPool.borrowEvent();
converter.convertEvent(event, borrowedEvent);
AssertJUnit.assertTrue(converter instanceof ZeroStreamEventConverter);
AssertJUnit.assertEquals(3, borrowedEvent.getOutputData().length);
AssertJUnit.assertEquals("WSO2", borrowedEvent.getOutputData()[0]);
AssertJUnit.assertEquals(200.0, borrowedEvent.getOutputData()[1]);
AssertJUnit.assertEquals(50, borrowedEvent.getOutputData()[2]);
}
use of org.ballerinalang.siddhi.core.event.stream.StreamEventPool in project ballerina by ballerina-lang.
the class MultiProcessStreamReceiver method receive.
@Override
public void receive(Event[] events) {
for (Event event : events) {
synchronized (this) {
stabilizeStates();
for (int anEventSequence : eventSequence) {
StreamEventConverter aStreamEventConverter = streamEventConverters[anEventSequence];
StreamEventPool aStreamEventPool = streamEventPools[anEventSequence];
StreamEvent borrowedEvent = aStreamEventPool.borrowEvent();
aStreamEventConverter.convertEvent(event, borrowedEvent);
process(anEventSequence, borrowedEvent);
}
}
}
}
use of org.ballerinalang.siddhi.core.event.stream.StreamEventPool in project ballerina by ballerina-lang.
the class MultiProcessStreamReceiver method receive.
@Override
public void receive(Event event, boolean endOfBatch) {
eventBuffer.add(event);
if (endOfBatch) {
for (Event aEvent : eventBuffer) {
synchronized (this) {
stabilizeStates();
for (int anEventSequence : eventSequence) {
StreamEventConverter aStreamEventConverter = streamEventConverters[anEventSequence];
StreamEventPool aStreamEventPool = streamEventPools[anEventSequence];
StreamEvent borrowedEvent = aStreamEventPool.borrowEvent();
aStreamEventConverter.convertEvent(aEvent, borrowedEvent);
process(anEventSequence, borrowedEvent);
}
}
}
eventBuffer.clear();
}
}
use of org.ballerinalang.siddhi.core.event.stream.StreamEventPool in project ballerina by ballerina-lang.
the class MultiProcessStreamReceiver method receive.
@Override
public void receive(long timestamp, Object[] data) {
synchronized (this) {
stabilizeStates();
for (int anEventSequence : eventSequence) {
StreamEventConverter aStreamEventConverter = streamEventConverters[anEventSequence];
StreamEventPool aStreamEventPool = streamEventPools[anEventSequence];
StreamEvent borrowedEvent = aStreamEventPool.borrowEvent();
aStreamEventConverter.convertData(timestamp, data, borrowedEvent);
process(anEventSequence, borrowedEvent);
}
}
}
Aggregations