Search in sources :

Example 1 with SiddhiAppContextException

use of org.wso2.siddhi.query.api.exception.SiddhiAppContextException in project siddhi by wso2.

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.wso2.siddhi.query.api.exception.SiddhiAppContextException) StoreQueryRuntime(org.wso2.siddhi.core.query.StoreQueryRuntime) StoreQueryCreationException(org.wso2.siddhi.core.exception.StoreQueryCreationException)

Example 2 with SiddhiAppContextException

use of org.wso2.siddhi.query.api.exception.SiddhiAppContextException in project siddhi by wso2.

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.wso2.siddhi.query.api.exception.SiddhiAppContextException) StoreQueryRuntime(org.wso2.siddhi.core.query.StoreQueryRuntime) StoreQueryCreationException(org.wso2.siddhi.core.exception.StoreQueryCreationException)

Aggregations

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