Search in sources :

Example 11 with StreamJunction

use of io.siddhi.core.stream.StreamJunction in project siddhi by wso2.

the class OutputParser method constructOutputCallback.

public static OutputCallback constructOutputCallback(OutputStream outStream, String key, ConcurrentMap<String, StreamJunction> streamJunctionMap, StreamDefinition outputStreamDefinition, SiddhiQueryContext siddhiQueryContext) {
    String id = outStream.getId();
    // Construct CallBack
    if (outStream instanceof InsertIntoStream) {
        StreamJunction outputStreamJunction = streamJunctionMap.get(id + key);
        if (outputStreamJunction == null) {
            outputStreamJunction = new StreamJunction(outputStreamDefinition, siddhiQueryContext.getSiddhiAppContext().getExecutorService(), siddhiQueryContext.getSiddhiAppContext().getBufferSize(), null, siddhiQueryContext.getSiddhiAppContext());
            streamJunctionMap.putIfAbsent(id + key, outputStreamJunction);
        }
        InsertIntoStreamCallback insertIntoStreamCallback = new InsertIntoStreamCallback(outputStreamDefinition, siddhiQueryContext.getName());
        insertIntoStreamCallback.init(streamJunctionMap.get(id + key));
        return insertIntoStreamCallback;
    } else {
        throw new SiddhiAppCreationException(outStream.getClass().getName() + " not supported", outStream.getQueryContextStartIndex(), outStream.getQueryContextEndIndex());
    }
}
Also used : SiddhiAppCreationException(io.siddhi.core.exception.SiddhiAppCreationException) InsertIntoStream(io.siddhi.query.api.execution.query.output.stream.InsertIntoStream) StreamJunction(io.siddhi.core.stream.StreamJunction) InsertIntoStreamCallback(io.siddhi.core.query.output.callback.InsertIntoStreamCallback)

Example 12 with StreamJunction

use of io.siddhi.core.stream.StreamJunction in project siddhi by wso2.

the class DefinitionParserHelper method addStreamJunction.

public static void addStreamJunction(StreamDefinition streamDefinition, ConcurrentMap<String, StreamJunction> streamJunctionMap, SiddhiAppContext siddhiAppContext) {
    if (!streamJunctionMap.containsKey(streamDefinition.getId())) {
        StreamJunction faultStreamJunction = streamJunctionMap.get(SiddhiConstants.FAULT_STREAM_PREFIX.concat(streamDefinition.getId()));
        StreamJunction streamJunction = new StreamJunction(streamDefinition, siddhiAppContext.getExecutorService(), siddhiAppContext.getBufferSize(), faultStreamJunction, siddhiAppContext);
        streamJunctionMap.putIfAbsent(streamDefinition.getId(), streamJunction);
    }
}
Also used : StreamJunction(io.siddhi.core.stream.StreamJunction)

Aggregations

StreamJunction (io.siddhi.core.stream.StreamJunction)12 InsertIntoStreamCallback (io.siddhi.core.query.output.callback.InsertIntoStreamCallback)3 DefinitionNotExistException (io.siddhi.core.exception.DefinitionNotExistException)2 SiddhiAppCreationException (io.siddhi.core.exception.SiddhiAppCreationException)2 QueryRuntime (io.siddhi.core.query.QueryRuntime)2 StreamRuntime (io.siddhi.core.query.input.stream.StreamRuntime)2 InsertIntoWindowCallback (io.siddhi.core.query.output.callback.InsertIntoWindowCallback)2 Sink (io.siddhi.core.stream.output.sink.Sink)2 Table (io.siddhi.core.table.Table)2 ExternalReferencedHolder (io.siddhi.core.util.extension.holder.ExternalReferencedHolder)2 StreamDefinition (io.siddhi.query.api.definition.StreamDefinition)2 InsertIntoStream (io.siddhi.query.api.execution.query.output.stream.InsertIntoStream)2 AggregationRuntime (io.siddhi.core.aggregation.AggregationRuntime)1 SiddhiAppRuntimeException (io.siddhi.core.exception.SiddhiAppRuntimeException)1 QueryRuntimeImpl (io.siddhi.core.query.QueryRuntimeImpl)1 ProcessStreamReceiver (io.siddhi.core.query.input.ProcessStreamReceiver)1 SingleStreamRuntime (io.siddhi.core.query.input.stream.single.SingleStreamRuntime)1 OutputCallback (io.siddhi.core.query.output.callback.OutputCallback)1 Source (io.siddhi.core.stream.input.source.Source)1 SourceHandlerManager (io.siddhi.core.stream.input.source.SourceHandlerManager)1