Esempio n. 1
0
        public static ContextPartitionIdentifierInitiatedTerminated KeyToIdentifier(
            int subpathIdOrCPId,
            ContextControllerInitTermPartitionKey key,
            ContextControllerInitTerm controller)
        {
            var identifier = new ContextPartitionIdentifierInitiatedTerminated();
            identifier.StartTime = key.StartTime;
            identifier.EndTime = key.ExpectedEndTime;

            var start = controller.InitTermFactory.InitTermSpec.StartCondition;
            if (start is ContextConditionDescriptorFilter) {
                var filter = (ContextConditionDescriptorFilter) start;
                if (filter.OptionalFilterAsName != null) {
                    identifier.Properties = Collections.SingletonDataMap(
                        filter.OptionalFilterAsName,
                        key.TriggeringEvent);
                }
            }

            if (controller.Factory.FactoryEnv.IsLeaf) {
                identifier.ContextPartitionId = subpathIdOrCPId;
            }

            return identifier;
        }
Esempio n. 2
0
        public bool Filter(ContextPartitionIdentifier contextPartitionIdentifier) {
            var id = (ContextPartitionIdentifierInitiatedTerminated) contextPartitionIdentifier;
            if (_matchP00Value == null && _cpids.Contains(id.ContextPartitionId)) {
                throw new EPRuntimeException("Already exists context id: " + id.ContextPartitionId);
            }

            _cpids.Add(id.ContextPartitionId);
            _startTimes.Add(id.StartTime);
            var p00Value = (string) ((EventBean) id.Properties.Get("s0")).Get("p00");
            _p00PropertyValues.Add(p00Value);
            _lastValue = id;
            return _matchP00Value != null && _matchP00Value.Equals(p00Value);
        }
Esempio n. 3
0
        public void VisitSelectedPartitions(ContextPartitionSelector contextPartitionSelector, ContextPartitionVisitor visitor)
        {
            var nestingLevel = _factory.FactoryContext.NestingLevel;

            if (contextPartitionSelector is ContextPartitionSelectorFiltered)
            {
                var filter     = (ContextPartitionSelectorFiltered)contextPartitionSelector;
                var identifier = new ContextPartitionIdentifierInitiatedTerminated();
                foreach (var entry in EndConditions)
                {
                    identifier.EndTime            = entry.Value.EndTime;
                    identifier.StartTime          = entry.Value.StartTime;
                    identifier.Properties         = entry.Value.StartProperties;
                    identifier.ContextPartitionId = entry.Value.InstanceHandle.ContextPartitionOrPathId;
                    if (filter.Filter(identifier))
                    {
                        var state = new ContextControllerInitTermState(_factory.FactoryContext.ServicesContext.SchedulingService.Time, entry.Value.StartProperties);
                        visitor.Visit(nestingLevel, _pathId, _factory.Binding, state, this, entry.Value.InstanceHandle);
                    }
                }
                return;
            }
            if (contextPartitionSelector is ContextPartitionSelectorById)
            {
                var filter = (ContextPartitionSelectorById)contextPartitionSelector;
                foreach (var entry in EndConditions)
                {
                    if (filter.ContextPartitionIds.Contains(entry.Value.InstanceHandle.ContextPartitionOrPathId))
                    {
                        var state = new ContextControllerInitTermState(_factory.FactoryContext.ServicesContext.SchedulingService.Time, entry.Value.StartProperties);
                        visitor.Visit(nestingLevel, _pathId, _factory.Binding, state, this, entry.Value.InstanceHandle);
                    }
                }
                return;
            }
            if (contextPartitionSelector is ContextPartitionSelectorAll)
            {
                foreach (var entry in EndConditions)
                {
                    var state = new ContextControllerInitTermState(_factory.FactoryContext.ServicesContext.SchedulingService.Time, entry.Value.StartProperties);
                    visitor.Visit(nestingLevel, _pathId, _factory.Binding, state, this, entry.Value.InstanceHandle);
                }
                return;
            }
            throw ContextControllerSelectorUtil.GetInvalidSelector(new Type[0], contextPartitionSelector);
        }