use of org.wso2.siddhi.core.event.SiddhiEventFactory in project siddhi by wso2.
the class EventTestCase method testEventCreation.
@Test
public void testEventCreation() {
SiddhiEventFactory siddhiEventFactory = new SiddhiEventFactory(2);
AssertJUnit.assertEquals(2, siddhiEventFactory.newInstance().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 org.wso2.siddhi.core.event.SiddhiEventFactory in project siddhi by wso2.
the class StreamJunction method startProcessing.
/**
* Create and start disruptor based on annotations given in the streamDefinition.
*/
public synchronized void startProcessing() {
if (!receivers.isEmpty() && async) {
for (Constructor constructor : Disruptor.class.getConstructors()) {
if (constructor.getParameterTypes().length == 5) {
// If new disruptor classes available
ProducerType producerType = ProducerType.MULTI;
disruptor = new Disruptor<Event>(new SiddhiEventFactory(streamDefinition.getAttributeList().size()), bufferSize, executorService, producerType, new BlockingWaitStrategy());
disruptor.handleExceptionsWith(siddhiAppContext.getDisruptorExceptionHandler());
break;
}
}
if (disruptor == null) {
disruptor = new Disruptor<Event>(new SiddhiEventFactory(streamDefinition.getAttributeList().size()), bufferSize, executorService);
disruptor.handleExceptionsWith(siddhiAppContext.getDisruptorExceptionHandler());
}
for (Receiver receiver : receivers) {
disruptor.handleEventsWith(new StreamHandler(receiver));
}
ringBuffer = disruptor.start();
} else {
for (Receiver receiver : receivers) {
if (receiver instanceof StreamCallback) {
((StreamCallback) receiver).startProcessing();
}
}
}
}
Aggregations