public override void Add( EventType eventType, FilterValueSetParam[][] valueSet, FilterHandle callback) { AddInternal(eventType, valueSet, callback); }
private static FilterHandle Init(FilterHandle childFilter) { FilterHandle result; Log4JParserC.Log4JFilterInitNot (out result, childFilter); return result; }
/// <summary> /// Add a filter callback according to the filter specification to the top node returning /// information to be used to remove the filter callback. /// </summary> /// <param name="valueSet">is the filter definition</param> /// <param name="filterCallback">is the callback to be added</param> /// <param name="topNode">node to be added to any subnode beneath it</param> /// <param name="lockFactory">lock factory</param> public static void Add( FilterValueSetParam[][] valueSet, FilterHandle filterCallback, FilterHandleSetNode topNode, FilterServiceGranularLockFactory lockFactory) { if (ExecutionPathDebugLog.IsDebugEnabled && log.IsDebugEnabled) { log.Debug( ".add (" + Thread.CurrentThread.ManagedThreadId + ") Adding filter callback, " + " topNode=" + topNode + " filterCallback=" + filterCallback); } if (valueSet.Length == 0) { AddToNode(new ArrayDeque<FilterValueSetParam>(1), filterCallback, topNode, lockFactory); } else { var remainingParameters = new ArrayDeque<FilterValueSetParam>(); for (var i = 0; i < valueSet.Length; i++) { remainingParameters.Clear(); remainingParameters.AddAll(valueSet[i]); AddToNode(remainingParameters, filterCallback, topNode, lockFactory); } } }
/// <summary> /// Add a filter callback according to the filter specification to the top node returning information to be used to remove the filter callback. /// </summary> /// <param name="filterValueSet">is the filter definition</param> /// <param name="filterCallback">is the callback to be added</param> /// <param name="topNode">node to be added to any subnode beneath it</param> /// <param name="lockFactory">The lock factory.</param> /// <returns> /// an encapsulation of information need to allow for safe removal of the filter tree. /// </returns> public static ArrayDeque <EventTypeIndexBuilderIndexLookupablePair>[] Add( FilterValueSet filterValueSet, FilterHandle filterCallback, FilterHandleSetNode topNode, FilterServiceGranularLockFactory lockFactory) { if ((ExecutionPathDebugLog.IsEnabled) && (Log.IsDebugEnabled)) { Log.Debug(".add (" + Thread.CurrentThread.ManagedThreadId + ") Adding filter callback, " + " topNode=" + topNode + " filterCallback=" + filterCallback); } ArrayDeque <EventTypeIndexBuilderIndexLookupablePair>[] treePathInfo; if (filterValueSet.Parameters.Length == 0) { treePathInfo = AllocateTreePath(1); treePathInfo[0] = new ArrayDeque <EventTypeIndexBuilderIndexLookupablePair>(1); AddToNode(new ArrayDeque <FilterValueSetParam>(1), filterCallback, topNode, treePathInfo[0], lockFactory); } else { treePathInfo = AllocateTreePath(filterValueSet.Parameters.Length); var remainingParameters = new ArrayDeque <FilterValueSetParam>(4); for (int i = 0; i < filterValueSet.Parameters.Length; i++) { treePathInfo[i] = new ArrayDeque <EventTypeIndexBuilderIndexLookupablePair>(filterValueSet.Parameters[i].Length); remainingParameters.Clear(); remainingParameters.AddAll(filterValueSet.Parameters[i]); AddToNode(remainingParameters, filterCallback, topNode, treePathInfo[i], lockFactory); } } return(treePathInfo); }
/// <summary> /// Add a filter callback. The filter callback set allows adding the same callback twice with no effect. /// If a client to the class needs to check that the callback already existed, the contains method does that. /// NOTE: the client to this method must use the read-write lock of this object to lock, if required /// by the client code. /// </summary> /// <param name="filterCallback">is the callback to add</param> public void Add(FilterHandle filterCallback) { _callbackSet.Add(filterCallback); #if DEBUG && DIAGNOSTICS System.Diagnostics.Debug.WriteLine("{0}: Add: {1} / {2} / {3}", System.Threading.Thread.CurrentThread.ManagedThreadId, _id, _callbackSet.Count, System.Threading.Thread.CurrentThread.ManagedThreadId); #endif }
protected FilterServiceEntry AddInternal(FilterValueSet filterValueSet, FilterHandle filterCallback) { var entry = _indexBuilder.Add(filterValueSet, filterCallback, _lockFactory); _filtersVersion++; return(entry); }
/// <summary> /// Add filter callback to an event evaluator, which could be either an index node or a set node. /// </summary> /// <param name="remainingParameters">The remaining parameters.</param> /// <param name="filterCallback">The filter callback.</param> /// <param name="eventEvaluator">to add the filterCallback to.</param> /// <param name="treePathInfo">is for holding the information on where the add occured</param> /// <param name="lockFactory">The lock factory.</param> /// <returns> /// bool indicating if the eventEvaluator was successfully added /// </returns> private static bool AddToEvaluator( ArrayDeque <FilterValueSetParam> remainingParameters, FilterHandle filterCallback, EventEvaluator eventEvaluator, ArrayDeque <EventTypeIndexBuilderIndexLookupablePair> treePathInfo, FilterServiceGranularLockFactory lockFactory) { if (eventEvaluator is FilterHandleSetNode) { var node = (FilterHandleSetNode)eventEvaluator; AddToNode(remainingParameters, filterCallback, node, treePathInfo, lockFactory); return(true); } // Check if the next index matches any of the remaining filterCallback parameters var nextIndex = (FilterParamIndexBase)eventEvaluator; var parameter = IndexHelper.FindParameter(remainingParameters, nextIndex); if (parameter != null) { remainingParameters.Remove(parameter); treePathInfo.Add(new EventTypeIndexBuilderIndexLookupablePair(nextIndex, parameter.FilterForValue)); AddToIndex(remainingParameters, filterCallback, nextIndex, parameter.FilterForValue, treePathInfo, lockFactory); return(true); } // This eventEvaluator does not work with any of the remaining filter parameters return(false); }
public override FilterServiceEntry Add(FilterValueSet filterValueSet, FilterHandle callback) { using (_iLock.AcquireWriteLock()) { return(base.AddInternal(filterValueSet, callback)); } }
/// <summary> /// Add filter callback to an event evaluator, which could be either an index node or a set node. /// </summary> /// <param name="remainingParameters">The remaining parameters.</param> /// <param name="filterCallback">The filter callback.</param> /// <param name="eventEvaluator">to add the filterCallback to.</param> /// <param name="treePathInfo">is for holding the information on where the add occured</param> /// <param name="lockFactory">The lock factory.</param> /// <returns> /// bool indicating if the eventEvaluator was successfully added /// </returns> private static bool AddToEvaluator( ArrayDeque <FilterValueSetParam> remainingParameters, FilterHandle filterCallback, EventEvaluator eventEvaluator, ArrayDeque <EventTypeIndexBuilderIndexLookupablePair> treePathInfo, FilterServiceGranularLockFactory lockFactory) { if (eventEvaluator is FilterHandleSetNode) { var node = (FilterHandleSetNode)eventEvaluator; #if DEBUG && DIAGNOSTICS System.Diagnostics.Debug.WriteLine("{0}: AddToEvaluator: {1}", Thread.CurrentThread.ManagedThreadId, node); #endif AddToNode(remainingParameters, filterCallback, node, treePathInfo, lockFactory); return(true); } // Check if the next index matches any of the remaining filterCallback parameters var nextIndex = (FilterParamIndexBase)eventEvaluator; var parameter = IndexHelper.FindParameter(remainingParameters, nextIndex); if (parameter != null) { remainingParameters.Remove(parameter); treePathInfo.Add(new EventTypeIndexBuilderIndexLookupablePair(nextIndex, parameter.FilterForValue)); #if DEBUG && DIAGNOSTICS System.Diagnostics.Debug.WriteLine("{0}: AddToEvaluator -> AddToIndex: {1}", Thread.CurrentThread.ManagedThreadId, nextIndex); #endif AddToIndex(remainingParameters, filterCallback, nextIndex, parameter.FilterForValue, treePathInfo, lockFactory); return(true); } // This eventEvaluator does not work with any of the remaining filter parameters return(false); }
public override void Remove(FilterHandle callback, FilterServiceEntry filterServiceEntry) { using (_iLock.AcquireWriteLock()) { base.RemoveInternal(callback, filterServiceEntry); } }
/// <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 void Stop(AgentInstanceStopServices services) { using (_lock.Acquire()) { if (_filterHandle != null) { FilterValueSetParam[][] addendum = null; var agentInstanceContext = services.AgentInstanceContext; if (agentInstanceContext.AgentInstanceFilterProxy != null) { addendum = agentInstanceContext.AgentInstanceFilterProxy.GetAddendumFilters( _filterSpecActivatable, agentInstanceContext); } var filterValues = _filterSpecActivatable.GetValueSet( null, addendum, agentInstanceContext, agentInstanceContext.StatementContextFilterEvalEnv); services.AgentInstanceContext.FilterService.Remove( _filterHandle, _filterSpecActivatable.FilterForEventType, filterValues); } _filterHandle = null; } }
public override void Remove( FilterHandle callback, EventType eventType, FilterValueSetParam[][] valueSet) { RemoveInternal(callback, eventType, valueSet); }
public FilterSetEntry( FilterHandle handle, EventType eventType, FilterValueSetParam[][] valueSet) { Handle = handle; EventType = eventType; ValueSet = valueSet; }
/// <summary>Add to the current node building up the tree path information.</summary> /// <param name="remainingParameters">any remaining parameters</param> /// <param name="filterCallback">the filter callback</param> /// <param name="currentNode">is the node to add to</param> /// <param name="lockFactory">the lock factory</param> private static void AddToNode( ArrayDeque<FilterValueSetParam> remainingParameters, FilterHandle filterCallback, FilterHandleSetNode currentNode, FilterServiceGranularLockFactory lockFactory) { // If no parameters are specified, add to current node, and done if (remainingParameters.IsEmpty()) { using (currentNode.NodeRWLock.WriteLock.Acquire()) { currentNode.Add(filterCallback); } return; } // Need to find an existing index that matches one of the filter parameters Pair<FilterValueSetParam, FilterParamIndexBase> pair; using (currentNode.NodeRWLock.ReadLock.Acquire()) { pair = IndexHelper.FindIndex(remainingParameters, currentNode.Indizes); // Found an index matching a filter parameter if (pair != null) { remainingParameters.Remove(pair.First); var filterForValue = pair.First.FilterForValue; var index = pair.Second; AddToIndex(remainingParameters, filterCallback, index, filterForValue, lockFactory); return; } } // An index for any of the filter parameters was not found, create one using (currentNode.NodeRWLock.WriteLock.Acquire()) { pair = IndexHelper.FindIndex(remainingParameters, currentNode.Indizes); // Attempt to find an index again this time under a write lock if (pair != null) { remainingParameters.Remove(pair.First); var filterForValue = pair.First.FilterForValue; var indexInner = pair.Second; AddToIndex(remainingParameters, filterCallback, indexInner, filterForValue, lockFactory); return; } // No index found that matches any parameters, create a new one // Pick the next parameter for an index var parameterPickedForIndex = remainingParameters.RemoveFirst(); var index = IndexFactory.CreateIndex(parameterPickedForIndex.Lookupable, lockFactory, parameterPickedForIndex.FilterOperator); currentNode.Add(index); AddToIndex(remainingParameters, filterCallback, index, parameterPickedForIndex.FilterForValue, lockFactory); } }
public ViewableActivatorFilterMgmtCallback( IContainer container, FilterHandle filterHandle, FilterSpecActivatable filterSpecActivatable) { _lock = container.LockManager().CreateLock(GetType()); _filterHandle = filterHandle; _filterSpecActivatable = filterSpecActivatable; }
public override void Add( EventType eventType, FilterValueSetParam[][] valueSet, FilterHandle callback) { using (_lock.WriteLock.Acquire()) { AddInternal(eventType, valueSet, callback); } }
public override void Remove( FilterHandle callback, EventType eventType, FilterValueSetParam[][] valueSet) { using (_lock.WriteLock.Acquire()) { RemoveInternal(callback, eventType, valueSet); } }
public MySupportFilterHandle(FilterServiceLockCoarse filterService, FilterHandle callback, EventType eventType, FilterValueSetParam[][] spec) { this.filterService = filterService; this.callback = callback; this.eventType = eventType; this.spec = spec; }
// Remove an filterCallback from the current node, return true if the node is the node is empty now private static bool RemoveFromNode( FilterHandle filterCallback, FilterHandleSetNode currentNode, EventTypeIndexBuilderIndexLookupablePair[] treePathInfo, int treePathPosition) { var nextPair = treePathPosition < treePathInfo.Length ? treePathInfo[treePathPosition++] : null; // No remaining filter parameters if (nextPair == null) { using (currentNode.NodeRWLock.AcquireWriteLock()) { var isRemoved = currentNode.Remove(filterCallback); var isEmpty = currentNode.IsEmpty(); if (!isRemoved) { Log.Warn(".removeFromNode (" + Thread.CurrentThread.ManagedThreadId + ") Could not find the filterCallback to be removed within the supplied node , node=" + currentNode + " filterCallback=" + filterCallback); } return(isEmpty); } } // Remove from index var nextIndex = nextPair.Index; var filteredForValue = nextPair.Lookupable; using (currentNode.NodeRWLock.AcquireWriteLock()) { var isEmpty = RemoveFromIndex(filterCallback, nextIndex, treePathInfo, treePathPosition, filteredForValue); if (!isEmpty) { return(false); } // Remove the index if the index is now empty if (nextIndex.Count == 0) { var isRemoved = currentNode.Remove(nextIndex); if (!isRemoved) { Log.Warn(".removeFromNode (" + Thread.CurrentThread.ManagedThreadId + ") Could not find the index in index list for removal, index=" + nextIndex + " filterCallback=" + filterCallback); return(false); } } return(currentNode.IsEmpty()); } }
public void SetUp() { SupportBean testBean = new SupportBean(); _testEventBean = SupportEventBeanFactory.CreateObject(testBean); _testEventType = _testEventBean.EventType; _handleSetNode = new FilterHandleSetNode(ReaderWriterLockManager.CreateDefaultLock()); _filterCallback = new SupportFilterHandle(); _handleSetNode.Add(_filterCallback); _testIndex = new EventTypeIndex(new FilterServiceGranularLockFactoryReentrant()); _testIndex.Add(_testEventType, _handleSetNode); }
public void SetUp() { _eventTypeIndex = new EventTypeIndex(_lockFactory); _indexBuilder = new EventTypeIndexBuilder(_eventTypeIndex, true); _typeOne = SupportEventTypeFactory.CreateBeanType(typeof(SupportBean)); _typeTwo = SupportEventTypeFactory.CreateBeanType(typeof(SupportBeanSimple)); _valueSetOne = SupportFilterSpecBuilder.Build(_typeOne, new Object[0]).GetValueSet(null, null, null); _valueSetTwo = SupportFilterSpecBuilder.Build(_typeTwo, new Object[0]).GetValueSet(null, null, null); _callbackOne = new SupportFilterHandle(); _callbackTwo = new SupportFilterHandle(); }
protected void AddInternal( EventType eventType, FilterValueSetParam[][] valueSet, FilterHandle filterCallback) { if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().QFilterAdd(eventType, valueSet, filterCallback); } indexBuilder.Add(eventType, valueSet, filterCallback, lockFactory); filtersVersion++; if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().AFilterAdd(); } }
protected void RemoveInternal( FilterHandle filterCallback, EventType eventType, FilterValueSetParam[][] valueSet) { if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().QFilterRemove(filterCallback, eventType, valueSet); } indexBuilder.Remove(filterCallback, eventType, valueSet); filtersVersion++; if (InstrumentationHelper.ENABLED) { InstrumentationHelper.Get().AFilterRemove(); } }
public void Stop(AgentInstanceStopServices services) { using (_lock.Acquire()) { if (_filterHandle != null) { var filterValues = ComputeFilterValues(services.AgentInstanceContext); if (filterValues != null) { services.AgentInstanceContext.FilterService.Remove( _filterHandle, _filterSpecActivatable.FilterForEventType, filterValues); } } _filterHandle = null; } }
/// <summary> /// Remove an filterCallback from the given top node. The IndexTreePath instance passed in must be the same as obtained when the same filterCallback was added. /// </summary> /// <param name="eventType">Type of the event.</param> /// <param name="filterCallback">filter callback to be removed</param> /// <param name="treePathInfo">encapsulates information need to allow for safe removal of the filterCallback</param> /// <param name="topNode">The top tree node beneath which the filterCallback was added</param> public static void Remove( EventType eventType, FilterHandle filterCallback, EventTypeIndexBuilderIndexLookupablePair[] treePathInfo, FilterHandleSetNode topNode) { if ((ExecutionPathDebugLog.IsEnabled) && (Log.IsDebugEnabled)) { Log.Debug(".remove (" + Thread.CurrentThread.ManagedThreadId + ") Removing filterCallback " + " type " + eventType.Name + " topNode=" + topNode + " filterCallback=" + filterCallback); } RemoveFromNode(filterCallback, topNode, treePathInfo, 0); }
/// <summary> /// Remove a filter callback from the given index node. /// </summary> /// <param name="eventType">event type</param> /// <param name="valueSet">value set</param> /// <param name="filterCallback">is the callback to remove</param> public void Remove( FilterHandle filterCallback, EventType eventType, FilterValueSetParam[][] valueSet) { var rootNode = eventTypeIndex.Get(eventType); if (rootNode != null) { if (valueSet.Length == 0) { IndexTreeBuilderRemove.Remove(eventType, filterCallback, FilterSpecParam.EMPTY_VALUE_ARRAY, rootNode); } else { for (var i = 0; i < valueSet.Length; i++) { IndexTreeBuilderRemove.Remove(eventType, filterCallback, valueSet[i], rootNode); } } } }
public void SetUp() { SupportBean testBean = new SupportBean(); testEventBean = SupportEventBeanFactory .GetInstance(container) .CreateObject(testBean); testEventType = testEventBean.EventType; handleSetNode = new FilterHandleSetNode(new SlimReaderWriterLock()); filterCallback = new SupportFilterHandle(); handleSetNode.Add(filterCallback); testIndex = new EventTypeIndex(new FilterServiceGranularLockFactoryReentrant( container.RWLockManager())); testIndex.Add(testEventType, handleSetNode); }
public static T OFilter <T>(this IList <T> list, FilterHandle <T> handle) { if (list == null) { throw new ArgumentNullException("list"); } if (handle == null) { throw new ArgumentNullException("handle"); } for (int i = 0; i < list.Count; i++) { var g = list[i]; if (handle.Invoke(g)) { return(g); } } return(default);
public void SetUp() { _container = SupportContainer.Reset(); _lockFactory = new FilterServiceGranularLockFactoryReentrant(_container.RWLockManager()); _eventTypeIndex = new EventTypeIndex(_lockFactory); _indexBuilder = new EventTypeIndexBuilder(_container.LockManager(), _eventTypeIndex, true); _typeOne = SupportEventTypeFactory.CreateBeanType(typeof(SupportBean)); _typeTwo = SupportEventTypeFactory.CreateBeanType(typeof(SupportBeanSimple)); _valueSetOne = SupportFilterSpecBuilder.Build(_typeOne, new Object[0]).GetValueSet(null, null, null); _valueSetTwo = SupportFilterSpecBuilder.Build(_typeTwo, new Object[0]).GetValueSet(null, null, null); _callbackOne = new SupportFilterHandle(); _callbackTwo = new SupportFilterHandle(); }
/// <summary> /// Add a filter to the event type index structure, and to the filter subtree. /// Throws an IllegalStateException exception if the callback is already registered. /// </summary> /// <param name="filterValueSet">is the filter information</param> /// <param name="filterCallback">is the callback</param> /// <param name="lockFactory">The lock factory.</param> /// <returns></returns> /// <exception cref="IllegalStateException">Callback for filter specification already exists in collection</exception> public FilterServiceEntry Add(FilterValueSet filterValueSet, FilterHandle filterCallback, FilterServiceGranularLockFactory lockFactory) { using (Instrument.With( i => i.QFilterAdd(filterValueSet, filterCallback), i => i.AFilterAdd())) { var eventType = filterValueSet.EventType; // Check if a filter tree exists for this event type var rootNode = _eventTypeIndex.Get(eventType); // Make sure we have a root node if (rootNode == null) { using (_callbacksLock.Acquire()) { rootNode = _eventTypeIndex.Get(eventType); if (rootNode == null) { rootNode = new FilterHandleSetNode(lockFactory.ObtainNew()); _eventTypeIndex.Add(eventType, rootNode); } } } // GetInstance add to tree var path = IndexTreeBuilder.Add(filterValueSet, filterCallback, rootNode, lockFactory); var pathArray = path.Select(p => p.ToArray()).ToArray(); var pair = new EventTypeIndexBuilderValueIndexesPair(filterValueSet, pathArray); // for non-isolatable callbacks the consumer keeps track of tree location if (_isolatableCallbacks == null) { return(pair); } // for isolatable callbacks this class is keeping track of tree location using (_callbacksLock.Acquire()) { _isolatableCallbacks.Put(filterCallback, pair); } return(null); } }