/// <summary> /// Remove a filter callback from the given index node. /// </summary> /// <param name="filterCallback">is the callback to remove</param> /// <param name="filterServiceEntry">The filter service entry.</param> public void Remove(FilterHandle filterCallback, FilterServiceEntry filterServiceEntry) { EventTypeIndexBuilderValueIndexesPair pair; if (_isolatableCallbacks != null) { using (_callbacksLock.Acquire()) { pair = _isolatableCallbacks.Delete(filterCallback); } if (pair == null) { return; } } else { pair = (EventTypeIndexBuilderValueIndexesPair)filterServiceEntry; } using (Instrument.With( i => i.QFilterRemove(filterCallback, pair), i => i.AFilterRemove())) { var eventType = pair.FilterValueSet.EventType; var rootNode = _eventTypeIndex.Get(eventType); // GetInstance remove from tree if (rootNode != null) { pair.IndexPairs.ForEach( indexPair => IndexTreeBuilder.Remove(eventType, filterCallback, indexPair, rootNode)); } } }
public override void Remove(FilterHandle callback, FilterServiceEntry filterServiceEntry) { using (_iLock.AcquireWriteLock()) { base.RemoveInternal(callback, filterServiceEntry); } }
public void Activate(EventBean optionalTriggeringEvent, MatchedEventMap priorMatches, long timeOffset, bool isRecoveringResilient) { FilterHandleCallback filterCallback = new ProxyFilterHandleCallback { ProcStatementId = () => _agentInstanceContext.StatementContext.StatementId, ProcIsSubselect = () => false, ProcMatchFound = (theEvent, allStmtMatches) => FilterMatchFound(theEvent) }; // determine addendum, if any FilterValueSetParam[][] addendum = null; if (_filterAddendum != null) { addendum = _filterAddendum.GetFilterAddendum(_endpointFilterSpec.FilterSpecCompiled); } _filterHandle = new EPStatementHandleCallback(_agentInstanceContext.EpStatementAgentInstanceHandle, filterCallback); FilterValueSet filterValueSet = _endpointFilterSpec.FilterSpecCompiled.GetValueSet(null, _agentInstanceContext, addendum); _filterServiceEntry = _servicesContext.FilterService.Add(filterValueSet, _filterHandle); if (optionalTriggeringEvent != null) { bool match = StatementAgentInstanceUtil.EvaluateFilterForStatement(_servicesContext, optionalTriggeringEvent, _agentInstanceContext, _filterHandle); if (match) { FilterMatchFound(optionalTriggeringEvent); } } }
public void Open(DataFlowOpOpenContext openContext) { FilterValueSet valueSet; try { IList <ExprNode> filters = new ExprNode[0]; if (filter != null) { filters = new ExprNode[] { filter }; } var spec = FilterSpecCompiler.MakeFilterSpec( _eventType, _eventType.Name, filters, null, null, null, new StreamTypeServiceImpl( _eventType, _eventType.Name, true, _agentInstanceContext.EngineURI), null, _agentInstanceContext.StatementContext, new List <int>()); valueSet = spec.GetValueSet(null, _agentInstanceContext, null); } catch (ExprValidationException ex) { throw new EPException("Failed to open filter: " + ex.Message, ex); } var handle = new EPStatementAgentInstanceHandle(_agentInstanceContext.StatementContext.EpStatementHandle, _agentInstanceContext.AgentInstanceLock, 0, new StatementAgentInstanceFilterVersion()); _callbackHandle = new EPStatementHandleCallback(handle, this); _filterServiceEntry = _agentInstanceContext.StatementContext.FilterService.Add(valueSet, _callbackHandle); }
public void Deactivate() { if (_filterHandle != null) { _servicesContext.FilterService.Remove(_filterHandle, _filterServiceEntry); _filterHandle = null; _filterServiceEntry = null; long filtersVersion = _agentInstanceContext.StatementContext.FilterService.FiltersVersion; _agentInstanceContext.EpStatementAgentInstanceHandle.StatementFilterVersion.StmtFilterVersion = filtersVersion; } }
public void Close(DataFlowOpCloseContext openContext) { using (_iLock.Acquire()) { if (callbackHandle != null) { agentInstanceContext.StatementContext.FilterService.Remove(callbackHandle, filterServiceEntry); callbackHandle = null; filterServiceEntry = null; } } }
protected void StartFiltering() { FilterService filterService = _evalFilterNode.Context.PatternContext.FilterService; Handle = new EPStatementHandleCallback(_evalFilterNode.Context.AgentInstanceContext.EpStatementAgentInstanceHandle, this); FilterValueSet filterValues = _evalFilterNode.FactoryNode.FilterSpec.GetValueSet(BeginState, _evalFilterNode.Context.AgentInstanceContext, _evalFilterNode.AddendumFilters); FilterServiceEntry = filterService.Add(filterValues, Handle); long filtersVersion = filterService.FiltersVersion; _evalFilterNode.Context.AgentInstanceContext.EpStatementAgentInstanceHandle.StatementFilterVersion.StmtFilterVersion = filtersVersion; }
private void StopFiltering() { PatternContext context = _evalFilterNode.Context.PatternContext; if (Handle != null) { context.FilterService.Remove(Handle, FilterServiceEntry); } Handle = null; FilterServiceEntry = null; IsStarted = false; long filtersVersion = context.FilterService.FiltersVersion; _evalFilterNode.Context.AgentInstanceContext.EpStatementAgentInstanceHandle.StatementFilterVersion.StmtFilterVersion = filtersVersion; }
public void TestActiveCallbackRemove() { var spec = SupportFilterSpecBuilder.Build(_eventTypeOne, new Object[0]).GetValueSet(null, null, null); var callbackTwo = new SupportFilterHandle(); // callback that removes another matching filter spec callback Atomic <FilterServiceEntry> filterServiceEntryOne = new Atomic <FilterServiceEntry>(); FilterHandleCallback callbackOne = new ProxyFilterHandleCallback { ProcStatementId = () => "", ProcIsSubselect = () => false, ProcMatchFound = (e, allStmtMatches) => { Log.Debug(".matchFound Removing callbackTwo"); _filterService.Remove(callbackTwo, filterServiceEntryOne.Value); } }; FilterServiceEntry filterServiceEntry = _filterService.Add(spec, callbackOne); filterServiceEntryOne.Set(filterServiceEntry); _filterService.Add(spec, callbackTwo); // send event var theEvent = MakeTypeOneEvent(1, "HELLO", false, 1); var matches = new List <FilterHandle>(); _filterService.Evaluate(theEvent, matches); foreach (FilterHandle match in matches) { var handle = (FilterHandleCallback)match; handle.MatchFound(theEvent, null); } // Callback two MUST be invoked, was removed by callback one, but since the // callback invocation order should not matter, the second one MUST also execute Assert.AreEqual(1, callbackTwo.GetAndResetCountInvoked()); }
public ContextControllerHashedFilterCallback( EPServicesContext servicesContext, AgentInstanceContext agentInstanceContextCreateContext, ContextDetailHashItem hashItem, ContextControllerHashedInstanceCallback callback, ContextInternalFilterAddendum filterAddendum) { _agentInstanceContextCreateContext = agentInstanceContextCreateContext; _callback = callback; _getter = hashItem.Lookupable.Getter; _filterHandle = new EPStatementHandleCallback(agentInstanceContextCreateContext.EpStatementAgentInstanceHandle, this); FilterValueSetParam[][] addendum = filterAddendum != null?filterAddendum.GetFilterAddendum(hashItem.FilterSpecCompiled) : null; FilterValueSet filterValueSet = hashItem.FilterSpecCompiled.GetValueSet(null, null, addendum); _filterServiceEntry = servicesContext.FilterService.Add(filterValueSet, _filterHandle); long filtersVersion = servicesContext.FilterService.FiltersVersion; agentInstanceContextCreateContext.EpStatementAgentInstanceHandle.StatementFilterVersion.StmtFilterVersion = filtersVersion; }
public ContextControllerPartitionedFilterCallback(EPServicesContext servicesContext, AgentInstanceContext agentInstanceContextCreateContext, ContextDetailPartitionItem partitionItem, ContextControllerPartitionedInstanceCreateCallback callback, ContextInternalFilterAddendum filterAddendum) { _agentInstanceContextCreateContext = agentInstanceContextCreateContext; _callback = callback; _filterHandle = new EPStatementHandleCallback(agentInstanceContextCreateContext.EpStatementAgentInstanceHandle, this); _getters = new EventPropertyGetter[partitionItem.PropertyNames.Count]; for (int i = 0; i < partitionItem.PropertyNames.Count; i++) { var propertyName = partitionItem.PropertyNames[i]; var getter = partitionItem.FilterSpecCompiled.FilterForEventType.GetGetter(propertyName); _getters[i] = getter; } var addendum = filterAddendum != null?filterAddendum.GetFilterAddendum(partitionItem.FilterSpecCompiled) : null; var filterValueSet = partitionItem.FilterSpecCompiled.GetValueSet(null, null, addendum); _filterServiceEntry = servicesContext.FilterService.Add(filterValueSet, _filterHandle); var filtersVersion = servicesContext.FilterService.FiltersVersion; agentInstanceContextCreateContext.EpStatementAgentInstanceHandle.StatementFilterVersion.StmtFilterVersion = filtersVersion; }
public void Remove(FilterHandle callback, FilterServiceEntry filterServiceEntry) { _removed.Add(callback); }
protected void RemoveInternal(FilterHandle filterCallback, FilterServiceEntry filterServiceEntry) { _indexBuilder.Remove(filterCallback, filterServiceEntry); _filtersVersion++; }
public abstract void Remove(FilterHandle callback, FilterServiceEntry filterServiceEntry);
public ViewableActivatorFilterProxyStopCallback(ViewableActivatorFilterProxy parent, EPStatementHandleCallback filterHandle, FilterServiceEntry filterServiceEntry) { _parent = parent; _filterHandle = filterHandle; _filterServiceEntry = filterServiceEntry; }
public override void Remove(FilterHandle callback, FilterServiceEntry filterServiceEntry) { base.RemoveInternal(callback, filterServiceEntry); }