Search in sources :

Example 6 with StreamHandler

use of org.wso2.siddhi.query.api.execution.query.input.handler.StreamHandler 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 7 with StreamHandler

use of org.wso2.siddhi.query.api.execution.query.input.handler.StreamHandler in project siddhi by wso2.

the class SiddhiQLBaseVisitorImpl method visitBasic_source.

/**
 * {@inheritDoc}
 * <p>The default implementation returns the result of calling
 * {@link #visitChildren} on {@code ctx}.</p>
 *
 * @param ctx
 */
@Override
public BasicSingleInputStream visitBasic_source(@NotNull SiddhiQLParser.Basic_sourceContext ctx) {
    // basic_source
    // : io (basic_source_stream_handler)*
    // ;
    Source source = (Source) visit(ctx.source());
    BasicSingleInputStream basicSingleInputStream = new BasicSingleInputStream(null, source.streamId, source.isInnerStream);
    if (ctx.basic_source_stream_handlers() != null) {
        basicSingleInputStream.addStreamHandlers((List<StreamHandler>) visit(ctx.basic_source_stream_handlers()));
    }
    populateQueryContext(basicSingleInputStream, ctx);
    return basicSingleInputStream;
}
Also used : BasicSingleInputStream(org.wso2.siddhi.query.api.execution.query.input.stream.BasicSingleInputStream) StreamHandler(org.wso2.siddhi.query.api.execution.query.input.handler.StreamHandler)

Aggregations

StreamHandler (org.wso2.siddhi.query.api.execution.query.input.handler.StreamHandler)5 MetaStateEvent (org.wso2.siddhi.core.event.state.MetaStateEvent)3 MetaStreamEvent (org.wso2.siddhi.core.event.stream.MetaStreamEvent)3 Window (org.wso2.siddhi.query.api.execution.query.input.handler.Window)3 BasicSingleInputStream (org.wso2.siddhi.query.api.execution.query.input.stream.BasicSingleInputStream)3 SingleInputStream (org.wso2.siddhi.query.api.execution.query.input.stream.SingleInputStream)3 ArrayList (java.util.ArrayList)2 VariableExpressionExecutor (org.wso2.siddhi.core.executor.VariableExpressionExecutor)2 SingleStreamRuntime (org.wso2.siddhi.core.query.input.stream.single.SingleStreamRuntime)2 FilterProcessor (org.wso2.siddhi.core.query.processor.filter.FilterProcessor)2 AbstractStreamProcessor (org.wso2.siddhi.core.query.processor.stream.AbstractStreamProcessor)2 WindowProcessor (org.wso2.siddhi.core.query.processor.stream.window.WindowProcessor)2 BlockingWaitStrategy (com.lmax.disruptor.BlockingWaitStrategy)1 ProducerType (com.lmax.disruptor.dsl.ProducerType)1 Constructor (java.lang.reflect.Constructor)1 List (java.util.List)1 ReentrantLock (java.util.concurrent.locks.ReentrantLock)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