/// <summary> /// Ctor. /// </summary> /// <param name="isFirst">true for the first-where clause, false for all where-clauses</param> /// <param name="eventType">output type</param> /// <param name="epStatementHandle">handle</param> /// <param name="internalEventRouter">routining output events</param> /// <param name="tableStateInstance">The table state instance.</param> /// <param name="isNamedWindowInsert">The is named window insert.</param> /// <param name="processors">processors for select clauses</param> /// <param name="whereClauses">where expressions</param> /// <param name="agentInstanceContext">agent instance context</param> /// <exception cref="System.ArgumentException">Number of where-clauses and processors does not match</exception> public RouteResultView( bool isFirst, EventType eventType, EPStatementHandle epStatementHandle, InternalEventRouter internalEventRouter, TableStateInstance[] tableStateInstance, bool[] isNamedWindowInsert, ResultSetProcessor[] processors, ExprNode[] whereClauses, AgentInstanceContext agentInstanceContext) { if (whereClauses.Length != processors.Length) { throw new ArgumentException("Number of where-clauses and processors does not match"); } _exprEvaluatorContext = agentInstanceContext; _eventType = eventType; if (isFirst) { _handler = new RouteResultViewHandlerFirst(epStatementHandle, internalEventRouter, tableStateInstance, isNamedWindowInsert, processors, ExprNodeUtility.GetEvaluators(whereClauses), agentInstanceContext); } else { _handler = new RouteResultViewHandlerAll(epStatementHandle, internalEventRouter, tableStateInstance, isNamedWindowInsert, processors, ExprNodeUtility.GetEvaluators(whereClauses), agentInstanceContext); } }
public RouteResultView( bool isFirst, EventType eventType, EPStatementHandle epStatementHandle, InternalEventRouter internalEventRouter, TableStateInstance[] tableStateInstances, EPStatementStartMethodOnTriggerItem[] items, ResultSetProcessor[] processors, ExprEvaluator[] whereClauses, AgentInstanceContext agentInstanceContext) { if (whereClauses.Length != processors.Length) { throw new ArgumentException("Number of where-clauses and processors does not match"); } _exprEvaluatorContext = agentInstanceContext; _eventType = eventType; if (isFirst) { _handler = new RouteResultViewHandlerFirst( epStatementHandle, internalEventRouter, tableStateInstances, items, processors, whereClauses, agentInstanceContext); } else { _handler = new RouteResultViewHandlerAll( epStatementHandle, internalEventRouter, tableStateInstances, items, processors, whereClauses, agentInstanceContext); } }
public void TestDropNoJoin() { var stmtHande = new EPStatementHandle(1, "id", null, StatementType.SELECT, "text", false, null, 1, false, false, new MultiMatchHandlerFactoryImpl().GetDefaultHandler()); var stmtAgentHandle = new EPStatementAgentInstanceHandle(stmtHande, ReaderWriterLockManager.CreateDefaultLock(), -1, null, null); _streams = new EventStream[4]; _streams[0] = _streamFactoryService.CreateStream(1, _filterSpecs[0], _supportFilterService, stmtAgentHandle, false, null, false, false, null, false, 0, false).First; _streams[1] = _streamFactoryService.CreateStream(2, _filterSpecs[0], _supportFilterService, stmtAgentHandle, false, null, false, false, null, false, 0, false).First; _streams[2] = _streamFactoryService.CreateStream(3, _filterSpecs[1], _supportFilterService, stmtAgentHandle, false, null, false, false, null, false, 0, false).First; _streams[3] = _streamFactoryService.CreateStream(4, _filterSpecs[2], _supportFilterService, stmtAgentHandle, false, null, false, false, null, false, 0, false).First; _streamFactoryService.DropStream(_filterSpecs[0], _supportFilterService, false, false, false, false); _streamFactoryService.DropStream(_filterSpecs[1], _supportFilterService, false, false, false, false); Assert.AreEqual(0, _supportFilterService.Removed.Count); // Filter removed _streamFactoryService.DropStream(_filterSpecs[0], _supportFilterService, false, false, false, false); Assert.AreEqual(1, _supportFilterService.Removed.Count); _streamFactoryService.DropStream(_filterSpecs[2], _supportFilterService, false, false, false, false); Assert.AreEqual(2, _supportFilterService.Removed.Count); // Something already removed try { _streamFactoryService.DropStream(_filterSpecs[2], _supportFilterService, false, false, false, false); Assert.Fail(); } catch (IllegalStateException) { // Expected } }
private void ScheduleNextCallback() { var nextScheduleCallback = new ProxyScheduleHandleCallback(delegate { ContinueSendingEvents(); }); var spi = (EPServiceProviderSPI)_epService; var metricsHandle = spi.MetricReportingService.GetStatementHandle(-1, "AbstractCoordinatedAdapter"); var lockImpl = ReaderWriterLockManager.CreateLock("CSV"); var stmtHandle = new EPStatementHandle(-1, "AbstractCoordinatedAdapter", null, StatementType.ESPERIO, "AbstractCoordinatedAdapter", false, metricsHandle, 0, false, false, spi.ServicesContext.MultiMatchHandlerFactory.GetDefaultHandler()); var agentInstanceHandle = new EPStatementAgentInstanceHandle(stmtHandle, lockImpl, -1, new StatementAgentInstanceFilterVersion(), null); var scheduleCSVHandle = new EPStatementHandleCallback(agentInstanceHandle, nextScheduleCallback); ScheduleSlot nextScheduleSlot; if (EventsToSend.IsEmpty()) { if ((ExecutionPathDebugLog.IsEnabled) && (Log.IsDebugEnabled)) { Log.Debug(".scheduleNextCallback no events to send, scheduling callback in 100 ms"); } nextScheduleSlot = new ScheduleSlot(0, 0); _schedulingService.Add(100, scheduleCSVHandle, nextScheduleSlot); } else { // Offset is not a function of the currentTime alone. var first = EventsToSend.First(); long baseMsec = _currentTime - _startTime; long afterMsec = first.SendTime - baseMsec; nextScheduleSlot = first.ScheduleSlot; if ((ExecutionPathDebugLog.IsEnabled) && (Log.IsDebugEnabled)) { Log.Debug(".scheduleNextCallback schedulingCallback in " + afterMsec + " milliseconds"); } _schedulingService.Add(afterMsec, scheduleCSVHandle, nextScheduleSlot); } }
public RouteResultView( bool isFirst, EventType eventType, EPStatementHandle epStatementHandle, InternalEventRouter internalEventRouter, TableInstance[] tableInstances, OnSplitItemEval[] items, ResultSetProcessor[] processors, AgentInstanceContext agentInstanceContext) { exprEvaluatorContext = agentInstanceContext; EventType = eventType; if (isFirst) { handler = new RouteResultViewHandlerFirst( epStatementHandle, internalEventRouter, tableInstances, items, processors, agentInstanceContext); } else { handler = new RouteResultViewHandlerAll( epStatementHandle, internalEventRouter, tableInstances, items, processors, agentInstanceContext); } }
public EPStatementAgentInstanceHandle(EPStatementHandle statementHandle, IReaderWriterLock statementAgentInstanceLock, int agentInstanceId, StatementAgentInstanceFilterVersion statementFilterVersion) { StatementHandle = statementHandle; _statementAgentInstanceLock = statementAgentInstanceLock; AgentInstanceId = agentInstanceId; _hashCode = 31 * statementHandle.GetHashCode() + agentInstanceId; StatementFilterVersion = statementFilterVersion; }
public RouteResultViewHandlerFirst( EPStatementHandle epStatementHandle, InternalEventRouter internalEventRouter, TableInstance[] tableInstances, OnSplitItemEval[] items, ResultSetProcessor[] processors, AgentInstanceContext agentInstanceContext) : base(epStatementHandle, internalEventRouter, tableInstances, items, processors, agentInstanceContext) { }
public TableOnSelectViewFactory(TableMetadata tableMetadata, InternalEventRouter internalEventRouter, EPStatementHandle statementHandle, EventBeanReader eventBeanReader, bool distinct, StatementResultService statementResultService, InternalEventRouteDest internalEventRouteDest, bool deleteAndSelect) { _tableMetadata = tableMetadata; InternalEventRouter = internalEventRouter; StatementHandle = statementHandle; EventBeanReader = eventBeanReader; IsDistinct = distinct; StatementResultService = statementResultService; InternalEventRouteDest = internalEventRouteDest; _deleteAndSelect = deleteAndSelect; }
/// <summary> /// Ctor. /// </summary> /// <param name="epStatementHandle">handle</param> /// <param name="internalEventRouter">routes generated events</param> /// <param name="tableStateInstances"></param> /// <param name="isNamedWindowInsert">The is named window insert.</param> /// <param name="processors">select clauses</param> /// <param name="whereClauses">where clauses</param> /// <param name="agentInstanceContext">agent instance context</param> public RouteResultViewHandlerFirst(EPStatementHandle epStatementHandle, InternalEventRouter internalEventRouter, TableStateInstance[] tableStateInstances, bool[] isNamedWindowInsert, ResultSetProcessor[] processors, ExprEvaluator[] whereClauses, AgentInstanceContext agentInstanceContext) { _internalEventRouter = internalEventRouter; _tableStateInstances = tableStateInstances; _isNamedWindowInsert = isNamedWindowInsert; _epStatementHandle = epStatementHandle; _processors = processors; _whereClauses = whereClauses; _agentInstanceContext = agentInstanceContext; _audit = AuditEnum.INSERT.GetAudit(agentInstanceContext.StatementContext.Annotations) != null; }
public EPStatementAgentInstanceHandle(EPStatementHandle statementHandle, IReaderWriterLock statementAgentInstanceLock, int agentInstanceId, StatementAgentInstanceFilterVersion statementFilterVersion, FilterFaultHandlerFactory filterFaultHandlerFactory) { StatementHandle = statementHandle; _statementAgentInstanceLock = statementAgentInstanceLock; AgentInstanceId = agentInstanceId; _hashCode = 31 * statementHandle.GetHashCode() + agentInstanceId; StatementFilterVersion = statementFilterVersion; if (filterFaultHandlerFactory != null) { FilterFaultHandler = filterFaultHandlerFactory.MakeFilterFaultHandler(); } }
public RouteResultViewHandlerFirst( EPStatementHandle epStatementHandle, InternalEventRouter internalEventRouter, TableStateInstance[] tableStateInstances, EPStatementStartMethodOnTriggerItem[] items, ResultSetProcessor[] processors, ExprEvaluator[] whereClauses, AgentInstanceContext agentInstanceContext) : base( epStatementHandle, internalEventRouter, tableStateInstances, items, processors, whereClauses, agentInstanceContext) { }
public NamedWindowOnSelectViewFactory(EventType namedWindowEventType, InternalEventRouter internalEventRouter, bool addToFront, EPStatementHandle statementHandle, EventBeanReader eventBeanReader, bool distinct, StatementResultService statementResultService, InternalEventRouteDest internalEventRouteDest, bool deleteAndSelect, StreamSelector?optionalStreamSelector, string optionalInsertIntoTableName) : base(namedWindowEventType) { InternalEventRouter = internalEventRouter; IsAddToFront = addToFront; StatementHandle = statementHandle; EventBeanReader = eventBeanReader; IsDistinct = distinct; StatementResultService = statementResultService; InternalEventRouteDest = internalEventRouteDest; _deleteAndSelect = deleteAndSelect; OptionalStreamSelector = optionalStreamSelector; _optionalInsertIntoTableName = optionalInsertIntoTableName; }
/// <summary>Register an adapter. </summary> /// <param name="epService">engine</param> public void RegisterAdapter(EPServiceProvider epService) { var spi = (EPServiceProviderSPI)epService; var eventType = spi.EventAdapterService.GetEventTypeByName(EventTypeName); var fvs = new FilterSpecCompiled(eventType, null, new IList <FilterSpecParam> [0], null).GetValueSet(null, null, null); var name = "subscription:" + SubscriptionName; var metricsHandle = spi.MetricReportingService.GetStatementHandle(name, name); var statementHandle = new EPStatementHandle(name, name, name, StatementType.ESPERIO, name, false, metricsHandle, 0, false, false, MultiMatchHandlerFactory.DefaultHandler); var agentHandle = new EPStatementAgentInstanceHandle(statementHandle, ReaderWriterLockManager.CreateDefaultLock(), -1, new StatementAgentInstanceFilterVersion()); var registerHandle = new EPStatementHandleCallback(agentHandle, this); spi.FilterService.Add(fvs, registerHandle); }
public void SetUp() { _container = SupportContainer.Reset(); _handle = new EPStatementHandle(1, "name", "text", StatementType.SELECT, "text", false, null, 1, false, false, new MultiMatchHandlerFactoryImpl().GetDefaultHandler()); _agentHandle = new EPStatementAgentInstanceHandle(_handle, _container.RWLockManager().CreateDefaultLock(), -1, null, null); _supportFilterService = new SupportFilterServiceImpl(); _streamFactoryService = new StreamFactorySvcImpl("default", true); var eventType = SupportEventTypeFactory.CreateBeanType(typeof(SupportBean)); _filterSpecs = new FilterSpecCompiled[3]; _filterSpecs[0] = SupportFilterSpecBuilder.Build(eventType, new Object[] { "string", FilterOperator.EQUAL, "a" }); _filterSpecs[1] = SupportFilterSpecBuilder.Build(eventType, new Object[] { "string", FilterOperator.EQUAL, "a" }); _filterSpecs[2] = SupportFilterSpecBuilder.Build(eventType, new Object[] { "string", FilterOperator.EQUAL, "b" }); }
public RouteResultViewHandlerBase( EPStatementHandle epStatementHandle, InternalEventRouter internalEventRouter, TableInstance[] tableStateInstances, OnSplitItemEval[] items, ResultSetProcessor[] processors, AgentInstanceContext agentInstanceContext) { this.internalEventRouter = internalEventRouter; this.tableStateInstances = tableStateInstances; this.items = items; this.epStatementHandle = epStatementHandle; this.processors = processors; this.agentInstanceContext = agentInstanceContext; audit = AuditEnum.INSERT.GetAudit(agentInstanceContext.Annotations) != null; }
public TableOnMergeActionIns( ExprEvaluator optionalFilter, SelectExprProcessor insertHelper, InternalEventRouter internalEventRouter, EPStatementHandle statementHandle, InternalEventRouteDest internalEventRouteDest, bool audit, TableStateRowFactory tableStateRowFactory) : base(optionalFilter) { _insertHelper = insertHelper; _internalEventRouter = internalEventRouter; _statementHandle = statementHandle; _internalEventRouteDest = internalEventRouteDest; _audit = audit; _tableStateRowFactory = tableStateRowFactory; }
protected RouteResultViewHandlerBase( EPStatementHandle epStatementHandle, InternalEventRouter internalEventRouter, TableStateInstance[] tableStateInstances, EPStatementStartMethodOnTriggerItem[] items, ResultSetProcessor[] processors, ExprEvaluator[] whereClauses, AgentInstanceContext agentInstanceContext) { InternalEventRouter = internalEventRouter; _tableStateInstances = tableStateInstances; Items = items; EPStatementHandle = epStatementHandle; Processors = processors; WhereClauses = whereClauses; AgentInstanceContext = agentInstanceContext; Audit = AuditEnum.INSERT.GetAudit(agentInstanceContext.StatementContext.Annotations) != null; }
public OutputStrategyPostProcessFactory( bool route, SelectClauseStreamSelectorEnum?insertIntoStreamSelector, SelectClauseStreamSelectorEnum selectStreamDirEnum, InternalEventRouter internalEventRouter, EPStatementHandle epStatementHandle, bool addToFront, TableService tableService, string tableName) { IsRoute = route; InsertIntoStreamSelector = insertIntoStreamSelector; SelectStreamDirEnum = selectStreamDirEnum; InternalEventRouter = internalEventRouter; EpStatementHandle = epStatementHandle; IsAddToFront = addToFront; TableService = tableService; TableName = tableName; }
public NamedWindowOnMergeActionIns( ExprEvaluator optionalFilter, SelectExprProcessor insertHelper, InternalEventRouter internalEventRouter, String insertIntoTableName, TableService tableService, EPStatementHandle statementHandle, InternalEventRouteDest internalEventRouteDest, bool audit) : base(optionalFilter) { _insertHelper = insertHelper; _internalEventRouter = internalEventRouter; _insertIntoTableName = insertIntoTableName; _tableService = tableService; _statementHandle = statementHandle; _internalEventRouteDest = internalEventRouteDest; _audit = audit; }
public void TestCreateNoJoin() { var stmtHande = new EPStatementHandle(1, "id", null, StatementType.SELECT, "text", false, null, 1, false, false, new MultiMatchHandlerFactoryImpl().GetDefaultHandler()); var stmtAgentHandle = new EPStatementAgentInstanceHandle(stmtHande, ReaderWriterLockManager.CreateDefaultLock(), -1, null, null); _streams = new EventStream[4]; _streams[0] = _streamFactoryService.CreateStream(1, _filterSpecs[0], _supportFilterService, stmtAgentHandle, false, null, false, false, null, false, 0, false).First; _streams[1] = _streamFactoryService.CreateStream(2, _filterSpecs[0], _supportFilterService, stmtAgentHandle, false, null, false, false, null, false, 0, false).First; _streams[2] = _streamFactoryService.CreateStream(3, _filterSpecs[1], _supportFilterService, stmtAgentHandle, false, null, false, false, null, false, 0, false).First; _streams[3] = _streamFactoryService.CreateStream(4, _filterSpecs[2], _supportFilterService, stmtAgentHandle, false, null, false, false, null, false, 0, false).First; // Streams are reused Assert.AreSame(_streams[0], _streams[1]); Assert.AreSame(_streams[0], _streams[2]); Assert.AreNotSame(_streams[0], _streams[3]); // Type is ok Assert.AreEqual(typeof(SupportBean), _streams[0].EventType.UnderlyingType); // 2 filters are active now Assert.AreEqual(2, _supportFilterService.Added.Count); }
private void ScheduleNextCallback() { var nextScheduleCallback = new ProxyScheduleHandleCallback(delegate { ContinueSendingEvents(); }); var spi = (EPRuntimeSPI)_runtime; var deploymentId = "CSV-adapter-" + UuidGenerator.Generate(); var metricsHandle = spi.ServicesContext.MetricReportingService.GetStatementHandle(-1, deploymentId, "AbstractCoordinatedAdapter"); var lockImpl = _container.RWLockManager().CreateLock("CSV"); var stmtHandle = new EPStatementHandle( "AbstractCoordinatedAdapter", deploymentId, -1, null, 0, false, false, spi.ServicesContext.MultiMatchHandlerFactory.Make(false, false), false, false, metricsHandle, null, null); var agentInstanceHandle = new EPStatementAgentInstanceHandle(stmtHandle, -1, lockImpl); var scheduleCSVHandle = new EPStatementHandleCallbackSchedule(agentInstanceHandle, nextScheduleCallback); long nextScheduleSlot; if (EventsToSend.IsEmpty()) { if ((ExecutionPathDebugLog.IsDebugEnabled) && (Log.IsDebugEnabled)) { Log.Debug(".scheduleNextCallback no events to send, scheduling callback in 100 ms"); } nextScheduleSlot = 0L; _schedulingService.Add(100, scheduleCSVHandle, nextScheduleSlot); } else { // Offset is not a function of the currentTime alone. var first = EventsToSend.First(); long baseMsec = _currentTime - _startTime; long afterMsec = first.SendTime - baseMsec; nextScheduleSlot = first.ScheduleSlot; if ((ExecutionPathDebugLog.IsDebugEnabled) && (Log.IsDebugEnabled)) { Log.Debug(".scheduleNextCallback schedulingCallback in " + afterMsec + " milliseconds"); } _schedulingService.Add(afterMsec, scheduleCSVHandle, nextScheduleSlot); } }
public void Route(EventBean theEvent, EPStatementHandle statementHandle, InternalEventRouteDest routeDest, ExprEvaluatorContext exprEvaluatorContext, bool addToFront) { _routed.Add(theEvent); }
public void QRouteBetweenStmt(EventBean theEvent, EPStatementHandle epStatementHandle, bool addToFront) { }
public TestStreamFactorySvcImpl() { _handle = new EPStatementHandle(1, "name", "text", StatementType.SELECT, "text", false, null, 1, false, false, new MultiMatchHandlerFactoryImpl().GetDefaultHandler()); _agentHandle = new EPStatementAgentInstanceHandle(_handle, ReaderWriterLockManager.CreateDefaultLock(), -1, null, null); }
private static StatementLightweight InitStatement( bool recovery, string moduleName, StatementProvider statementProvider, string deploymentId, int statementId, EventTypeResolver eventTypeResolver, ModuleIncidentals moduleIncidentals, StatementNameRuntimeOption statementNameResolverRuntime, StatementUserObjectRuntimeOption userObjectResolverRuntime, ClassLoader moduleClassLoader, EPServicesContext services) { var informationals = statementProvider.Informationals; // set instrumentation unless already provided if (informationals.InstrumentationProvider == null) { informationals.InstrumentationProvider = InstrumentationDefault.INSTANCE; } var statementResultService = new StatementResultServiceImpl(informationals, services); FilterSharedLookupableRegistery filterSharedLookupableRegistery = new ProxyFilterSharedLookupableRegistery() { ProcRegisterLookupable = ( eventTypeX, lookupable) => { services.FilterSharedLookupableRepository.RegisterLookupable(statementId, eventTypeX, lookupable); }, }; FilterSharedBoolExprRegistery filterSharedBoolExprRegistery = new ProxyFilterSharedBoolExprRegistery() { ProcRegisterBoolExpr = (node) => { services.FilterSharedBoolExprRepository.RegisterBoolExpr(statementId, node); }, }; IDictionary <int, FilterSpecActivatable> filterSpecActivatables = new Dictionary <int, FilterSpecActivatable>(); FilterSpecActivatableRegistry filterSpecActivatableRegistry = new ProxyFilterSpecActivatableRegistry() { ProcRegister = (filterSpecActivatable) => { filterSpecActivatables.Put(filterSpecActivatable.FilterCallbackId, filterSpecActivatable); }, }; var contextPartitioned = informationals.OptionalContextName != null; var statementResourceService = new StatementResourceService(contextPartitioned); // determine statement name var statementName = informationals.StatementNameCompileTime; if (statementNameResolverRuntime != null) { string statementNameAssigned = statementNameResolverRuntime.Invoke( new StatementNameRuntimeContext( deploymentId, statementName, statementId, (string)informationals.Properties.Get(StatementProperty.EPL), informationals.Annotations)); if (statementNameAssigned != null) { statementName = statementNameAssigned; } } statementName = statementName.Trim(); var epInitServices = new EPStatementInitServicesImpl( statementName, informationals.Properties, informationals.Annotations, deploymentId, eventTypeResolver, filterSpecActivatableRegistry, filterSharedBoolExprRegistery, filterSharedLookupableRegistery, moduleIncidentals, recovery, statementResourceService, statementResultService, services); if (!services.EpServicesHA.RuntimeExtensionServices.IsHAEnabled) { statementProvider.Initialize(epInitServices); } else { // for HA we set the context classloader as state may be loaded considering the module provider's classloader // - NEsper doesn't support HA like this, and we wouldn't want to deliver this information in // - this manner. An alternative delivery mechanism must be established to carry the information // - without relying on the "current" thread to carry that detail. // ClassLoader originalClassLoader = Thread.CurrentThread().ContextClassLoader; // try { // Thread.CurrentThread().ContextClassLoader = moduleClassLoader; // statementProvider.Initialize(epInitServices); // } // finally { // Thread.CurrentThread().ContextClassLoader = originalClassLoader; // } } var multiMatchHandler = services.MultiMatchHandlerFactory.Make(informationals.HasSubquery, informationals.IsNeedDedup); var stmtMetric = services.MetricReportingService.GetStatementHandle(statementId, deploymentId, statementName); var optionalEPL = (string)informationals.Properties.Get(StatementProperty.EPL); InsertIntoLatchFactory insertIntoFrontLatchFactory = null; InsertIntoLatchFactory insertIntoBackLatchFactory = null; if (informationals.InsertIntoLatchName != null) { var latchFactoryNameBack = "insert_stream_B_" + informationals.InsertIntoLatchName + "_" + statementName; var latchFactoryNameFront = "insert_stream_F_" + informationals.InsertIntoLatchName + "_" + statementName; var msecTimeout = services.RuntimeSettingsService.ConfigurationRuntime.Threading.InsertIntoDispatchTimeout; var locking = services.RuntimeSettingsService.ConfigurationRuntime.Threading.InsertIntoDispatchLocking; var latchFactoryFront = new InsertIntoLatchFactory( latchFactoryNameFront, informationals.IsStateless, msecTimeout, locking, services.TimeSourceService); var latchFactoryBack = new InsertIntoLatchFactory( latchFactoryNameBack, informationals.IsStateless, msecTimeout, locking, services.TimeSourceService); insertIntoFrontLatchFactory = latchFactoryFront; insertIntoBackLatchFactory = latchFactoryBack; } var statementHandle = new EPStatementHandle( statementName, deploymentId, statementId, optionalEPL, informationals.Priority, informationals.IsPreemptive, informationals.IsCanSelfJoin, multiMatchHandler, informationals.HasVariables, informationals.HasTableAccess, stmtMetric, insertIntoFrontLatchFactory, insertIntoBackLatchFactory); // determine context StatementAIResourceRegistry statementAgentInstanceRegistry = null; ContextRuntimeDescriptor contextRuntimeDescriptor = null; var optionalContextName = informationals.OptionalContextName; if (optionalContextName != null) { var contextDeploymentId = ContextDeployTimeResolver.ResolveContextDeploymentId( informationals.OptionalContextModuleName, informationals.OptionalContextVisibility, optionalContextName, deploymentId, services.ContextPathRegistry); var contextManager = services.ContextManagementService.GetContextManager(contextDeploymentId, optionalContextName); contextRuntimeDescriptor = contextManager.ContextRuntimeDescriptor; var registryRequirements = statementProvider.StatementAIFactoryProvider.Factory.RegistryRequirements; statementAgentInstanceRegistry = contextManager.AllocateAgentInstanceResourceRegistry(registryRequirements); } var statementCPCacheService = new StatementCPCacheService( contextPartitioned, statementResourceService, statementAgentInstanceRegistry); var eventType = statementProvider.StatementAIFactoryProvider.Factory.StatementEventType; var configurationThreading = services.RuntimeSettingsService.ConfigurationRuntime.Threading; var preserveDispatchOrder = configurationThreading.IsListenerDispatchPreserveOrder && !informationals.IsStateless; var isSpinLocks = configurationThreading.ListenerDispatchLocking == Locking.SPIN; var msecBlockingTimeout = configurationThreading.ListenerDispatchTimeout; UpdateDispatchViewBase dispatchChildView; if (preserveDispatchOrder) { if (isSpinLocks) { dispatchChildView = new UpdateDispatchViewBlockingSpin( eventType, statementResultService, services.DispatchService, msecBlockingTimeout, services.TimeSourceService); } else { dispatchChildView = new UpdateDispatchViewBlockingWait(eventType, statementResultService, services.DispatchService, msecBlockingTimeout); } } else { dispatchChildView = new UpdateDispatchViewNonBlocking(eventType, statementResultService, services.DispatchService); } var countSubexpressions = services.ConfigSnapshot.Runtime.Patterns.MaxSubexpressions != null; PatternSubexpressionPoolStmtSvc patternSubexpressionPoolStmtSvc = null; if (countSubexpressions) { var stmtCounter = new PatternSubexpressionPoolStmtHandler(); patternSubexpressionPoolStmtSvc = new PatternSubexpressionPoolStmtSvc(services.PatternSubexpressionPoolRuntimeSvc, stmtCounter); services.PatternSubexpressionPoolRuntimeSvc.AddPatternContext(statementId, statementName, stmtCounter); } var countMatchRecogStates = services.ConfigSnapshot.Runtime.MatchRecognize.MaxStates != null; RowRecogStatePoolStmtSvc rowRecogStatePoolStmtSvc = null; if (countMatchRecogStates && informationals.HasMatchRecognize) { var stmtCounter = new RowRecogStatePoolStmtHandler(); rowRecogStatePoolStmtSvc = new RowRecogStatePoolStmtSvc(services.RowRecogStatePoolEngineSvc, stmtCounter); services.RowRecogStatePoolEngineSvc.AddPatternContext(new DeploymentIdNamePair(deploymentId, statementName), stmtCounter); } // get user object for runtime object userObjectRuntime = null; if (userObjectResolverRuntime != null) { userObjectRuntime = userObjectResolverRuntime.GetUserObject( new StatementUserObjectRuntimeContext( deploymentId, statementName, statementId, (string)informationals.Properties.Get(StatementProperty.EPL), informationals.Annotations)); } var statementContext = new StatementContext( services.Container, contextRuntimeDescriptor, deploymentId, statementId, statementName, moduleName, informationals, userObjectRuntime, services.StatementContextRuntimeServices, statementHandle, filterSpecActivatables, patternSubexpressionPoolStmtSvc, rowRecogStatePoolStmtSvc, new ScheduleBucket(statementId), statementAgentInstanceRegistry, statementCPCacheService, statementProvider.StatementAIFactoryProvider, statementResultService, dispatchChildView, services.FilterService, services.SchedulingService, services.InternalEventRouteDest ); foreach (var readyCallback in epInitServices.ReadyCallbacks) { readyCallback.Ready(statementContext, moduleIncidentals, recovery); } return(new StatementLightweight(statementProvider, informationals, statementResultService, statementContext)); }