public void StopStatement(ContextControllerStatementDesc statement) { var statementId = statement.Lightweight.StatementContext.StatementId; if (!Statements.ContainsKey(statementId)) { return; } RemoveStatement(statementId); ContextStateEventUtil.DispatchPartition( listenersLazy, () => new ContextStateEventContextStatementRemoved( StatementContextCreate.RuntimeURI, ContextRuntimeDescriptor.ContextDeploymentId, ContextRuntimeDescriptor.ContextName, statement.Lightweight.StatementContext.DeploymentId, statement.Lightweight.StatementContext.StatementName), ( listener, context) => listener.OnContextStatementRemoved(context)); if (Statements.IsEmpty()) { Realization.StopContext(); ContextPartitionIdService.Clear(); ContextStateEventUtil.DispatchPartition( listenersLazy, () => new ContextStateEventContextDeactivated( StatementContextCreate.RuntimeURI, ContextRuntimeDescriptor.ContextDeploymentId, ContextRuntimeDescriptor.ContextName), ( listener, context) => listener.OnContextDeactivated(context)); } }
public static IDictionary<FilterSpecActivatable, FilterValueSetParam[][]> ComputeAddendumForStatement( ContextControllerStatementDesc statementDesc, ContextControllerFactory[] controllerFactories, object[] allPartitionKeys, AgentInstanceContext agentInstanceContextCreate) { IDictionary<int, FilterSpecActivatable> filters = statementDesc.Lightweight.StatementContext.FilterSpecActivatables; IDictionary<FilterSpecActivatable, FilterValueSetParam[][]> map = new IdentityDictionary<FilterSpecActivatable, FilterValueSetParam[][]>(); foreach (var filter in filters) { var addendum = ComputeAddendum( allPartitionKeys, filter.Value, true, statementDesc, controllerFactories, agentInstanceContextCreate); if (addendum != null && addendum.Length > 0) { map.Put(filter.Value, addendum); } } return map; }
public void RemoveStatement(ContextControllerStatementDesc statementDesc) { var contextControllers = ContextControllers; foreach (var id in ContextManager.ContextPartitionIdService.Ids) { AgentInstanceUtil.ContextPartitionTerminate(id, statementDesc, contextControllers, null, false, null); } }
public void StartLateStatement(ContextControllerStatementDesc statement) { var ids = ContextManager.ContextPartitionIdService.Ids; foreach (var cpid in ids) { var partitionKeys = ContextManager.ContextPartitionIdService.GetPartitionKeys(cpid); // create context properties bean var contextBean = ContextManagerUtil.BuildContextProperties( cpid, partitionKeys, ContextManager.ContextDefinition, AgentInstanceContextCreate.StatementContext); // create filter proxies Supplier<IDictionary<FilterSpecActivatable, FilterValueSetParam[][]>> generator = () => ContextManagerUtil.ComputeAddendumForStatement( statement, ContextManager.Statements, ContextManager.ContextDefinition.ControllerFactories, partitionKeys, AgentInstanceContextCreate); AgentInstanceFilterProxy proxy = new AgentInstanceFilterProxyImpl(generator); // start AgentInstanceUtil.StartStatement( ContextManager.StatementContextCreate.StatementContextRuntimeServices, cpid, statement, contextBean, proxy); } }
private static FilterValueSetParam[][] ComputeAddendum( object[] parentPartitionKeys, FilterSpecActivatable filterCallback, bool forStatement, ContextControllerStatementDesc optionalStatementDesc, ContextControllerFactory[] controllerFactories, IDictionary<int, ContextControllerStatementDesc> statements, AgentInstanceContext agentInstanceContextCreate) { var result = new FilterValueSetParam[0][]; for (var i = 0; i < parentPartitionKeys.Length; i++) { var addendumForController = controllerFactories[i] .PopulateFilterAddendum( filterCallback, forStatement, i + 1, parentPartitionKeys[i], optionalStatementDesc, statements, agentInstanceContextCreate); result = FilterAddendumUtil.MultiplyAddendum(result, addendumForController); } return result; }
public void StoppedStatement( string deploymentIdCreateContext, string contextName, ContextControllerStatementDesc statement) { var contextManager = GetAssertContextManager(deploymentIdCreateContext, contextName); contextManager.StopStatement(statement); }
public void AddStatement( string deploymentIdCreateContext, string contextName, ContextControllerStatementDesc statement, bool recovery) { var contextManager = GetAssertContextManager(deploymentIdCreateContext, contextName); contextManager.AddStatement(statement, recovery); }
public static IList<AgentInstance> GetAgentInstances( ContextControllerStatementDesc statement, ICollection<int> agentInstanceIds) { StatementContext statementContext = statement.Lightweight.StatementContext; IList<AgentInstance> instances = new List<AgentInstance>(); foreach (var id in agentInstanceIds) { var agentInstance = GetAgentInstance(statementContext, id); instances.Add(agentInstance); } return instances; }
public AgentInstanceFilterProxy ComputeFilterAddendum( ContextControllerStatementDesc statement, object[] contextPartitionKeys) { Func<AgentInstanceContext, IDictionary<FilterSpecActivatable, FilterValueSetParam[][]>> generator = agentInstanceContext => ContextManagerUtil.ComputeAddendumForStatement( statement, ContextDefinition.ControllerFactories, contextPartitionKeys, agentInstanceContext); return new AgentInstanceFilterProxyImpl(generator); }
public AgentInstanceFilterProxy ComputeFilterAddendum( ContextControllerStatementDesc statement, object[] contextPartitionKeys) { Supplier<IDictionary<FilterSpecActivatable, FilterValueSetParam[][]>> generator = () => ContextManagerUtil.ComputeAddendumForStatement( statement, Statements, ContextDefinition.ControllerFactories, contextPartitionKeys, Realization.AgentInstanceContextCreate); return new AgentInstanceFilterProxyImpl(generator); }
public static IList<AgentInstance> GetAgentInstancesFiltered( ContextControllerStatementDesc statement, ICollection<int> agentInstanceIds, Func<AgentInstance, bool> filter) { StatementContext statementContext = statement.Lightweight.StatementContext; IList<AgentInstance> instances = new List<AgentInstance>(); foreach (var id in agentInstanceIds) { var agentInstance = GetAgentInstance(statementContext, id); if (filter.Invoke(agentInstance)) { instances.Add(agentInstance); } } return instances; }
public void AddStatement( ContextControllerStatementDesc statement, bool recovery) { var statementContextOfStatement = statement.Lightweight.StatementContext; Statements.Put(statementContextOfStatement.StatementId, statement); // dispatch event ContextStateEventUtil.DispatchPartition( listenersLazy, () => new ContextStateEventContextStatementAdded( StatementContextCreate.RuntimeURI, ContextRuntimeDescriptor.ContextDeploymentId, ContextDefinition.ContextName, statementContextOfStatement.DeploymentId, statementContextOfStatement.StatementName), ( listener, context) => listener.OnContextStatementAdded(context)); if (recovery) { if (statement.Lightweight.StatementInformationals.StatementType == StatementType.CREATE_VARIABLE) { Realization.ActivateCreateVariableStatement(statement); } return; } // activate if this is the first statement if (Statements.Count == 1) { Realization.StartContext(); ContextStateEventUtil.DispatchPartition( listenersLazy, () => new ContextStateEventContextActivated( StatementContextCreate.RuntimeURI, ContextRuntimeDescriptor.ContextDeploymentId, ContextDefinition.ContextName), ( listener, context) => listener.OnContextActivated(context)); } else { // activate statement in respect to existing context partitions Realization.StartLateStatement(statement); } }
public void ActivateCreateVariableStatement(ContextControllerStatementDesc statement) { var ids = ContextManager.ContextPartitionIdService.Ids; ContextManagerUtil.GetAgentInstances(statement, ids); }