public override FilterValueSetParam[][] PopulateFilterAddendum( FilterSpecActivatable filterSpec, bool forStatement, int nestingLevel, object partitionKey, ContextControllerStatementDesc optionalStatementDesc, IDictionary<int, ContextControllerStatementDesc> statements, AgentInstanceContext agentInstanceContextStatement) { if (!forStatement) { if (!EventTypeUtility.IsTypeOrSubTypeOf( filterSpec.FilterForEventType, CategorySpec.FilterSpecActivatable.FilterForEventType)) { return null; } } var categoryNum = partitionKey.AsInt32(); var item = CategorySpec.Items[categoryNum]; FilterValueSetParam[][] filters = item.FilterPlan.EvaluateValueSet( null, agentInstanceContextStatement, agentInstanceContextStatement.StatementContextFilterEvalEnv); if (filters == null) { throw new EPException( "Category context '" + ContextName + "' for category '" + item.Name + "' has evaluated to a condition that cannot become true"); } return filters; }
public void Transfer( FilterSpecActivatable activatable, AgentInstanceTransferServices xfer) { xfer.AgentInstanceContext.FilterService.Remove(filterHandle, activatable.FilterForEventType, filterValueSet); xfer.TargetFilterService.Add(activatable.FilterForEventType, filterValueSet, filterHandle); }
public abstract FilterValueSetParam[][] PopulateFilterAddendum( FilterSpecActivatable filterSpec, bool forStatement, int nestingLevel, object partitionKey, ContextControllerStatementDesc optionalStatementDesc, AgentInstanceContext agentInstanceContextStatement);
private static FilterValueSetParam[][] ComputeAddendum( object[] parentPartitionKeys, FilterSpecActivatable filterCallback, bool forStatement, ContextControllerStatementDesc optionalStatementDesc, ContextControllerFactory[] controllerFactories, IDictionary<int, ContextControllerStatementDesc> statements, AgentInstanceContext agentInstanceContextCreate) { var result = new FilterValueSetParam[0][]; for (var i = 0; i < parentPartitionKeys.Length; i++) { var addendumForController = controllerFactories[i] .PopulateFilterAddendum( filterCallback, forStatement, i + 1, parentPartitionKeys[i], optionalStatementDesc, statements, agentInstanceContextCreate); result = FilterAddendumUtil.MultiplyAddendum(result, addendumForController); } return result; }
public ViewableActivatorFilterMgmtCallback( IContainer container, FilterHandle filterHandle, FilterSpecActivatable filterSpecActivatable) { _lock = container.LockManager().CreateLock(GetType()); _filterHandle = filterHandle; _filterSpecActivatable = filterSpecActivatable; }
public FilterValueSetParam[][] GetAddendumFilters( FilterSpecActivatable filterSpec, AgentInstanceContext agentInstanceContext) { if (addendumMap == null) { addendumMap = generator.Invoke(agentInstanceContext); } return addendumMap.Get(filterSpec); }
public static FilterValueSetParam[][] ComputeAddendumNonStmt( object[] partitionKeys, FilterSpecActivatable filterCallback, ContextManagerRealization realization) { return ComputeAddendum( partitionKeys, filterCallback, false, null, realization.ContextManager.ContextDefinition.ControllerFactories, realization.AgentInstanceContextCreate); }
protected void Stop(FilterSpecActivatable activatable) { if (filterHandle == null) { return; } var agentInstanceContext = callback.AgentInstanceContextCreate; agentInstanceContext.FilterService.Remove(filterHandle, activatable.FilterForEventType, filterValueSet); var filtersVersion = agentInstanceContext.FilterService.FiltersVersion; agentInstanceContext.EpStatementAgentInstanceHandle.StatementFilterVersion.StmtFilterVersion = filtersVersion; filterHandle = null; filterValueSet = null; }
public ZeroDepthStreamIterableWAudit( EventType eventType, AgentInstanceContext agentInstanceContext, FilterSpecActivatable filterSpec, int streamNumber, bool subselect, int subselectNumber) : base(eventType) { _agentInstanceContext = agentInstanceContext; _filterSpecText = filterSpec.GetFilterText(); _streamNumber = streamNumber; _subselect = subselect; _subselectNumber = subselectNumber; }
public FilterValueSetParam[][] GetAddendumFilters( FilterSpecActivatable filterSpec, AgentInstanceContext agentInstanceContext) { if (_addendumMap == null) { _addendumMap = _generator.Invoke(); if (_addendumMap.IsEmpty()) { _addendumMap = EmptyDictionary<FilterSpecActivatable, FilterValueSetParam[][]>.Instance; } _generator = null; } return _addendumMap.Get(filterSpec); }
public override FilterValueSetParam[][] PopulateFilterAddendum( FilterSpecActivatable filterSpec, bool forStatement, int nestingLevel, object partitionKey, ContextControllerStatementDesc optionalStatementDesc, AgentInstanceContext agentInstanceContextStatement) { if (!forStatement) { if (!EventTypeUtility.IsTypeOrSubTypeOf( filterSpec.FilterForEventType, CategorySpec.FilterSpecActivatable.FilterForEventType)) { return null; } } int categoryNum = partitionKey.AsInt32(); ContextControllerDetailCategoryItem item = CategorySpec.Items[categoryNum]; return FilterSpecActivatable.EvaluateValueSet( item.CompiledFilterParam, null, agentInstanceContextStatement); }
protected void Start(FilterSpecActivatable activatable) { if (filterHandle != null) { throw new IllegalStateException("Already started"); } var agentInstanceContext = callback.AgentInstanceContextCreate; filterHandle = new EPStatementHandleCallbackFilter( agentInstanceContext.EpStatementAgentInstanceHandle, this); var addendum = ContextManagerUtil.ComputeAddendumNonStmt( parentPartitionKeys, activatable, callback.Realization); filterValueSet = activatable.GetValueSet( null, addendum, agentInstanceContext, agentInstanceContext.StatementContextFilterEvalEnv); agentInstanceContext.FilterService.Add(activatable.FilterForEventType, filterValueSet, filterHandle); var filtersVersion = agentInstanceContext.FilterService.FiltersVersion; agentInstanceContext.EpStatementAgentInstanceHandle.StatementFilterVersion.StmtFilterVersion = filtersVersion; }
public void Run() { long currentThreadId = Thread.CurrentThread.ManagedThreadId; // Choose one of filter specifications, randomly, then reserve to make sure no one else has the same FilterSpecActivatable filterSpec = null; EventBean unmatchedEvent = null; EventBean matchedEvent = null; var index = 0; do { index = random.Next(testFilterSpecs.Count); filterSpec = testFilterSpecs[index]; unmatchedEvent = unmatchedEvents[index]; matchedEvent = matchedEvents[index]; } while (!ObjectReservationSingleton.GetInstance().Reserve(filterSpec)); // Add expression var filterValues = filterSpec.GetValueSet(null, null, null, null); FilterHandle filterCallback = new SupportFilterHandle(); IndexTreeBuilderAdd.Add(filterValues, filterCallback, topNode, lockFactory); // Fire a no-match IList <FilterHandle> matches = new List <FilterHandle>(); topNode.MatchEvent(unmatchedEvent, matches, null); if (matches.Count != 0) { log.Error( ".Run (" + currentThreadId + ") Got a match but expected no-match, matchCount=" + matches.Count + " bean=" + unmatchedEvent + " match=" + matches[0].GetHashCode()); Assert.IsFalse(true); } // Fire a match topNode.MatchEvent(matchedEvent, matches, null); if (matches.Count != 1) { log.Error( ".Run (" + currentThreadId + ") Got zero or two or more match but expected a match, count=" + matches.Count + " bean=" + matchedEvent); Assert.IsFalse(true); } // Remove the same expression again IndexTreeBuilderRemove.Remove(eventType, filterCallback, filterValues[0], topNode); log.Debug(".Run (" + Thread.CurrentThread.ManagedThreadId + ")" + " Completed"); ObjectReservationSingleton.GetInstance().Unreserve(filterSpec); }
public static FilterValueSetParam[][] GetAddendumFilters( object getterKey, FilterSpecActivatable filtersSpec, ContextControllerDetailKeyed keyedSpec, bool includePartition, ContextControllerStatementDesc optionalStatementDesc, AgentInstanceContext agentInstanceContext) { // determine whether create-named-window var isCreateWindow = optionalStatementDesc != null && optionalStatementDesc.Lightweight.StatementContext.StatementInformationals .StatementType == StatementType.CREATE_WINDOW; ContextControllerDetailKeyedItem foundPartition = null; if (!isCreateWindow) { foreach (var partitionItem in keyedSpec.Items) { var typeOrSubtype = EventTypeUtility.IsTypeOrSubTypeOf( filtersSpec.FilterForEventType, partitionItem.FilterSpecActivatable.FilterForEventType); if (typeOrSubtype) { foundPartition = partitionItem; break; } } } else { var factory = (StatementAgentInstanceFactoryCreateNW) optionalStatementDesc.Lightweight.StatementContext .StatementAIFactoryProvider .Factory; var declaredAsName = factory.AsEventTypeName; foreach (var partitionItem in keyedSpec.Items) { if (partitionItem.FilterSpecActivatable.FilterForEventType.Name.Equals(declaredAsName)) { foundPartition = partitionItem; break; } } } if (foundPartition == null) { return null; } var lookupables = foundPartition.Lookupables; var addendumFilters = new FilterValueSetParam[lookupables.Length]; if (lookupables.Length == 1) { addendumFilters[0] = GetFilterMayEqualOrNull(lookupables[0], getterKey); } else { var keys = getterKey is HashableMultiKey ? ((HashableMultiKey) getterKey).Keys : (object[]) getterKey; for (var i = 0; i < lookupables.Length; i++) { addendumFilters[i] = GetFilterMayEqualOrNull(lookupables[i], keys[i]); } } var addendum = new FilterValueSetParam[1][]; addendum[0] = addendumFilters; var partitionFilters = foundPartition.FilterSpecActivatable.GetValueSet( null, null, agentInstanceContext, agentInstanceContext.StatementContextFilterEvalEnv); if (partitionFilters != null && includePartition) { addendum = FilterAddendumUtil.AddAddendum(partitionFilters, addendum[0]); } return addendum; }
public FilterValueSetParam[][] GetFilterAddendumForContextPath(FilterSpecActivatable filterSpec) { return contextAddendumFunction == null ? null : contextAddendumFunction.Invoke(filterSpec); }