Ejemplo n.º 1
0
 public override void RangeNotification(
     IntSeqKey conditionPath,
     ContextControllerConditionNonHA originCondition,
     EventBean optionalTriggeringEvent,
     IDictionary<string, object> optionalTriggeringPattern,
     EventBean optionalTriggeringEventPattern,
     IDictionary<string, object> optionalPatternForInclusiveEval)
 {
     bool endConditionNotification = originCondition.Descriptor != factory.InitTermSpec.StartCondition;
     if (endConditionNotification) {
         RangeNotificationEnd(
             conditionPath,
             originCondition,
             optionalTriggeringEvent,
             optionalTriggeringPattern,
             optionalTriggeringEventPattern);
     }
     else {
         RangeNotificationStart(
             conditionPath,
             originCondition,
             optionalTriggeringEvent,
             optionalTriggeringPattern,
             optionalTriggeringEventPattern);
     }
 }
Ejemplo n.º 2
0
        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);
            }
        }
Ejemplo n.º 3
0
 public abstract void RangeNotification(
     IntSeqKey conditionPath,
     ContextControllerConditionNonHA originEndpoint,
     EventBean optionalTriggeringEvent,
     IDictionary<string, object> optionalTriggeringPattern,
     EventBean optionalTriggeringEventPattern,
     IDictionary<string, object> optionalPatternForInclusiveEval);
Ejemplo n.º 4
0
 public ContextControllerKeyedSvcEntry(
     int subpathOrCPId,
     ContextControllerConditionNonHA terminationCondition)
 {
     SubpathOrCPId = subpathOrCPId;
     TerminationCondition = terminationCondition;
 }
 public void KeyAdd(
     IntSeqKey controllerPath,
     object key,
     int subpathIdOrCPId,
     ContextControllerConditionNonHA terminationCondition)
 {
     _keys.Put(key, new ContextControllerKeyedSvcEntry(subpathIdOrCPId, terminationCondition));
 }
Ejemplo n.º 6
0
 public void MgmtUpdSetStartCondition(
     IntSeqKey controllerPath,
     ContextControllerConditionNonHA startCondition)
 {
     var existing = mgmt.Get(controllerPath);
     if (existing != null) {
         existing.startCondition = startCondition;
     }
 }
Ejemplo n.º 7
0
 internal NestedEntry(
     int currentSubpath,
     ContextControllerConditionNonHA startCondition,
     object[] parentPartitionKeys)
 {
     this.currentSubpath = currentSubpath;
     this.startCondition = startCondition;
     this.parentPartitionKeys = parentPartitionKeys;
 }
 public ContextControllerInitTermSvcEntry(
     int subpathIdOrCPId,
     ContextControllerConditionNonHA terminationCondition,
     ContextControllerInitTermPartitionKey partitionKey)
 {
     SubpathIdOrCPId = subpathIdOrCPId;
     TerminationCondition = terminationCondition;
     PartitionKey = partitionKey;
 }
Ejemplo n.º 9
0
 public void EndCreate(
     IntSeqKey endConditionPath,
     int subpathIdOrCPId,
     ContextControllerConditionNonHA endCondition,
     ContextControllerInitTermPartitionKey partitionKey)
 {
     endConditions.Put(
         ((IntSeqKeyOne) endConditionPath).One,
         new ContextControllerInitTermSvcEntry(subpathIdOrCPId, endCondition, partitionKey));
 }
Ejemplo n.º 10
0
        public ContextControllerConditionNonHA MgmtUpdClearStartCondition(IntSeqKey controllerPath)
        {
            var existing = mgmt.Get(controllerPath);
            ContextControllerConditionNonHA tmp = null;
            if (existing != null) {
                tmp = existing.startCondition;
                existing.startCondition = null;
            }

            return tmp;
        }
Ejemplo n.º 11
0
        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;
        }
Ejemplo n.º 12
0
 public void Destroy()
 {
     currentSubpath = 0;
     startCondition = null;
     endConditions = null;
 }
Ejemplo n.º 13
0
 public void MgmtUpdSetStartCondition(
     IntSeqKey controllerPath,
     ContextControllerConditionNonHA startCondition)
 {
     this.startCondition = startCondition;
 }
Ejemplo n.º 14
0
 public ContextControllerConditionNonHA MgmtUpdClearStartCondition(IntSeqKey controllerPath)
 {
     var tmp = startCondition;
     startCondition = null;
     return tmp;
 }
Ejemplo n.º 15
0
        public void MatchFound(
            ContextControllerDetailKeyedItem item,
            EventBean theEvent,
            IntSeqKey controllerPath,
            string optionalInitCondAsName)
        {
            if (controllerPath.Length != Factory.FactoryEnv.NestingLevel - 1) {
                throw new IllegalStateException("Unrecognized controller path");
            }

            var getterKey = item.Getter.Get(theEvent);
            var exists = keyedSvc.KeyHasSeen(controllerPath, getterKey);
            if (exists || theEvent == LastTerminatingEvent) {
                // if all-matches is more than one, the termination has also fired
                return;
            }

            LastTerminatingEvent = null;

            var partitionKey = getterKey;
            if (KeyedFactory.KeyedSpec.HasAsName) {
                partitionKey = new ContextControllerKeyedPartitionKeyWInit(
                    getterKey,
                    optionalInitCondAsName,
                    optionalInitCondAsName == null ? null : theEvent);
            }

            var parentPartitionKeys = keyedSvc.MgmtGetPartitionKeys(controllerPath);

            // get next subpath id
            var subpathId = keyedSvc.MgmtGetIncSubpath(controllerPath);

            // instantiate
            var result = realization.ContextPartitionInstantiate(
                controllerPath,
                subpathId,
                this,
                theEvent,
                null,
                parentPartitionKeys,
                partitionKey);
            var subpathIdOrCPId = result.SubpathOrCPId;

            // handle termination filter
            ContextControllerConditionNonHA terminationCondition = null;
            if (KeyedFactory.KeyedSpec.OptionalTermination != null) {
                var conditionPath = controllerPath.AddToEnd(subpathIdOrCPId);
                terminationCondition = ActivateTermination(
                    theEvent,
                    parentPartitionKeys,
                    partitionKey,
                    conditionPath,
                    optionalInitCondAsName);

                foreach (var agentInstance in result.AgentInstances) {
                    agentInstance.AgentInstanceContext.EpStatementAgentInstanceHandle.FilterFaultHandler =
                        ContextControllerWTerminationFilterFaultHandler.INSTANCE;
                }
            }

            keyedSvc.KeyAdd(controllerPath, getterKey, subpathIdOrCPId, terminationCondition);

            // update the filter version for this handle
            var filterVersionAfterStart = realization.AgentInstanceContextCreate.FilterService.FiltersVersion;
            realization.AgentInstanceContextCreate.EpStatementAgentInstanceHandle.StatementFilterVersion
                .StmtFilterVersion = filterVersionAfterStart;
        }
        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();
                }
            }
        }