Пример #1
0
 protected abstract void VisitPartitions(
     IntSeqKey controllerPath,
     BiConsumer<ContextControllerInitTermPartitionKey, int> partKeyAndCPId);
 public object[] MgmtGetParentPartitionKeys(IntSeqKey controllerPath)
 {
     return EMPTY_PARENT_PARTITION_KEYS;
 }
 public bool HashHasSeenPartition(
     IntSeqKey controllerPath,
     int value)
 {
     return optionalHashes.ContainsKey(value);
 }
 public void MgmtCreate(
     IntSeqKey controllerPath,
     object[] parentPartitionKeys)
 {
     // can ignore, parent partition keys always empty
 }
 public int[] MgmtGetSubpathOrCPIdsWhenPreallocate(IntSeqKey path)
 {
     return subpathOrCPIdsPreallocate;
 }
Пример #6
0
        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);
                    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();
                }
            }
        }
Пример #7
0
 public void MgmtSetFilters(
     IntSeqKey controllerPath,
     ContextControllerFilterEntry[] filterEntries)
 {
     _mgmt.Get(controllerPath).FilterEntries = filterEntries;
 }
 public void Clear(IntSeqKey path)
 {
     distinctContexts.Clear();
 }
Пример #9
0
 public int MgmtGetIncSubpath(IntSeqKey controllerPath)
 {
     var subpathId = _currentSubpathId;
     _currentSubpathId++;
     return subpathId;
 }
 public bool AddUnlessExists(
     IntSeqKey controllerPath,
     object key)
 {
     return distinctContexts.Add(key);
 }
 public void Remove(
     IntSeqKey controllerPath,
     object key)
 {
     distinctContexts.Remove(key);
 }
Пример #12
0
 public virtual void Transfer(
     IntSeqKey path,
     bool transferChildContexts,
     AgentInstanceTransferServices xfer)
 {
 }
Пример #13
0
 public abstract void Deactivate(
     IntSeqKey path,
     bool terminateChildContexts);
Пример #14
0
 public abstract void Activate(
     IntSeqKey path,
     object[] parentPartitionKeys,
     EventBean optionalTriggeringEvent,
     IDictionary<string, object> optionalTriggeringPattern);
 public ContextControllerCondition MgmtGetStartCondition(IntSeqKey controllerPath)
 {
     return mgmt.TryGetValue(controllerPath, out var existing) ? existing.startCondition : null;
 }
Пример #16
0
 public bool KeyHasSeen(
     IntSeqKey controllerPath,
     object key)
 {
     return _keys.ContainsKey(key);
 }
 public ContextControllerInitTermSvcEntry EndDelete(IntSeqKey conditionPath)
 {
     return endConditions.Delete(conditionPath);
 }
Пример #18
0
 public ContextControllerKeyedSvcEntry KeyRemove(
     IntSeqKey controllerPath,
     object key)
 {
     return _keys.Delete(key);
 }
Пример #19
0
 public void MgmtCreate(
     IntSeqKey controllerPath,
     object[] parentPartitionKeys)
 {
     _mgmt.Put(controllerPath, new MgmtInfo(null, parentPartitionKeys));
 }
 public int[] MgmtGetSubpathOrCPIds(IntSeqKey controllerPath)
 {
     return subpathOrCPId;
 }
Пример #21
0
 public object[] MgmtGetParentPartitionKeys(IntSeqKey controllerPath)
 {
     return _mgmt.Get(controllerPath).ParentPartitionKeys;
 }
 public int[] MgmtDelete(IntSeqKey controllerPath)
 {
     var tmp = subpathOrCPId;
     subpathOrCPId = null;
     return tmp;
 }
 public void MgmtSetFilters(
     IntSeqKey controllerPath,
     ContextControllerFilterEntry[] filterEntries)
 {
     this.filterEntries = filterEntries;
 }
Пример #24
0
 protected override void VisitPartitions(
     IntSeqKey controllerPath,
     BiConsumer<ContextControllerInitTermPartitionKey, int> partKeyAndCPId)
 {
     initTermSvc.EndVisit(controllerPath, partKeyAndCPId);
 }
 public void MgmtSetSubpathOrCPIdsWhenPreallocate(
     IntSeqKey path,
     int[] subpathOrCPIds)
 {
     subpathOrCPIdsPreallocate = subpathOrCPIds;
 }
 public object[] MgmtGetParentPartitionKeys(IntSeqKey controllerPath)
 {
     var entry = mgmt.Get(controllerPath);
     return entry == null ? null : entry.parentPartitionKeys;
 }
 public ContextControllerFilterEntry[] MgmtGetFilters(IntSeqKey controllerPath)
 {
     return filterEntries;
 }
 public ContextControllerConditionNonHA MgmtDelete(IntSeqKey controllerPath)
 {
     var existing = mgmt.Delete(controllerPath);
     return existing == null ? null : existing.startCondition;
 }
Пример #29
0
        public override void VisitSelectedPartitions(
            IntSeqKey path,
            ContextPartitionSelector contextPartitionSelector,
            ContextPartitionVisitor visitor,
            ContextPartitionSelector[] selectorPerLevel)
        {
            if (contextPartitionSelector is ContextPartitionSelectorCategory) {
                var category = (ContextPartitionSelectorCategory) contextPartitionSelector;
                if (category.Labels == null || category.Labels.IsEmpty()) {
                    return;
                }

                var ids = categorySvc.MgmtGetSubpathOrCPIds(path);
                if (ids != null) {
                    var count = -1;
                    foreach (ContextControllerDetailCategoryItem categoryItem in factory.CategorySpec.Items) {
                        count++;
                        var subpathOrCPID = ids[count];
                        if (category.Labels.Contains(categoryItem.Name)) {
                            realization.ContextPartitionRecursiveVisit(
                                path,
                                subpathOrCPID,
                                this,
                                visitor,
                                selectorPerLevel);
                        }
                    }
                }

                return;
            }

            if (contextPartitionSelector is ContextPartitionSelectorFiltered) {
                var filter = (ContextPartitionSelectorFiltered) contextPartitionSelector;
                var ids = categorySvc.MgmtGetSubpathOrCPIds(path);
                if (ids != null) {
                    var count = -1;
                    foreach (ContextControllerDetailCategoryItem categoryItem in factory.CategorySpec.Items) {
                        var identifierCategory = new ContextPartitionIdentifierCategory(categoryItem.Name);
                        count++;
                        if (factory.FactoryEnv.IsLeaf) {
                            identifierCategory.ContextPartitionId = ids[count];
                        }

                        if (filter.Filter(identifierCategory)) {
                            realization.ContextPartitionRecursiveVisit(
                                path,
                                ids[count],
                                this,
                                visitor,
                                selectorPerLevel);
                        }
                    }
                }

                return;
            }

            if (contextPartitionSelector is ContextPartitionSelectorAll) {
                var ids = categorySvc.MgmtGetSubpathOrCPIds(path);
                if (ids != null) {
                    foreach (var id in ids) {
                        realization.ContextPartitionRecursiveVisit(path, id, this, visitor, selectorPerLevel);
                    }
                }

                return;
            }

            if (contextPartitionSelector is ContextPartitionSelectorById) {
                var byId = (ContextPartitionSelectorById) contextPartitionSelector;
                var ids = categorySvc.MgmtGetSubpathOrCPIds(path);
                foreach (var id in ids) {
                    if (byId.ContextPartitionIds.Contains(id)) {
                        realization.ContextPartitionRecursiveVisit(path, id, this, visitor, selectorPerLevel);
                    }
                }
            }

            throw ContextControllerSelectorUtil.GetInvalidSelector(
                new[] {typeof(ContextPartitionSelectorCategory)},
                contextPartitionSelector);
        }
Пример #30
0
 protected override int GetSubpathOrCPId(
     IntSeqKey path,
     int hash)
 {
     return hashSvc.HashGetSubpathOrCPId(path, hash);
 }