public ViewableActivationResult Activate( AgentInstanceContext agentInstanceContext, bool isSubselect, bool isRecoveringResilient) { PatternAgentInstanceContext patternAgentInstanceContext = agentInstanceContext.StatementContext.PatternContextFactory.CreatePatternAgentContext( _patternContext, agentInstanceContext, _hasConsumingFilter); EvalRootNode rootNode = EvalNodeUtil.MakeRootNodeFromFactory(_rootFactoryNode, patternAgentInstanceContext); EventStream sourceEventStream = _isCanIterate ? (EventStream) new ZeroDepthStreamIterable(_eventType) : (EventStream) new ZeroDepthStreamNoIterate(_eventType); StatementContext statementContext = _patternContext.StatementContext; PatternMatchCallback callback = matchEvent => { EventBean compositeEvent = statementContext.EventAdapterService.AdapterForTypedMap( matchEvent, _eventType); sourceEventStream.Insert(compositeEvent); }; var rootState = (EvalRootState)rootNode.Start(callback, _patternContext, isRecoveringResilient); return(new ViewableActivationResult( sourceEventStream, rootState, null, rootState, rootState, _suppressSameEventMatches, _discardPartialsOnMatch, null)); }
public void Activate(EventBean optionalTriggeringEvent, MatchedEventMap priorMatches, long timeOffset, bool isRecoveringResilient) { if (PatternStopCallback != null) { PatternStopCallback.Stop(); } PatternStreamSpecCompiled patternStreamSpec = _endpointPatternSpec.PatternCompiled; StatementContext stmtContext = _agentInstanceContext.StatementContext; EvalRootFactoryNode rootFactoryNode = _servicesContext.PatternNodeFactory.MakeRootNode(patternStreamSpec.EvalFactoryNode); int streamNum = _isStartEndpoint ? _contextStatePathKey.SubPath : -1 * _contextStatePathKey.SubPath; bool allowResilient = _contextStatePathKey.Level == 1; PatternContext patternContext = stmtContext.PatternContextFactory.CreateContext(stmtContext, streamNum, rootFactoryNode, new MatchedEventMapMeta(patternStreamSpec.AllTags, !patternStreamSpec.ArrayEventTypes.IsEmpty()), allowResilient); PatternAgentInstanceContext patternAgentInstanceContext = stmtContext.PatternContextFactory.CreatePatternAgentContext(patternContext, _agentInstanceContext, false); EvalRootNode rootNode = EvalNodeUtil.MakeRootNodeFromFactory(rootFactoryNode, patternAgentInstanceContext); if (priorMatches == null) { priorMatches = new MatchedEventMapImpl(patternContext.MatchedEventMapMeta); } // capture any callbacks that may occur right after start ConditionPatternMatchCallback callback = new ConditionPatternMatchCallback(this); PatternStopCallback = rootNode.Start(callback.MatchFound, patternContext, priorMatches, isRecoveringResilient); callback.ForwardCalls = true; if (_agentInstanceContext.StatementContext.StatementExtensionServicesContext != null && _agentInstanceContext.StatementContext.StatementExtensionServicesContext.StmtResources != null) { _agentInstanceContext.StatementContext.StatementExtensionServicesContext.StmtResources .StartContextPattern(PatternStopCallback, _isStartEndpoint, _contextStatePathKey); } if (callback.IsInvoked) { MatchFound(Collections.GetEmptyMap <String, Object>()); } }