コード例 #1
0
        public void TestActiveCallbackRemove()
        {
            var spec        = SupportFilterSpecBuilder.Build(eventTypeOne, new object[0]).GetValueSet(null, null, null, null);
            var callbackTwo = new SupportFilterHandle();

            // callback that removes another matching filter spec callback
            var callbackOne = new MySupportFilterHandle(
                filterService,
                callbackTwo,
                eventTypeOne,
                spec);

            filterService.Add(eventTypeOne, spec, callbackOne);
            filterService.Add(eventTypeOne, spec, callbackTwo);

            // send event
            var theEvent = MakeTypeOneEvent(1, "HELLO", false, 1);
            var matches  = new List <FilterHandle>();

            filterService.Evaluate(theEvent, (ICollection <FilterHandle>)matches, (ExprEvaluatorContext)null);
            foreach (var match in matches)
            {
                ((FilterHandleCallback)match).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.That(callbackTwo.GetAndResetCountInvoked(), Is.EqualTo(1));
        }
コード例 #2
0
ファイル: TestFilterServiceMT.cs プロジェクト: lanicon/nesper
        private void RunAssertionAddRemoveFilter(FilterService service)
        {
            EventType eventType    = supportEventTypeFactory.CreateBeanType(typeof(SupportBean));
            var       spec         = SupportFilterSpecBuilder.Build(eventType, new object[] { "string", FilterOperator.EQUAL, "HELLO" });
            var       filterValues = spec.GetValueSet(null, null, null, null);

            var callables = new Func <bool> [5];

            for (var ii = 0; ii < callables.Length; ii++)
            {
                callables[ii] = () => {
                    var handle = new SupportFilterHandle();
                    for (var jj = 0; jj < 10000; jj++)
                    {
                        service.Add(eventType, filterValues, handle);
                        service.Remove(handle, eventType, filterValues);
                    }

                    return(true);
                };
            }

            var result = TryMT(callables);

            EPAssertionUtil.AssertAllBooleanTrue(result);
        }
コード例 #3
0
        public void SetUp()
        {
            var supportEventTypeFactory = SupportEventTypeFactory.GetInstance(container);

            lockFactory = new FilterServiceGranularLockFactoryReentrant(
                container.RWLockManager());

            eventTypeIndex = new EventTypeIndex(lockFactory);
            indexBuilder   = new EventTypeIndexBuilder(eventTypeIndex);

            typeOne = supportEventTypeFactory.CreateBeanType(typeof(SupportBean));
            typeTwo = supportEventTypeFactory.CreateBeanType(typeof(SupportBeanSimple));

            valueSetOne = SupportFilterSpecBuilder.Build(typeOne, new object[0]).GetValueSet(null, null, null, null);
            valueSetTwo = SupportFilterSpecBuilder.Build(typeTwo, new object[0]).GetValueSet(null, null, null, null);

            callbackOne = new SupportFilterHandle();
            callbackTwo = new SupportFilterHandle();
        }
コード例 #4
0
 private FilterSpecActivatable MakeSpec(object[] args)
 {
     return(SupportFilterSpecBuilder.Build(eventType, args));
 }
コード例 #5
0
        public void SetUp()
        {
            supportEventBeanFactory = SupportEventBeanFactory.GetInstance(container);

            filterService = new FilterServiceLockCoarse(container.RWLockManager(), -1);

            eventTypeOne = supportEventTypeFactory.CreateBeanType(typeof(SupportBean));
            eventTypeTwo = supportEventTypeFactory.CreateBeanType(typeof(SupportBeanSimple));

            filterSpecs = new List <Pair <EventType, FilterValueSetParam[][]> >();
            filterSpecs.Add(
                new Pair <EventType, FilterValueSetParam[][]>(
                    eventTypeOne,
                    SupportFilterSpecBuilder.Build(eventTypeOne, new object[0]).GetValueSet(null, null, null, null)));
            filterSpecs.Add(
                new Pair <EventType, FilterValueSetParam[][]>(
                    eventTypeOne,
                    SupportFilterSpecBuilder.Build(
                        eventTypeOne,
                        new object[] {
                "IntPrimitive", FilterOperator.RANGE_CLOSED, 10, 20,
                "TheString", FilterOperator.EQUAL, "HELLO",
                "BoolPrimitive", FilterOperator.EQUAL, false,
                "DoubleBoxed", FilterOperator.GREATER, 100d
            })
                    .GetValueSet(null, null, null, null)));
            filterSpecs.Add(
                new Pair <EventType, FilterValueSetParam[][]>(
                    eventTypeTwo,
                    SupportFilterSpecBuilder.Build(eventTypeTwo, new object[0]).GetValueSet(null, null, null, null)));
            filterSpecs.Add(
                new Pair <EventType, FilterValueSetParam[][]>(
                    eventTypeTwo,
                    SupportFilterSpecBuilder.Build(
                        eventTypeTwo,
                        new object[] {
                "MyInt", FilterOperator.RANGE_HALF_CLOSED, 1, 10,
                "MyString", FilterOperator.EQUAL, "Hello"
            })
                    .GetValueSet(null, null, null, null)));

            // Create callbacks and add
            filterCallbacks = new List <SupportFilterHandle>();
            for (var i = 0; i < filterSpecs.Count; i++)
            {
                filterCallbacks.Add(new SupportFilterHandle());
                filterService.Add(filterSpecs[i].First, filterSpecs[i].Second, filterCallbacks[i]);
            }

            // Create events
            matchesExpected = new List <int[]>();
            events          = new List <EventBean>();

            events.Add(MakeTypeOneEvent(15, "HELLO", false, 101));
            matchesExpected.Add(new[] { 1, 1, 0, 0 });

            events.Add(MakeTypeTwoEvent("Hello", 100));
            matchesExpected.Add(new[] { 0, 0, 1, 0 });

            events.Add(MakeTypeTwoEvent("Hello", 1)); // eventNumber = 2
            matchesExpected.Add(new[] { 0, 0, 1, 0 });

            events.Add(MakeTypeTwoEvent("Hello", 2));
            matchesExpected.Add(new[] { 0, 0, 1, 1 });

            events.Add(MakeTypeOneEvent(15, "HELLO", true, 100));
            matchesExpected.Add(new[] { 1, 0, 0, 0 });

            events.Add(MakeTypeOneEvent(15, "HELLO", false, 99));
            matchesExpected.Add(new[] { 1, 0, 0, 0 });

            events.Add(MakeTypeOneEvent(9, "HELLO", false, 100));
            matchesExpected.Add(new[] { 1, 0, 0, 0 });

            events.Add(MakeTypeOneEvent(10, "no", false, 100));
            matchesExpected.Add(new[] { 1, 0, 0, 0 });

            events.Add(MakeTypeOneEvent(15, "HELLO", false, 999999)); // number 8
            matchesExpected.Add(new[] { 1, 1, 0, 0 });

            events.Add(MakeTypeTwoEvent("Hello", 10));
            matchesExpected.Add(new[] { 0, 0, 1, 1 });

            events.Add(MakeTypeTwoEvent("Hello", 11));
            matchesExpected.Add(new[] { 0, 0, 1, 0 });
        }
コード例 #6
0
        private FilterValueSetParam[][] MakeFilterValues(params object[] filterSpecArgs)
        {
            var spec = SupportFilterSpecBuilder.Build(eventType, filterSpecArgs);

            return(spec.GetValueSet(null, null, null, null));
        }