private void RetryableMatchEvent(EventBean theEvent, ICollection <FilterHandle> matches) { // Install lock backoff exception handler that retries the evaluation. try { _eventTypeIndex.MatchEvent(theEvent, matches); } catch (FilterLockBackoffException ex) { // retry on lock back-off // lock-backoff may occur when stateful evaluations take place such as bool expressions that are subqueries // statements that contain subqueries in pattern filter expression can themselves modify filters, leading to a theoretically possible deadlock long delayNs = 10; while (true) { try { // yield try { Thread.Sleep(0); } catch (ThreadInterruptedException e) { Thread.CurrentThread.Interrupt(); } // delay MicroThread.SleepNano(delayNs); if (delayNs < 1000000000) { delayNs = delayNs * 2; } // evaluate matches.Clear(); _eventTypeIndex.MatchEvent(theEvent, matches); break; } catch (FilterLockBackoffException ex2) { // retried } } } }
public void TestMatch() { List <FilterHandle> matchesList = new List <FilterHandle>(); // Invoke match _testIndex.MatchEvent(_testEventBean, matchesList); Assert.AreEqual(1, matchesList.Count); Assert.AreEqual(_filterCallback, matchesList[0]); }
public void TestInterfaceMatch() { _testEventBean = SupportEventBeanFactory.CreateObject(new ISupportABCImpl("a", "b", "ab", "c")); _testEventType = SupportEventTypeFactory.CreateBeanType(typeof(ISupportBaseAB)); _testIndex = new EventTypeIndex(new FilterServiceGranularLockFactoryReentrant()); _testIndex.Add(_testEventType, _handleSetNode); List <FilterHandle> matchesList = new List <FilterHandle>(); _testIndex.MatchEvent(_testEventBean, matchesList); Assert.AreEqual(1, matchesList.Count); Assert.AreEqual(_filterCallback, matchesList[0]); }
public void TestSuperclassMatch() { _testEventBean = SupportEventBeanFactory.CreateObject(new ISupportAImplSuperGImplPlus()); _testEventType = SupportEventTypeFactory.CreateBeanType(typeof(ISupportA)); _testIndex = new EventTypeIndex(new FilterServiceGranularLockFactoryReentrant(_container.RWLockManager())); _testIndex.Add(_testEventType, _handleSetNode); List <FilterHandle> matchesList = new List <FilterHandle>(); _testIndex.MatchEvent(_testEventBean, matchesList); Assert.AreEqual(1, matchesList.Count); Assert.AreEqual(_filterCallback, matchesList[0]); }