public ContextControllerStatementDesc( StatementLightweight lightweight, ContextMergeView contextMergeView) { Lightweight = lightweight; ContextMergeView = contextMergeView; }
public DeployerSubstitutionParameterHandler( string deploymentId, StatementLightweight lightweight, IDictionary<int, IDictionary<int, object>> provided, Type[] types, IDictionary<string, int> names) { DeploymentId = deploymentId; this.lightweight = lightweight; this.provided = provided; SubstitutionParameterTypes = types; SubstitutionParameterNames = names; aiFactoryProvider = lightweight.StatementProvider.StatementAIFactoryProvider; }
private static StatementAgentInstanceFactoryResult StartStatementNoContext( StatementLightweight lightweight, bool recovery, EPServicesContext services) { var statementContext = lightweight.StatementContext; var agentInstanceContext = statementContext.MakeAgentInstanceContextUnpartitioned(); // start var result = lightweight.StatementProvider.StatementAIFactoryProvider.Factory.NewContext(agentInstanceContext, recovery); // keep var holder = services.StatementResourceHolderBuilder.Build(agentInstanceContext, result); statementContext.StatementCPCacheService.StatementResourceService.Unpartitioned = holder; return(result); }
private static EPStatementSPI DeployStatement( bool recovery, StatementLightweight lightweight, EPRuntimeSPI epRuntime) { // statement-create: safe operation for registering things var statementAgentInstanceFactory = lightweight.StatementContext.StatementAIFactoryProvider.Factory; statementAgentInstanceFactory.StatementCreate(lightweight.StatementContext); // add statement var stmt = MakeStatement( lightweight.StatementContext.UpdateDispatchView, lightweight.StatementContext, (StatementResultServiceImpl)lightweight.StatementResultService, epRuntime); // add statement to globals epRuntime.ServicesContext.StatementLifecycleService.AddStatement(stmt); // it is now available for lookup Viewable finalView; StatementDestroyCallback statementDestroyCallback; ICollection <StatementAgentInstancePreload> preloads = null; var contextName = lightweight.StatementInformationals.OptionalContextName; if (contextName == null) { var result = StartStatementNoContext(lightweight, recovery, epRuntime.ServicesContext); finalView = result.FinalView; preloads = result.PreloadList; var createContextStmt = result is StatementAgentInstanceFactoryCreateContextResult; statementDestroyCallback = new ProxyStatementDestroyCallback() { ProcDestroy = ( destroyServices, statementContext) => { // All statements other that create-context: get the agent-instance-context and stop // Create-context statements already got destroyed when the last statement associated to context was removed. if (!createContextStmt) { var holder = statementContext.StatementCPCacheService.MakeOrGetEntryCanNull(-1, statementContext); holder.AgentInstanceStopCallback.Stop(new AgentInstanceStopServices(holder.AgentInstanceContext)); } // Invoke statement-destroy statementAgentInstanceFactory.StatementDestroy(lightweight.StatementContext); }, }; // assign StatementAIFactoryAssignments assignments = new StatementAIFactoryAssignmentsImpl( result.OptionalAggegationService, result.PriorStrategies, result.PreviousGetterStrategies, result.SubselectStrategies, result.TableAccessStrategies, result.RowRecogPreviousStrategy); lightweight.StatementContext.StatementAIFactoryProvider.Assign(assignments); } else { var contextModuleName = lightweight.StatementInformationals.OptionalContextModuleName; var statementAIResourceRegistry = lightweight.StatementContext.StatementAIResourceRegistry; var contextVisibility = lightweight.StatementInformationals.OptionalContextVisibility; var contextDeploymentId = ContextDeployTimeResolver.ResolveContextDeploymentId( contextModuleName, contextVisibility, contextName, lightweight.StatementContext.DeploymentId, lightweight.StatementContext.PathContextRegistry); var contextMergeView = lightweight.StatementInformationals.StatementType.IsOnTriggerInfra() ? new ContextMergeViewForwarding(null) : new ContextMergeView(null); finalView = contextMergeView; var statement = new ContextControllerStatementDesc(lightweight, contextMergeView); // assignments before add-statement, since add-statement creates context partitions which may preload lightweight.StatementContext.StatementAIFactoryProvider.Assign(new StatementAIFactoryAssignmentContext(statementAIResourceRegistry)); // add statement epRuntime.ServicesContext.ContextManagementService.AddStatement(contextDeploymentId, contextName, statement, recovery); statementDestroyCallback = new ProxyStatementDestroyCallback() { ProcDestroy = ( destroyServices, statementContext) => { var ctx = statement.Lightweight.StatementContext; epRuntime.ServicesContext.ContextManagementService.StoppedStatement( contextDeploymentId, contextName, ctx.StatementId, ctx.StatementName, ctx.DeploymentId); statementAgentInstanceFactory.StatementDestroy(lightweight.StatementContext); }, }; } // make dispatch view finalView.Child = lightweight.StatementContext.UpdateDispatchView; // assign parent view stmt.StatementContext.DestroyCallback = statementDestroyCallback; stmt.ParentView = finalView; // execute preloads if (preloads != null) { foreach (var preload in preloads) { preload.ExecutePreload(); } } return(stmt); }