Search in sources :

Example 1 with SiddhiAppContextException

use of org.ballerinalang.siddhi.query.api.exception.SiddhiAppContextException in project ballerina by ballerina-lang.

the class SiddhiAppRuntime method getStoreQueryOutputAttributes.

/**
 * This method get the storeQuery and return the corresponding output and its types.
 *
 * @param storeQuery       this storeQuery is processed and get the output attributes.
 * @param storeQueryString this passed to report errors with context if there are any.
 * @return List of output attributes
 */
private Attribute[] getStoreQueryOutputAttributes(StoreQuery storeQuery, String storeQueryString) {
    try {
        StoreQueryRuntime storeQueryRuntime = storeQueryRuntimeMap.get(storeQuery);
        if (storeQueryRuntime == null) {
            storeQueryRuntime = StoreQueryParser.parse(storeQuery, siddhiAppContext, tableMap, windowMap, aggregationMap);
            storeQueryRuntimeMap.put(storeQuery, storeQueryRuntime);
        }
        return storeQueryRuntime.getStoreQueryOutputAttributes();
    } catch (RuntimeException e) {
        if (e instanceof SiddhiAppContextException) {
            throw new StoreQueryCreationException(((SiddhiAppContextException) e).getMessageWithOutContext(), e, ((SiddhiAppContextException) e).getQueryContextStartIndex(), ((SiddhiAppContextException) e).getQueryContextEndIndex(), null, siddhiAppContext.getSiddhiAppString());
        }
        throw new StoreQueryCreationException(e.getMessage(), e);
    }
}
Also used : SiddhiAppContextException(org.ballerinalang.siddhi.query.api.exception.SiddhiAppContextException) StoreQueryRuntime(org.ballerinalang.siddhi.core.query.StoreQueryRuntime) StoreQueryCreationException(org.ballerinalang.siddhi.core.exception.StoreQueryCreationException)

Example 2 with SiddhiAppContextException

use of org.ballerinalang.siddhi.query.api.exception.SiddhiAppContextException in project ballerina by ballerina-lang.

the class SiddhiAppRuntime method query.

private Event[] query(StoreQuery storeQuery, String storeQueryString) {
    try {
        if (siddhiAppContext.isStatsEnabled() && storeQueryLatencyTracker != null) {
            storeQueryLatencyTracker.markIn();
        }
        StoreQueryRuntime storeQueryRuntime = storeQueryRuntimeMap.get(storeQuery);
        if (storeQueryRuntime == null) {
            storeQueryRuntime = StoreQueryParser.parse(storeQuery, siddhiAppContext, tableMap, windowMap, aggregationMap);
            storeQueryRuntimeMap.put(storeQuery, storeQueryRuntime);
        } else {
            storeQueryRuntime.reset();
        }
        return storeQueryRuntime.execute();
    } catch (RuntimeException e) {
        if (e instanceof SiddhiAppContextException) {
            throw new StoreQueryCreationException(((SiddhiAppContextException) e).getMessageWithOutContext(), e, ((SiddhiAppContextException) e).getQueryContextStartIndex(), ((SiddhiAppContextException) e).getQueryContextEndIndex(), null, storeQueryString);
        }
        throw new StoreQueryCreationException(e.getMessage(), e);
    } finally {
        if (siddhiAppContext.isStatsEnabled() && storeQueryLatencyTracker != null) {
            storeQueryLatencyTracker.markOut();
        }
    }
}
Also used : SiddhiAppContextException(org.ballerinalang.siddhi.query.api.exception.SiddhiAppContextException) StoreQueryRuntime(org.ballerinalang.siddhi.core.query.StoreQueryRuntime) StoreQueryCreationException(org.ballerinalang.siddhi.core.exception.StoreQueryCreationException)

Aggregations

StoreQueryCreationException (org.ballerinalang.siddhi.core.exception.StoreQueryCreationException)2 StoreQueryRuntime (org.ballerinalang.siddhi.core.query.StoreQueryRuntime)2 SiddhiAppContextException (org.ballerinalang.siddhi.query.api.exception.SiddhiAppContextException)2