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 ContextPartitionTerminate( IntSeqKey controllerPath, int subpathIdOrCPId, ContextController originator, IDictionary<string, object> terminationProperties, bool leaveLocksAcquired, IList<AgentInstance> agentInstancesLocksHeld) { if (controllerPath.Length != originator.Factory.FactoryEnv.NestingLevel - 1) { throw new IllegalStateException("Unrecognized controller path"); } // detect non-leaf var controllerEnv = originator.Factory.FactoryEnv; var nestingLevel = controllerEnv.NestingLevel; // starts at 1 for root if (nestingLevel < ContextControllers.Length) { var childController = ContextControllers[nestingLevel]; var path = controllerPath.AddToEnd(subpathIdOrCPId); childController.Deactivate(path, true); return; } var agentInstanceId = subpathIdOrCPId; // stop - in reverse order of statements, to allow termination to use tables+named-windows var contextControllers = ContextControllers; var contextControllerStatementDescList = new List<ContextControllerStatementDesc>(ContextManager.Statements.Values); contextControllerStatementDescList.Reverse(); foreach (var statementDesc in contextControllerStatementDescList) { AgentInstanceUtil.ContextPartitionTerminate( agentInstanceId, statementDesc, contextControllers, terminationProperties, leaveLocksAcquired, agentInstancesLocksHeld); } // remove all context partition statement resources foreach (var statementEntry in ContextManager.Statements) { var statementDesc = statementEntry.Value; var svc = statementDesc.Lightweight.StatementContext.StatementCPCacheService.StatementResourceService; var holder = svc.DeallocatePartitioned(agentInstanceId); } // remove id ContextManager.ContextPartitionIdService.RemoveId(agentInstanceId); if (ContextManager.ListenersMayNull != null) { ContextStateEventUtil.DispatchPartition( ContextManager.ListenersMayNull, () => new ContextStateEventContextPartitionDeallocated( AgentInstanceContextCreate.RuntimeURI, ContextManager.ContextRuntimeDescriptor.ContextDeploymentId, ContextManager.ContextDefinition.ContextName, agentInstanceId), ( listener, context) => listener.OnContextPartitionDeallocated(context)); } }