use of org.wso2.siddhi.core.config.SiddhiAppContext in project siddhi by wso2.
the class StoreQueryParser method constructStoreQueryRuntime.
private static StoreQueryRuntime constructStoreQueryRuntime(AggregationRuntime aggregation, StoreQuery storeQuery, SiddhiAppContext siddhiAppContext, Map<String, Table> tableMap, String queryName, Within within, Expression per, Expression onCondition, MetaStreamEvent metaStreamEvent, List<VariableExpressionExecutor> variableExpressionExecutors) {
int metaPosition;
metaStreamEvent.setEventType(EventType.AGGREGATE);
initMetaStreamEvent(metaStreamEvent, aggregation.getAggregationDefinition());
MatchingMetaInfoHolder metaStreamInfoHolder = generateMatchingMetaInfoHolder(metaStreamEvent, aggregation.getAggregationDefinition());
CompiledCondition compiledCondition = aggregation.compileExpression(onCondition, within, per, metaStreamInfoHolder, variableExpressionExecutors, tableMap, queryName, siddhiAppContext);
metaStreamInfoHolder = ((IncrementalAggregateCompileCondition) compiledCondition).getAlteredMatchingMetaInfoHolder();
FindStoreQueryRuntime findStoreQueryRuntime = new FindStoreQueryRuntime(aggregation, compiledCondition, queryName, metaStreamEvent);
metaPosition = 1;
populateFindStoreQueryRuntime(findStoreQueryRuntime, metaStreamInfoHolder, storeQuery.getSelector(), variableExpressionExecutors, siddhiAppContext, tableMap, queryName, metaPosition);
ComplexEventPopulater complexEventPopulater = StreamEventPopulaterFactory.constructEventPopulator(metaStreamInfoHolder.getMetaStateEvent().getMetaStreamEvent(0), 0, ((IncrementalAggregateCompileCondition) compiledCondition).getAdditionalAttributes());
((IncrementalAggregateCompileCondition) compiledCondition).setComplexEventPopulater(complexEventPopulater);
return findStoreQueryRuntime;
}
use of org.wso2.siddhi.core.config.SiddhiAppContext in project siddhi by wso2.
the class StoreQueryParser method buildExpectedOutputAttributes.
private static List<Attribute> buildExpectedOutputAttributes(StoreQuery storeQuery, SiddhiAppContext siddhiAppContext, Map<String, Table> tableMap, String queryName, int metaPosition, MatchingMetaInfoHolder metaStreamInfoHolder) {
MetaStateEvent selectMetaStateEvent = new MetaStateEvent(metaStreamInfoHolder.getMetaStateEvent().getMetaStreamEvents());
SelectorParser.parse(storeQuery.getSelector(), new ReturnStream(OutputStream.OutputEventType.CURRENT_EVENTS), siddhiAppContext, selectMetaStateEvent, tableMap, new ArrayList<>(), queryName, metaPosition);
return selectMetaStateEvent.getOutputStreamDefinition().getAttributeList();
}
use of org.wso2.siddhi.core.config.SiddhiAppContext in project siddhi by wso2.
the class DefinitionParserHelper method isMultiClientDistributedTransport.
private static boolean isMultiClientDistributedTransport(Sink clientTransport, StreamDefinition streamDefinition, Annotation distributionAnnotation, SiddhiAppContext siddhiAppContext) {
// fetch the @distribution annotations from the @sink annotation
List<OptionHolder> destinationOptHolders = createDestinationOptionHolders(distributionAnnotation, streamDefinition, clientTransport, siddhiAppContext);
List<String> dynamicOptions = Arrays.asList(clientTransport.getSupportedDynamicOptions());
// If at least one of the @destination contains a static option then multi client transport should be used
for (OptionHolder optionHolder : destinationOptHolders) {
for (String key : optionHolder.getDynamicOptionsKeys()) {
if (!dynamicOptions.contains(key)) {
return true;
}
}
for (String key : optionHolder.getStaticOptionsKeys()) {
if (!dynamicOptions.contains(key)) {
return true;
}
}
}
return false;
}
use of org.wso2.siddhi.core.config.SiddhiAppContext 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 streamJunction = new StreamJunction(streamDefinition, siddhiAppContext.getExecutorService(), siddhiAppContext.getBufferSize(), siddhiAppContext);
streamJunctionMap.putIfAbsent(streamDefinition.getId(), streamJunction);
}
}
use of org.wso2.siddhi.core.config.SiddhiAppContext in project siddhi by wso2.
the class DefinitionParserHelper method addEventTrigger.
public static void addEventTrigger(TriggerDefinition triggerDefinition, ConcurrentMap<String, Trigger> eventTriggerMap, ConcurrentMap<String, StreamJunction> streamJunctionMap, SiddhiAppContext siddhiAppContext) {
if (!eventTriggerMap.containsKey(triggerDefinition.getId())) {
Trigger trigger;
if (triggerDefinition.getAtEvery() != null) {
trigger = new PeriodicTrigger();
} else if (triggerDefinition.getAt().trim().equalsIgnoreCase(SiddhiConstants.TRIGGER_START)) {
trigger = new StartTrigger();
} else {
trigger = new CronTrigger();
}
StreamJunction streamJunction = streamJunctionMap.get(triggerDefinition.getId());
trigger.init(triggerDefinition, siddhiAppContext, streamJunction);
siddhiAppContext.addEternalReferencedHolder(trigger);
eventTriggerMap.putIfAbsent(trigger.getId(), trigger);
}
}
Aggregations