Search in sources :

Example 1 with ProducerType

use of com.lmax.disruptor.dsl.ProducerType 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)

Example 2 with ProducerType

use of com.lmax.disruptor.dsl.ProducerType in project ballerina by ballerina-lang.

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) ComplexEvent(org.ballerinalang.siddhi.core.event.ComplexEvent) Event(org.ballerinalang.siddhi.core.event.Event) SiddhiEventFactory(org.ballerinalang.siddhi.core.event.SiddhiEventFactory) StreamCallback(org.ballerinalang.siddhi.core.stream.output.StreamCallback)

Example 3 with ProducerType

use of com.lmax.disruptor.dsl.ProducerType in project siddhi by wso2.

the class StreamJunction method startProcessing.

/**
 * Create and start disruptor based on annotations given in the streamDefinition.
 */
public void startProcessing() {
    this.exceptionListener = siddhiAppContext.getRuntimeExceptionListener();
    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<EventExchangeHolder>(new EventExchangeHolderFactory(streamDefinition.getAttributeList().size()), bufferSize, executorService, producerType, new BlockingWaitStrategy());
                disruptor.handleExceptionsWith(siddhiAppContext.getDisruptorExceptionHandler());
                break;
            }
        }
        if (disruptor == null) {
            disruptor = new Disruptor<EventExchangeHolder>(new EventExchangeHolderFactory(streamDefinition.getAttributeList().size()), bufferSize, executorService);
            disruptor.handleExceptionsWith(siddhiAppContext.getDisruptorExceptionHandler());
        }
        if (workers > 0) {
            for (int i = 0; i < workers; i++) {
                disruptor.handleEventsWith(new StreamHandler(receivers, batchSize, streamDefinition.getId(), siddhiAppContext.getName(), faultStreamJunction, onErrorAction, exceptionListener));
            }
        } else {
            disruptor.handleEventsWith(new StreamHandler(receivers, batchSize, streamDefinition.getId(), siddhiAppContext.getName(), faultStreamJunction, onErrorAction, exceptionListener));
        }
        ringBuffer = disruptor.start();
    } else {
        for (Receiver receiver : receivers) {
            if (receiver instanceof StreamCallback) {
                ((StreamCallback) receiver).startProcessing();
            }
        }
    }
}
Also used : EventExchangeHolderFactory(io.siddhi.core.util.event.handler.EventExchangeHolderFactory) BlockingWaitStrategy(com.lmax.disruptor.BlockingWaitStrategy) ProducerType(com.lmax.disruptor.dsl.ProducerType) EventExchangeHolder(io.siddhi.core.util.event.handler.EventExchangeHolder) Constructor(java.lang.reflect.Constructor) StreamHandler(io.siddhi.core.util.event.handler.StreamHandler) StreamCallback(io.siddhi.core.stream.output.StreamCallback)

Aggregations

BlockingWaitStrategy (com.lmax.disruptor.BlockingWaitStrategy)3 ProducerType (com.lmax.disruptor.dsl.ProducerType)3 Constructor (java.lang.reflect.Constructor)3 StreamCallback (io.siddhi.core.stream.output.StreamCallback)1 EventExchangeHolder (io.siddhi.core.util.event.handler.EventExchangeHolder)1 EventExchangeHolderFactory (io.siddhi.core.util.event.handler.EventExchangeHolderFactory)1 StreamHandler (io.siddhi.core.util.event.handler.StreamHandler)1 ComplexEvent (org.ballerinalang.siddhi.core.event.ComplexEvent)1 Event (org.ballerinalang.siddhi.core.event.Event)1 SiddhiEventFactory (org.ballerinalang.siddhi.core.event.SiddhiEventFactory)1 StreamCallback (org.ballerinalang.siddhi.core.stream.output.StreamCallback)1 ComplexEvent (org.wso2.siddhi.core.event.ComplexEvent)1 Event (org.wso2.siddhi.core.event.Event)1 SiddhiEventFactory (org.wso2.siddhi.core.event.SiddhiEventFactory)1 StreamCallback (org.wso2.siddhi.core.stream.output.StreamCallback)1