public StatementContext( IContainer container, ContextRuntimeDescriptor contextRuntimeDescriptor, string deploymentId, int statementId, string statementName, string moduleName, StatementInformationalsRuntime statementInformationals, object userObjectRuntime, StatementContextRuntimeServices statementContextRuntimeServices, EPStatementHandle epStatementHandle, IDictionary<int, FilterSpecActivatable> filterSpecActivatables, PatternSubexpressionPoolStmtSvc patternSubexpressionPoolSvc, RowRecogStatePoolStmtSvc rowRecogStatePoolStmtSvc, ScheduleBucket scheduleBucket, StatementAIResourceRegistry statementAIResourceRegistry, StatementCPCacheService statementCPCacheService, StatementAIFactoryProvider statementAIFactoryProvider, StatementResultService statementResultService, UpdateDispatchView updateDispatchView, FilterService filterService, SchedulingService schedulingService, InternalEventRouteDest internalEventRouteDest) { Container = container; ContextRuntimeDescriptor = contextRuntimeDescriptor; DeploymentId = deploymentId; StatementId = statementId; StatementName = statementName; ModuleName = moduleName; StatementInformationals = statementInformationals; UserObjectRuntime = userObjectRuntime; StatementContextRuntimeServices = statementContextRuntimeServices; EpStatementHandle = epStatementHandle; FilterSpecActivatables = filterSpecActivatables; PatternSubexpressionPoolSvc = patternSubexpressionPoolSvc; RowRecogStatePoolStmtSvc = rowRecogStatePoolStmtSvc; ScheduleBucket = scheduleBucket; StatementAIResourceRegistry = statementAIResourceRegistry; StatementCPCacheService = statementCPCacheService; StatementAIFactoryProvider = statementAIFactoryProvider; StatementResultService = statementResultService; UpdateDispatchView = updateDispatchView; StatementContextFilterEvalEnv = new StatementContextFilterEvalEnv( statementContextRuntimeServices.ImportServiceRuntime, statementInformationals.Annotations, statementContextRuntimeServices.VariableManagementService, statementContextRuntimeServices.TableExprEvaluatorContext); this.FilterService = filterService; this.SchedulingService = schedulingService; this.InternalEventRouteDest = internalEventRouteDest; }
public static AgentInstance StartStatement( StatementContextRuntimeServices services, int assignedContextId, ContextControllerStatementDesc statementDesc, MappedEventBean contextBean, AgentInstanceFilterProxy proxy) { var result = AgentInstanceUtil.Start( services, statementDesc, assignedContextId, contextBean, proxy, false); return new AgentInstance(result.StopCallback, result.AgentInstanceContext, result.FinalView); }
public static StatementAgentInstanceFactoryResult Start( StatementContextRuntimeServices services, ContextControllerStatementDesc statement, int agentInstanceId, MappedEventBean contextProperties, AgentInstanceFilterProxy agentInstanceFilterProxy, bool isRecoveringResilient) { var statementContext = statement.Lightweight.StatementContext; // create handle that comtains lock for use in scheduling and filter callbacks var @lock = statementContext.StatementAIFactoryProvider.Factory.ObtainAgentInstanceLock( statementContext, agentInstanceId); var agentInstanceHandle = new EPStatementAgentInstanceHandle(statementContext.EpStatementHandle, agentInstanceId, @lock); var auditProvider = statementContext.StatementInformationals.AuditProvider; var instrumentationProvider = statementContext.StatementInformationals.InstrumentationProvider; var agentInstanceContext = new AgentInstanceContext( statementContext, agentInstanceHandle, agentInstanceFilterProxy, contextProperties, auditProvider, instrumentationProvider); if (agentInstanceId != -1) { agentInstanceContext.AuditProvider.ContextPartition(true, agentInstanceContext); } var statementAgentInstanceLock = agentInstanceContext.EpStatementAgentInstanceHandle.StatementAgentInstanceLock; agentInstanceContext.InstrumentationProvider.QContextPartitionAllocate(agentInstanceContext); using (statementAgentInstanceLock.AcquireWriteLock()) { try { // start var startResult = statement.Lightweight.StatementProvider.StatementAIFactoryProvider.Factory.NewContext( agentInstanceContext, isRecoveringResilient); // hook up with listeners+subscribers startResult.FinalView.Child = statement.ContextMergeView; // hook output to merge view // assign agents for expression-node based strategies var aiResourceRegistry = statementContext.StatementAIResourceRegistry; AIRegistryUtil.AssignFutures( aiResourceRegistry, agentInstanceId, startResult.OptionalAggegationService, startResult.PriorStrategies, startResult.PreviousGetterStrategies, startResult.SubselectStrategies, startResult.TableAccessStrategies, startResult.RowRecogPreviousStrategy); // execute preloads, if any if (startResult.PreloadList != null) { foreach (var preload in startResult.PreloadList) { preload.ExecutePreload(); } } // handle any pattern-match-event that was produced during startup, relevant for "timer:interval(0)" in conjunction with contexts startResult.PostContextMergeRunnable?.Invoke(); var holder = services.StatementResourceHolderBuilder.Build(agentInstanceContext, startResult); statementContext.StatementCPCacheService.StatementResourceService.SetPartitioned( agentInstanceId, holder); // instantiated return startResult; } finally { if (agentInstanceContext.StatementContext.EpStatementHandle.HasTableAccess) { agentInstanceContext.TableExprEvaluatorContext.ReleaseAcquiredLocks(); } agentInstanceContext.InstrumentationProvider.AContextPartitionAllocate(); } } }