public ContextControllerFactory Make(ContextControllerFactoryContext factoryContext, ContextDetail detail, IList <FilterSpecCompiled> optFiltersNested, ContextStateCache contextStateCache)
        {
            ContextControllerFactory factory;

            if (detail is ContextDetailInitiatedTerminated)
            {
                factory = new ContextControllerInitTermFactory(factoryContext, (ContextDetailInitiatedTerminated)detail, contextStateCache);
            }
            else if (detail is ContextDetailPartitioned)
            {
                factory = new ContextControllerPartitionedFactory(factoryContext, (ContextDetailPartitioned)detail, optFiltersNested, contextStateCache);
            }
            else if (detail is ContextDetailCategory)
            {
                factory = new ContextControllerCategoryFactory(factoryContext, (ContextDetailCategory)detail, optFiltersNested, contextStateCache);
            }
            else if (detail is ContextDetailHash)
            {
                factory = new ContextControllerHashFactory(factoryContext, (ContextDetailHash)detail, optFiltersNested, contextStateCache);
            }
            else
            {
                throw new UnsupportedOperationException("Context detail " + detail + " is not yet supported in a nested context");
            }

            return(factory);
        }
Example #2
0
 private static ContextControllerFactory BuildContextFactory(ContextControllerFactoryContext factoryContext,
                                                             ContextDetail detail,
                                                             IList <FilterSpecCompiled> optFiltersNested,
                                                             ContextStateCache contextStateCache)
 {
     return(factoryContext.ServicesContext.ContextControllerFactoryFactorySvc.Make(factoryContext, detail, optFiltersNested, contextStateCache));
 }
Example #3
0
        public void Create(int id, EventBean theEvent)
        {
            lock (this)
            {
                ContextControllerFactoryContext factoryContext = _factory.FactoryContext;
                if (_partitionKeys.ContainsKey(id))
                {
                    return;
                }

                IDictionary <String, Object> properties = ContextPropertyEventType.GetHashBean(factoryContext.ContextName, id);
                _currentSubpathId++;

                // merge filter addendum, if any
                ContextInternalFilterAddendum filterAddendumToUse = _activationFilterAddendum;
                if (_factory.HasFiltersSpecsNestedContexts)
                {
                    filterAddendumToUse = _activationFilterAddendum != null?_activationFilterAddendum.DeepCopy() : new ContextInternalFilterAddendum();

                    _factory.PopulateContextInternalFilterAddendums(filterAddendumToUse, id);
                }

                ContextControllerInstanceHandle handle = _activationCallback.ContextPartitionInstantiate(null, _currentSubpathId, null, this, theEvent, null, id, properties, null, filterAddendumToUse, _factory.FactoryContext.IsRecoveringResilient, ContextPartitionState.STARTED);
                _partitionKeys.Put(id, handle);
                _factory.FactoryContext.StateCache.AddContextPath(factoryContext.OutermostContextName, factoryContext.NestingLevel, _pathId, _currentSubpathId, handle.ContextPartitionOrPathId, id, _factory.Binding);

                // update the filter version for this handle
                long filterVersion = factoryContext.ServicesContext.FilterService.FiltersVersion;
                _factory.FactoryContext.AgentInstanceContextCreate.EpStatementAgentInstanceHandle.StatementFilterVersion.StmtFilterVersion = filterVersion;
            }
        }
Example #4
0
 public ContextControllerInitTermFactory(ContextControllerFactoryContext factoryContext, ContextDetailInitiatedTerminated detail, ContextStateCache stateCache)
     : base(factoryContext)
 {
     _detail     = detail;
     _stateCache = stateCache;
     _binding    = stateCache.GetBinding(detail);
 }
 public ContextControllerCategoryFactoryImpl(
     ContextControllerFactoryContext factoryContext,
     ContextDetailCategory categorySpec,
     IList <FilterSpecCompiled> filtersSpecsNestedContexts)
     : base(factoryContext, categorySpec, filtersSpecsNestedContexts)
 {
     _binding = factoryContext.StateCache.GetBinding(typeof(int));        // the integer ordinal of the category
 }
Example #6
0
 public ContextControllerHashFactory(ContextControllerFactoryContext factoryContext, ContextDetailHash hashedSpec, IList <FilterSpecCompiled> filtersSpecsNestedContexts, ContextStateCache stateCache)
     : base(factoryContext)
 {
     _hashedSpec = hashedSpec;
     _filtersSpecsNestedContexts = filtersSpecsNestedContexts;
     _stateCache = stateCache;
     _binding    = stateCache.GetBinding(typeof(int));
 }
Example #7
0
 public ContextControllerHashFactoryImpl(
     ContextControllerFactoryContext factoryContext,
     ContextDetailHash hashedSpec,
     IList<FilterSpecCompiled> filtersSpecsNestedContexts)
     : base(factoryContext, hashedSpec, filtersSpecsNestedContexts)
 {
     _binding = factoryContext.StateCache.GetBinding(typeof(int));
 }
 public ContextControllerCategoryFactory(ContextControllerFactoryContext factoryContext, ContextDetailCategory categorySpec, IList <FilterSpecCompiled> filtersSpecsNestedContexts, ContextStateCache stateCache)
     : base(factoryContext)
 {
     _categorySpec = categorySpec;
     _filtersSpecsNestedContexts = filtersSpecsNestedContexts;
     _stateCache = stateCache;
     _binding    = stateCache.GetBinding(typeof(int)); // the integer ordinal of the category
 }
Example #9
0
        public void Activate(EventBean optionalTriggeringEvent, IDictionary <String, Object> optionalTriggeringPattern, ContextControllerState controllerState, ContextInternalFilterAddendum activationFilterAddendum, int?importPathId)
        {
            ContextControllerFactoryContext factoryContext = _factory.FactoryContext;

            _activationFilterAddendum = activationFilterAddendum;

            if (factoryContext.NestingLevel == 1)
            {
                controllerState = ContextControllerStateUtil.GetRecoveryStates(_factory.FactoryContext.StateCache, factoryContext.OutermostContextName);
            }
            if (controllerState == null)
            {
                // handle preallocate
                if (_factory.HashedSpec.IsPreallocate)
                {
                    for (int i = 0; i < _factory.HashedSpec.Granularity; i++)
                    {
                        var properties = ContextPropertyEventType.GetHashBean(factoryContext.ContextName, i);
                        _currentSubpathId++;

                        // merge filter addendum, if any
                        var filterAddendumToUse = activationFilterAddendum;
                        if (_factory.HasFiltersSpecsNestedContexts)
                        {
                            filterAddendumToUse = activationFilterAddendum != null?activationFilterAddendum.DeepCopy() : new ContextInternalFilterAddendum();

                            _factory.PopulateContextInternalFilterAddendums(filterAddendumToUse, i);
                        }

                        ContextControllerInstanceHandle handle = _activationCallback.ContextPartitionInstantiate(null, _currentSubpathId, null, this, optionalTriggeringEvent, null, i, properties, controllerState, filterAddendumToUse, _factory.FactoryContext.IsRecoveringResilient, ContextPartitionState.STARTED);
                        _partitionKeys.Put(i, handle);

                        _factory.FactoryContext.StateCache.AddContextPath(
                            _factory.FactoryContext.OutermostContextName,
                            _factory.FactoryContext.NestingLevel,
                            _pathId, _currentSubpathId, handle.ContextPartitionOrPathId, i,
                            _factory.Binding);
                    }
                    return;
                }

                // start filters if not preallocated
                ActivateFilters(optionalTriggeringEvent);

                return;
            }

            // initialize from existing state
            int pathIdToUse = importPathId ?? _pathId;

            InitializeFromState(optionalTriggeringEvent, optionalTriggeringPattern, controllerState, pathIdToUse, null, false);

            // activate filters
            if (!_factory.HashedSpec.IsPreallocate)
            {
                ActivateFilters(null);
            }
        }
Example #10
0
 protected ContextControllerHashFactoryBase(
     ContextControllerFactoryContext factoryContext,
     ContextDetailHash hashedSpec,
     IList <FilterSpecCompiled> filtersSpecsNestedContexts)
     : base(factoryContext)
 {
     _hashedSpec = hashedSpec;
     _filtersSpecsNestedContexts = filtersSpecsNestedContexts;
 }
Example #11
0
 public ContextControllerPartitionedFactory(
     ContextControllerFactoryContext factoryContext,
     ContextDetailPartitioned segmentedSpec,
     IList <FilterSpecCompiled> filtersSpecsNestedContexts,
     ContextStateCache stateCache)
     : base(factoryContext)
 {
     _segmentedSpec = segmentedSpec;
     _filtersSpecsNestedContexts = filtersSpecsNestedContexts;
     _stateCache = stateCache;
     _binding    = stateCache.GetBinding(typeof(ContextControllerPartitionedState));
 }
Example #12
0
        private static ContextControllerFactory BuildContextFactory(
            ContextControllerFactoryServiceContext serviceContext,
            String contextName,
            ContextDetail detail,
            int nestingLevel,
            IList <FilterSpecCompiled> optFiltersNested,
            ContextStateCache contextStateCache)
        {
            var factoryContext = new ContextControllerFactoryContext(
                serviceContext.ContextName, contextName, serviceContext.ServicesContext,
                serviceContext.AgentInstanceContextCreate, nestingLevel, serviceContext.IsRecoveringResilient);

            return(BuildContextFactory(factoryContext, detail, optFiltersNested, contextStateCache));
        }
Example #13
0
 public ContextControllerInitTermFactoryImpl(ContextControllerFactoryContext factoryContext, ContextDetailInitiatedTerminated detail)
     : base(factoryContext, detail)
 {
     _binding = factoryContext.StateCache.GetBinding(detail);
 }
 public ContextControllerInitTermFactoryBase(ContextControllerFactoryContext factoryContext, ContextDetailInitiatedTerminated detail)
     : base(factoryContext)
 {
     this._detail = detail;
 }
Example #15
0
 protected ContextControllerPartitionedFactoryBase(ContextControllerFactoryContext factoryContext, ContextDetailPartitioned segmentedSpec, IList <FilterSpecCompiled> filtersSpecsNestedContexts)
     : base(factoryContext)
 {
     _segmentedSpec = segmentedSpec;
     _filtersSpecsNestedContexts = filtersSpecsNestedContexts;
 }
 public ContextControllerPartitionedFactoryImpl(ContextControllerFactoryContext factoryContext, ContextDetailPartitioned segmentedSpec, IList <FilterSpecCompiled> filtersSpecsNestedContexts)
     : base(factoryContext, segmentedSpec, filtersSpecsNestedContexts)
 {
     _binding = factoryContext.StateCache.GetBinding(typeof(ContextControllerPartitionedState));
 }
 protected ContextControllerFactoryBase(ContextControllerFactoryContext factoryContext)
 {
     _factoryContext = factoryContext;
 }
        public static IDictionary <ContextStatePathKey, ContextStatePathValue> GetChildContexts(ContextControllerFactoryContext factoryContext, int pathId, OrderedDictionary <ContextStatePathKey, ContextStatePathValue> states)
        {
            ContextStatePathKey start = new ContextStatePathKey(factoryContext.NestingLevel, pathId, int.MinValue);
            ContextStatePathKey end   = new ContextStatePathKey(factoryContext.NestingLevel, pathId, int.MaxValue);

            return(states.Between(start, true, end, true));
        }
 protected ContextControllerCategoryFactoryBase(ContextControllerFactoryContext factoryContext, ContextDetailCategory categorySpec, IList <FilterSpecCompiled> filtersSpecsNestedContexts)
     : base(factoryContext)
 {
     _categorySpec = categorySpec;
     _filtersSpecsNestedContexts = filtersSpecsNestedContexts;
 }