Search in sources :

Example 1 with SiddhiEventFactory

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);
}
Also used : StreamEventFactory(org.wso2.siddhi.core.event.stream.StreamEventFactory) StreamEvent(org.wso2.siddhi.core.event.stream.StreamEvent) MetaStreamEvent(org.wso2.siddhi.core.event.stream.MetaStreamEvent) SiddhiEventFactory(org.wso2.siddhi.core.event.SiddhiEventFactory) Test(org.testng.annotations.Test)

Example 2 with SiddhiEventFactory

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();
            }
        }
    }
}
Also used : BlockingWaitStrategy(com.lmax.disruptor.BlockingWaitStrategy) ProducerType(com.lmax.disruptor.dsl.ProducerType) Constructor(java.lang.reflect.Constructor) Event(org.wso2.siddhi.core.event.Event) ComplexEvent(org.wso2.siddhi.core.event.ComplexEvent) SiddhiEventFactory(org.wso2.siddhi.core.event.SiddhiEventFactory) StreamCallback(org.wso2.siddhi.core.stream.output.StreamCallback)

Aggregations

SiddhiEventFactory (org.wso2.siddhi.core.event.SiddhiEventFactory)2 BlockingWaitStrategy (com.lmax.disruptor.BlockingWaitStrategy)1 ProducerType (com.lmax.disruptor.dsl.ProducerType)1 Constructor (java.lang.reflect.Constructor)1 Test (org.testng.annotations.Test)1 ComplexEvent (org.wso2.siddhi.core.event.ComplexEvent)1 Event (org.wso2.siddhi.core.event.Event)1 MetaStreamEvent (org.wso2.siddhi.core.event.stream.MetaStreamEvent)1 StreamEvent (org.wso2.siddhi.core.event.stream.StreamEvent)1 StreamEventFactory (org.wso2.siddhi.core.event.stream.StreamEventFactory)1 StreamCallback (org.wso2.siddhi.core.stream.output.StreamCallback)1