Search in sources :

Example 1 with SiddhiAppContext

use of org.wso2.siddhi.core.config.SiddhiAppContext in project siddhi by wso2.

the class SiddhiAppRuntime method debug.

public synchronized SiddhiDebugger debug() {
    siddhiDebugger = new SiddhiDebugger(siddhiAppContext);
    List<StreamRuntime> streamRuntime = new ArrayList<>();
    List<OutputCallback> streamCallbacks = new ArrayList<>();
    for (QueryRuntime queryRuntime : queryProcessorMap.values()) {
        streamRuntime.add(queryRuntime.getStreamRuntime());
        streamCallbacks.add(queryRuntime.getOutputCallback());
    }
    for (StreamRuntime streamRuntime1 : streamRuntime) {
        for (SingleStreamRuntime singleStreamRuntime : streamRuntime1.getSingleStreamRuntimes()) {
            singleStreamRuntime.getProcessStreamReceiver().setSiddhiDebugger(siddhiDebugger);
        }
    }
    for (OutputCallback callback : streamCallbacks) {
        callback.setSiddhiDebugger(siddhiDebugger);
    }
    start();
    running = true;
    return siddhiDebugger;
}
Also used : SiddhiDebugger(org.wso2.siddhi.core.debugger.SiddhiDebugger) QueryRuntime(org.wso2.siddhi.core.query.QueryRuntime) StoreQueryRuntime(org.wso2.siddhi.core.query.StoreQueryRuntime) SingleStreamRuntime(org.wso2.siddhi.core.query.input.stream.single.SingleStreamRuntime) ArrayList(java.util.ArrayList) StreamRuntime(org.wso2.siddhi.core.query.input.stream.StreamRuntime) SingleStreamRuntime(org.wso2.siddhi.core.query.input.stream.single.SingleStreamRuntime) OutputCallback(org.wso2.siddhi.core.query.output.callback.OutputCallback)

Example 2 with SiddhiAppContext

use of org.wso2.siddhi.core.config.SiddhiAppContext in project siddhi by wso2.

the class SiddhiAppRuntime method addCallback.

public void addCallback(String queryName, QueryCallback callback) {
    callback.setContext(siddhiAppContext);
    QueryRuntime queryRuntime = queryProcessorMap.get(queryName);
    if (queryRuntime == null) {
        throw new QueryNotExistException("No query found with name: " + queryName);
    }
    callback.setQuery(queryRuntime.getQuery());
    queryRuntime.addCallback(callback);
}
Also used : QueryNotExistException(org.wso2.siddhi.core.exception.QueryNotExistException) QueryRuntime(org.wso2.siddhi.core.query.QueryRuntime) StoreQueryRuntime(org.wso2.siddhi.core.query.StoreQueryRuntime)

Example 3 with SiddhiAppContext

use of org.wso2.siddhi.core.config.SiddhiAppContext in project siddhi by wso2.

the class CoalesceFunctionExecutor method init.

@Override
public void init(ExpressionExecutor[] attributeExpressionExecutors, ConfigReader configReader, SiddhiAppContext siddhiAppContext) {
    if (attributeExpressionExecutors.length == 0) {
        throw new SiddhiAppValidationException("Coalesce must have at least one parameter");
    }
    Attribute.Type type = attributeExpressionExecutors[0].getReturnType();
    for (ExpressionExecutor expressionExecutor : attributeExpressionExecutors) {
        if (type != expressionExecutor.getReturnType()) {
            throw new SiddhiAppValidationException("Coalesce cannot have parameters with different type");
        }
    }
    returnType = type;
}
Also used : ExpressionExecutor(org.wso2.siddhi.core.executor.ExpressionExecutor) ReturnAttribute(org.wso2.siddhi.annotation.ReturnAttribute) Attribute(org.wso2.siddhi.query.api.definition.Attribute) SiddhiAppValidationException(org.wso2.siddhi.query.api.exception.SiddhiAppValidationException)

Example 4 with SiddhiAppContext

use of org.wso2.siddhi.core.config.SiddhiAppContext in project siddhi by wso2.

the class FunctionExecutor method cloneExecutor.

@Override
public ExpressionExecutor cloneExecutor(String key) {
    try {
        FunctionExecutor functionExecutor = this.getClass().newInstance();
        ExpressionExecutor[] innerExpressionExecutors = new ExpressionExecutor[attributeSize];
        for (int i = 0; i < attributeSize; i++) {
            innerExpressionExecutors[i] = attributeExpressionExecutors[i].cloneExecutor(key);
        }
        functionExecutor.elementId = elementId + "-" + key;
        functionExecutor.functionId = functionId;
        functionExecutor.initExecutor(innerExpressionExecutors, siddhiAppContext, queryName, configReader);
        return functionExecutor;
    } catch (Exception e) {
        throw new SiddhiAppRuntimeException("Exception in cloning " + this.getClass().getCanonicalName(), e);
    }
}
Also used : ExpressionExecutor(org.wso2.siddhi.core.executor.ExpressionExecutor) SiddhiAppRuntimeException(org.wso2.siddhi.core.exception.SiddhiAppRuntimeException) SiddhiAppRuntimeException(org.wso2.siddhi.core.exception.SiddhiAppRuntimeException) SiddhiAppCreationException(org.wso2.siddhi.core.exception.SiddhiAppCreationException)

Example 5 with SiddhiAppContext

use of org.wso2.siddhi.core.config.SiddhiAppContext in project siddhi by wso2.

the class AbstractStreamProcessor method cloneProcessor.

@Override
public Processor cloneProcessor(String key) {
    try {
        AbstractStreamProcessor abstractStreamProcessor = this.getClass().newInstance();
        abstractStreamProcessor.inputDefinition = inputDefinition;
        ExpressionExecutor[] innerExpressionExecutors = new ExpressionExecutor[attributeExpressionLength];
        ExpressionExecutor[] attributeExpressionExecutors1 = this.attributeExpressionExecutors;
        for (int i = 0; i < attributeExpressionLength; i++) {
            innerExpressionExecutors[i] = attributeExpressionExecutors1[i].cloneExecutor(key);
        }
        abstractStreamProcessor.attributeExpressionExecutors = innerExpressionExecutors;
        abstractStreamProcessor.attributeExpressionLength = attributeExpressionLength;
        abstractStreamProcessor.additionalAttributes = additionalAttributes;
        abstractStreamProcessor.complexEventPopulater = complexEventPopulater;
        abstractStreamProcessor.siddhiAppContext = siddhiAppContext;
        abstractStreamProcessor.elementId = elementId + "-" + key;
        abstractStreamProcessor.configReader = configReader;
        abstractStreamProcessor.outputExpectsExpiredEvents = outputExpectsExpiredEvents;
        abstractStreamProcessor.queryName = queryName;
        abstractStreamProcessor.siddhiAppContext.getSnapshotService().addSnapshotable(queryName, abstractStreamProcessor);
        abstractStreamProcessor.siddhiAppContext.addEternalReferencedHolder(abstractStreamProcessor);
        abstractStreamProcessor.init(inputDefinition, attributeExpressionExecutors, configReader, siddhiAppContext, outputExpectsExpiredEvents);
        abstractStreamProcessor.start();
        return abstractStreamProcessor;
    } catch (Exception e) {
        throw new SiddhiAppRuntimeException("Exception in cloning " + this.getClass().getCanonicalName(), e);
    }
}
Also used : ExpressionExecutor(org.wso2.siddhi.core.executor.ExpressionExecutor) SiddhiAppRuntimeException(org.wso2.siddhi.core.exception.SiddhiAppRuntimeException) SiddhiAppCreationException(org.wso2.siddhi.core.exception.SiddhiAppCreationException) SiddhiAppRuntimeException(org.wso2.siddhi.core.exception.SiddhiAppRuntimeException)

Aggregations

VariableExpressionExecutor (org.wso2.siddhi.core.executor.VariableExpressionExecutor)30 ExpressionExecutor (org.wso2.siddhi.core.executor.ExpressionExecutor)28 SiddhiAppCreationException (org.wso2.siddhi.core.exception.SiddhiAppCreationException)24 ArrayList (java.util.ArrayList)22 MetaStreamEvent (org.wso2.siddhi.core.event.stream.MetaStreamEvent)20 Attribute (org.wso2.siddhi.query.api.definition.Attribute)18 StreamEventPool (org.wso2.siddhi.core.event.stream.StreamEventPool)17 ConstantExpressionExecutor (org.wso2.siddhi.core.executor.ConstantExpressionExecutor)17 SiddhiAppValidationException (org.wso2.siddhi.query.api.exception.SiddhiAppValidationException)13 MetaStateEvent (org.wso2.siddhi.core.event.state.MetaStateEvent)12 AbstractDefinition (org.wso2.siddhi.query.api.definition.AbstractDefinition)12 StreamDefinition (org.wso2.siddhi.query.api.definition.StreamDefinition)12 HashMap (java.util.HashMap)11 StreamEvent (org.wso2.siddhi.core.event.stream.StreamEvent)11 SingleStreamRuntime (org.wso2.siddhi.core.query.input.stream.single.SingleStreamRuntime)11 Expression (org.wso2.siddhi.query.api.expression.Expression)11 Table (org.wso2.siddhi.core.table.Table)10 Variable (org.wso2.siddhi.query.api.expression.Variable)10 QueryRuntime (org.wso2.siddhi.core.query.QueryRuntime)8 StreamJunction (org.wso2.siddhi.core.stream.StreamJunction)8