private AgentInstance startStatement( int contextId, ContextControllerStatementDesc statementDesc, ContextController originator, Object partitionKey, Map<String, Object> contextProperties, boolean isRecoveringResilient) { // build filters IdentityHashMap<FilterSpecCompiled, List<FilterValueSetParam>> filterAddendum = new IdentityHashMap<FilterSpecCompiled, List<FilterValueSetParam>>(); originator .getFactory() .populateFilterAddendums(filterAddendum, statementDesc, partitionKey, contextId); AgentInstanceFilterProxy proxy = new AgentInstanceFilterProxyImpl(filterAddendum); // build built-in context properties contextProperties.put(ContextPropertyEventType.PROP_CTX_NAME, contextName); contextProperties.put(ContextPropertyEventType.PROP_CTX_ID, contextId); MappedEventBean contextBean = (MappedEventBean) servicesContext .getEventAdapterService() .adapterForTypedMap( contextProperties, contextDescriptor.getContextPropertyRegistry().getContextEventType()); // activate StatementAgentInstanceFactoryResult result = StatementAgentInstanceUtil.start( servicesContext, statementDesc.getStatement(), false, contextId, contextBean, proxy, isRecoveringResilient); // save only instance data return new AgentInstance( result.getStopCallback(), result.getAgentInstanceContext(), result.getFinalView()); }
public void startContextPartition( StatementAgentInstanceFactoryResult startResult, int agentInstanceId) { StatementAgentInstanceLock lock = startResult .getAgentInstanceContext() .getEpStatementAgentInstanceHandle() .getStatementAgentInstanceLock(); StatementResourceHolder recoveryResources = null; if (startResult instanceof StatementAgentInstanceFactorySelectResult) { StatementAgentInstanceFactorySelectResult selectResult = (StatementAgentInstanceFactorySelectResult) startResult; recoveryResources = new StatementResourceHolder( lock, selectResult.getTopViews(), selectResult.getEventStreamViewables(), selectResult.getPatternRoots(), selectResult.getOptionalAggegationService(), selectResult.getSubselectStrategies(), selectResult.getOptionalPostLoadJoin()); } if (startResult instanceof StatementAgentInstanceFactoryCreateWindowResult) { StatementAgentInstanceFactoryCreateWindowResult createResult = (StatementAgentInstanceFactoryCreateWindowResult) startResult; recoveryResources = new StatementResourceHolder( lock, new Viewable[] {createResult.getTopView()}, null, null, null, null, createResult.getPostLoad()); } if (startResult instanceof StatementAgentInstanceFactoryCreateTableResult) { StatementAgentInstanceFactoryCreateTableResult createResult = (StatementAgentInstanceFactoryCreateTableResult) startResult; recoveryResources = new StatementResourceHolder( lock, new Viewable[] {createResult.getFinalView()}, null, null, createResult.getOptionalAggegationService(), null, null); } if (startResult instanceof StatementAgentInstanceFactoryOnTriggerResult) { StatementAgentInstanceFactoryOnTriggerResult onTriggerResult = (StatementAgentInstanceFactoryOnTriggerResult) startResult; recoveryResources = new StatementResourceHolder( lock, null, null, new EvalRootState[] {onTriggerResult.getOptPatternRoot()}, onTriggerResult.getOptionalAggegationService(), onTriggerResult.getSubselectStrategies(), null); } if (recoveryResources != null) { this.addRecoveryResources(agentInstanceId, recoveryResources); } }