public override void Activate( IntSeqKey path, object[] parentPartitionKeys, EventBean optionalTriggeringEvent, IDictionary<string, object> optionalTriggeringPattern) { initTermSvc.MgmtCreate(path, parentPartitionKeys); ContextControllerConditionNonHA startCondition = ContextControllerConditionFactory.GetEndpoint( path, parentPartitionKeys, factory.initTermSpec.StartCondition, this, this, true); bool isTriggeringEventMatchesFilter = startCondition.Activate(optionalTriggeringEvent, null); initTermSvc.MgmtUpdSetStartCondition(path, startCondition); if (isTriggeringEventMatchesFilter || startCondition.IsImmediate) { InstantiateAndActivateEndCondition( path, optionalTriggeringEvent, optionalTriggeringPattern, optionalTriggeringPattern, startCondition); } }
public override void Activate( IntSeqKey path, object[] parentPartitionKeys, EventBean optionalTriggeringEvent, IDictionary<string, object> optionalTriggeringPattern) { initTermSvc.MgmtCreate(path, parentPartitionKeys); var startCondition = ContextControllerConditionFactory.GetEndpoint( path, parentPartitionKeys, factory.initTermSpec.StartCondition, this, this, true); var currentlyRunning = DetermineCurrentlyRunning(startCondition, this); if (!currentlyRunning) { initTermSvc.MgmtUpdSetStartCondition(path, startCondition); var isTriggeringEventMatchesFilter = startCondition.Activate(optionalTriggeringEvent, null, optionalTriggeringPattern); if (isTriggeringEventMatchesFilter) { RangeNotificationStart(path, optionalTriggeringEvent, null, null, null); } } else { InstantiateAndActivateEndCondition( path, optionalTriggeringEvent, optionalTriggeringPattern, optionalTriggeringPattern, startCondition); } }
private ContextControllerConditionNonHA ActivateTermination( EventBean triggeringEvent, object[] parentPartitionKeys, object partitionKey, IntSeqKey conditionPath, string optionalInitCondAsName) { ContextControllerConditionCallback callback = new ProxyContextControllerConditionCallback( ( conditionPathArg, originEndpoint, optionalTriggeringEvent, optionalTriggeringPattern, optionalTriggeringEventPattern, optionalPatternForInclusiveEval) => { var parentPath = conditionPathArg.RemoveFromEnd(); var getterKey = factory.GetGetterKey(partitionKey); var removed = keyedSvc.KeyRemove(parentPath, getterKey); if (removed == null) { return; } // remember the terminating event, we don't want it to initiate a new partition lastTerminatingEvent = optionalTriggeringEvent != null ? optionalTriggeringEvent : optionalTriggeringEventPattern; realization.ContextPartitionTerminate( conditionPathArg.RemoveFromEnd(), removed.SubpathOrCPId, this, null, false, null); removed.TerminationCondition.Deactivate(); }); var partitionKeys = CollectionUtil.AddValue(parentPartitionKeys, partitionKey); var terminationCondition = ContextControllerConditionFactory.GetEndpoint( conditionPath, partitionKeys, factory.keyedSpec.OptionalTermination, callback, this, false); ContextControllerEndConditionMatchEventProvider endConditionMatchEventProvider = null; if (optionalInitCondAsName != null) { endConditionMatchEventProvider = new ProxyContextControllerEndConditionMatchEventProvider { ProcPopulateEndConditionFromTrigger = ( map, triggeringEventArg) => { ContextControllerKeyedUtil.PopulatePriorMatch(optionalInitCondAsName, map, triggeringEventArg); } }; } terminationCondition.Activate(triggeringEvent, endConditionMatchEventProvider); return terminationCondition; }
internal IList<AgentInstance> InstantiateAndActivateEndCondition( IntSeqKey controllerPath, EventBean optionalTriggeringEvent, IDictionary<string, object> optionalTriggeringPattern, IDictionary<string, object> optionalPatternForInclusiveEval, ContextControllerConditionNonHA startCondition) { var subpathId = initTermSvc.MgmtUpdIncSubpath(controllerPath); var endConditionPath = controllerPath.AddToEnd(subpathId); var partitionKeys = initTermSvc.MgmtGetParentPartitionKeys(controllerPath); var endCondition = ContextControllerConditionFactory.GetEndpoint( endConditionPath, partitionKeys, factory.initTermSpec.EndCondition, this, this, false); endCondition.Activate(optionalTriggeringEvent, this); var partitionKey = ContextControllerInitTermUtil.BuildPartitionKey( optionalTriggeringEvent, optionalTriggeringPattern, endCondition, this); var result = realization.ContextPartitionInstantiate( controllerPath, subpathId, this, optionalTriggeringEvent, optionalPatternForInclusiveEval, partitionKeys, partitionKey); var subpathIdOrCPId = result.SubpathOrCPId; initTermSvc.EndCreate(endConditionPath, subpathIdOrCPId, endCondition, partitionKey); return result.AgentInstances; }
private void RangeNotificationEnd( IntSeqKey conditionPath, ContextControllerConditionNonHA endCondition, EventBean optionalTriggeringEvent, IDictionary<string, object> optionalTriggeringPattern, EventBean optionalTriggeringEventPattern) { if (endCondition.IsRunning) { endCondition.Deactivate(); } var instance = initTermSvc.EndDelete(conditionPath); if (instance == null) { return; } // start "@now" we maintain the locks var startNow = factory.InitTermSpec.StartCondition is ContextConditionDescriptorImmediate; IList<AgentInstance> agentInstancesLocksHeld = null; if (startNow) { realization.AgentInstanceContextCreate.FilterService.AcquireWriteLock(); agentInstancesLocksHeld = new List<AgentInstance>(2); } realization.ContextPartitionTerminate( conditionPath.RemoveFromEnd(), instance.SubpathIdOrCPId, this, optionalTriggeringPattern, startNow, agentInstancesLocksHeld); try { var controllerPath = conditionPath.RemoveFromEnd(); var partitionKeys = initTermSvc.MgmtGetParentPartitionKeys(controllerPath); var startDesc = factory.initTermSpec.StartCondition; var startCondition = ContextControllerConditionFactory.GetEndpoint( controllerPath, partitionKeys, startDesc, this, this, true); if (!startCondition.IsImmediate) { startCondition.Activate(optionalTriggeringEvent, null, optionalTriggeringPattern); initTermSvc.MgmtUpdSetStartCondition(controllerPath, startCondition); } else { // we do not forward triggering events of termination InstantiateAndActivateEndCondition(controllerPath, null, null, null, startCondition); } } finally { if (agentInstancesLocksHeld != null) { foreach (var agentInstance in agentInstancesLocksHeld) { agentInstance.AgentInstanceContext.EpStatementAgentInstanceHandle.StatementFilterVersion .StmtFilterVersion = long.MaxValue; if (agentInstance.AgentInstanceContext.StatementContext.EpStatementHandle.HasTableAccess) { agentInstance.AgentInstanceContext.TableExprEvaluatorContext.ReleaseAcquiredLocks(); } agentInstance.AgentInstanceContext.AgentInstanceLock.ReleaseWriteLock(); } } if (startNow) { realization.AgentInstanceContextCreate.FilterService.ReleaseWriteLock(); } } }