Beispiel #1
0
 internal void ShouldThrow_When_Objects_Type_IsNotFound(
     EventOne evt,
     EventCatalog sut)
 => FluentActions
 .Invoking(() => sut.GetName(evt))
 .Should()
 .Throw <EventNotRegisteredException>();
Beispiel #2
0
 public void Should_Resolve_Name_From_Type(
     EventOne evt1,
     string evt1Name,
     string evt2Name)
 => new EventCatalog(new Dictionary <EventName, Type>
 {
     { evt1Name, typeof(EventOne) },
     { evt2Name, typeof(EventTwo) },
 })
 .GetName(evt1)
 .Should()
 .Be(evt1Name);
Beispiel #3
0
    public void Run()
    {
        EventOne += HandlerOne;
        EventOne += HandlerTwo;
        Console.WriteLine("Before clone");
        EventOne("EventOne");
        MyDelegate eventTwo = (MyDelegate)EventOne.Clone();

        Console.WriteLine("After clone");
        EventOne("EventOne");
        eventTwo("eventTwo");
        Console.WriteLine("Change event one to show it is different");
        EventOne += HandlerThree;
        EventOne("EventOne");
        eventTwo("eventTwo");
    }
Beispiel #4
0
 public void Handler(EventOne e)
 {
     Console.WriteLine("HandlerTwo handling EventOne: " + e.EventOneData);
 }
        private void RunAssertion(
            int runtimeNum,
            bool useDefault,
            bool? preserve,
            Locking? locking,
            Configuration config)
        {
            if (!useDefault) {
                config.Runtime.Threading.IsNamedWindowConsumerDispatchPreserveOrder = preserve.GetValueOrDefault();
                config.Runtime.Threading.NamedWindowConsumerDispatchLocking = locking.GetValueOrDefault();
                config.Runtime.Threading.NamedWindowConsumerDispatchTimeout = 100000;

                if (!preserve.GetValueOrDefault(false)) {
                    // In this setting there is no guarantee:
                    // (1) A thread T1 may process the first event to create a pair {E1, null}
                    // (2) A thread T2 may process the second event to create a pair {E2, E1}
                    // (3) Thread T2 pair may process first against consumer index
                    // (4) Thread T1 pair processes against consumer index and since its a unique index it fails
                    config.Runtime.ExceptionHandling.HandlerFactories.Clear();
                }
            }

            var runtime = EPRuntimeProvider.GetRuntime(
                typeof(MultithreadStmtNamedWindowUniqueTwoWJoinConsumer).Name + "_" + runtimeNum + "_" + count++,
                config);
            runtime.Initialize();

            var epl = "create window EventOneWindow#unique(Key) as EventOne;\n" +
                      "insert into EventOneWindow select * from EventOne;\n" +
                      "create window EventTwoWindow#unique(Key) as EventTwo;\n" +
                      "insert into EventTwoWindow select * from EventTwo;\n" +
                      "@Name('out') select * from EventOneWindow as e1, EventTwoWindow as e2 where e1.Key = e2.Key";
            var deployed = CompileDeploy(epl, runtime, config);

            var listener = new SupportMTUpdateListener();
            runtime.DeploymentService.GetStatement(deployed.DeploymentId, "out").AddListener(listener);

            ThreadStart runnableOne = () => {
                for (var i = 0; i < 33; i++) {
                    var eventOne = new EventOne("TEST");
                    runtime.EventService.SendEventBean(eventOne, eventOne.GetType().Name);
                    var eventTwo = new EventTwo("TEST");
                    runtime.EventService.SendEventBean(eventTwo, eventTwo.GetType().Name);
                }
            };

            ThreadStart runnableTwo = () => {
                for (var i = 0; i < 33; i++) {
                    var eventTwo = new EventTwo("TEST");
                    runtime.EventService.SendEventBean(eventTwo, eventTwo.GetType().Name);
                    var eventOne = new EventOne("TEST");
                    runtime.EventService.SendEventBean(eventOne, eventOne.GetType().Name);
                }
            };

            ThreadStart runnableThree = () => {
                for (var i = 0; i < 34; i++) {
                    var eventTwo = new EventTwo("TEST");
                    runtime.EventService.SendEventBean(eventTwo, eventTwo.GetType().Name);
                    var eventOne = new EventOne("TEST");
                    runtime.EventService.SendEventBean(eventOne, eventOne.GetType().Name);
                }
            };

            var t1 = new Thread(runnableOne) {
                Name = typeof(MultithreadStmtNamedWindowUniqueTwoWJoinConsumer).Name + "-one"
            };
            var t2 = new Thread(runnableTwo) {
                Name = typeof(MultithreadStmtNamedWindowUniqueTwoWJoinConsumer).Name + "-two"
            };
            var t3 = new Thread(runnableThree) {
                Name = typeof(MultithreadStmtNamedWindowUniqueTwoWJoinConsumer).Name + "-three"
            };
            t1.Start();
            t2.Start();
            t3.Start();
            ThreadSleep(1000);

            ThreadJoin(t1);
            ThreadJoin(t2);
            ThreadJoin(t3);
            ThreadSleep(200);

            var delivered = listener.NewDataList;

            // count deliveries of multiple rows
            var countMultiDeliveries = 0;
            foreach (var events in delivered) {
                countMultiDeliveries += events.Length > 1 ? 1 : 0;
            }

            // count deliveries where instance doesn't monotonically increase from previous row for one column
            var countNotMonotone = 0;
            long? previousIdE1 = null;
            long? previousIdE2 = null;
            foreach (var events in delivered) {
                var idE1 = events[0].Get("e1.Instance").AsInt64();
                var idE2 = events[0].Get("e2.Instance").AsInt64();
                // comment-in when needed: System.out.println("Received " + IdE1 + " " + IdE2);

                if (previousIdE1 != null) {
                    var incorrect = idE1 != previousIdE1 && idE2 != previousIdE2;
                    if (!incorrect) {
                        incorrect = idE1 == previousIdE1 && idE2 != previousIdE2 + 1 ||
                                    idE2 == previousIdE2 && idE1 != previousIdE1 + 1;
                    }

                    if (incorrect) {
                        // comment-in when needed: System.out.println("Non-Monotone increase (this is still correct but noteworthy)");
                        countNotMonotone++;
                    }
                }

                previousIdE1 = idE1;
                previousIdE2 = idE2;
            }

            if (useDefault || preserve.GetValueOrDefault()) {
                Assert.AreEqual(0, countMultiDeliveries, "multiple row deliveries: " + countMultiDeliveries);
                // the number of non-monotone delivers should be small but not zero
                // this is because when the event get generated and when the event actually gets processed may not be in the same order
                Assert.IsTrue(countNotMonotone < 100, "count not monotone: " + countNotMonotone);
                Assert.IsTrue(
                    delivered.Count >=
                    197); // its possible to not have 199 since there may not be events on one side of the join
            }
            else {
                Assert.IsTrue(countNotMonotone > 5, "count not monotone: " + countNotMonotone);
            }

            runtime.Destroy();
        }
Beispiel #6
0
 /// <summary>
 /// Awake is called before Start
 /// </summary>
 void Awake()
 {
     eventNull = new EventNull();
     eventOne  = new EventOne();
 }
Beispiel #7
0
 private void Awake()
 {
     eventOne = new EventOne();
     eventTwo = new EventTwo();
 }
        private void RunAssertion(bool useDefault, bool?preserve, ConfigurationEngineDefaults.Threading.Locking?locking)
        {
            var config = SupportConfigFactory.GetConfiguration();

            if (!useDefault)
            {
                if (preserve != null)
                {
                    config.EngineDefaults.ThreadingConfig.IsNamedWindowConsumerDispatchPreserveOrder = preserve.Value;
                }
                if (locking != null)
                {
                    config.EngineDefaults.ThreadingConfig.NamedWindowConsumerDispatchLocking = locking.Value;
                }
            }

            var epService = EPServiceProviderManager.GetDefaultProvider(config);

            epService.Initialize();
            epService.EPAdministrator.Configuration.AddEventType(typeof(EventOne));
            epService.EPAdministrator.Configuration.AddEventType(typeof(EventTwo));

            var epl =
                "create window EventOneWindow.std:unique(key) as EventOne;\n" +
                "insert into EventOneWindow select * from EventOne;\n" +
                "create window EventTwoWindow.std:unique(key) as EventTwo;\n" +
                "insert into EventTwoWindow select * from EventTwo;\n" +
                "@Name('out') select * from EventOneWindow as e1, EventTwoWindow as e2 where e1.key = e2.key";

            epService.EPAdministrator.DeploymentAdmin.ParseDeploy(epl);

            var listener = new SupportMTUpdateListener();

            epService.EPAdministrator.GetStatement("out").Events += listener.Update;

            ThreadStart runnableOne = () =>
            {
                for (var i = 0; i < 33; i++)
                {
                    var eventOne = new EventOne("TEST");
                    epService.EPRuntime.SendEvent(eventOne);
                    var eventTwo = new EventTwo("TEST");
                    epService.EPRuntime.SendEvent(eventTwo);
                }
            };
            ThreadStart runnableTwo = () =>
            {
                for (var i = 0; i < 33; i++)
                {
                    var eventTwo = new EventTwo("TEST");
                    epService.EPRuntime.SendEvent(eventTwo);
                    var eventOne = new EventOne("TEST");
                    epService.EPRuntime.SendEvent(eventOne);
                }
            };
            ThreadStart runnableThree = () =>
            {
                for (var i = 0; i < 34; i++)
                {
                    var eventTwo = new EventTwo("TEST");
                    epService.EPRuntime.SendEvent(eventTwo);
                    var eventOne = new EventOne("TEST");
                    epService.EPRuntime.SendEvent(eventOne);
                }
            };

            var t1 = new Thread(runnableOne);
            var t2 = new Thread(runnableTwo);
            var t3 = new Thread(runnableThree);

            t1.Start();
            t2.Start();
            t3.Start();

            t1.Join();
            t2.Join();
            t3.Join();

            var delivered = listener.GetNewDataList();

            // count deliveries of multiple rows
            var countMultiDeliveries = 0;

            foreach (var events in delivered)
            {
                countMultiDeliveries += (events.Length > 1 ? 1 : 0);
            }

            // count deliveries where instance doesn't monotonically increase from previous row for one column
            var  countNotMonotone = 0;
            long?previousIdE1     = null;
            long?previousIdE2     = null;

            foreach (var events in delivered)
            {
                var idE1 = events[0].Get("e1.instance").AsLong();
                var idE2 = events[0].Get("e2.instance").AsLong();
                // comment-in when needed: System.out.println("Received " + idE1 + " " + idE2);

                if (previousIdE1 != null)
                {
                    var incorrect = idE1 != previousIdE1 && idE2 != previousIdE2;
                    if (!incorrect)
                    {
                        incorrect = (idE1 == previousIdE1 && idE2 != (previousIdE2 + 1) ||
                                     (idE2 == previousIdE2 && idE1 != (previousIdE1 + 1)));
                    }
                    if (incorrect)
                    {
                        // comment-in when needed: System.out.println("Non-Monotone increase (this is still correct but noteworthy)");
                        countNotMonotone++;
                    }
                }

                previousIdE1 = idE1;
                previousIdE2 = idE2;
            }

            if (useDefault || preserve.Value)
            {
                Assert.AreEqual(0, countMultiDeliveries, "multiple row deliveries: " + countMultiDeliveries);
                // the number of non-monotone delivers should be small but not zero
                // this is because when the event get generated and when the event actually gets processed may not be in the same order
                Assert.That(countNotMonotone, Is.LessThan(50), "count not monotone: " + countNotMonotone);
                Assert.That(delivered.Count, Is.GreaterThanOrEqualTo(197));     // its possible to not have 199 since there may not be events on one side of the join
            }
            else
            {
                Assert.That(countMultiDeliveries, Is.GreaterThan(0), "multiple row deliveries: " + countMultiDeliveries);
                Assert.That(countNotMonotone, Is.GreaterThan(5), "count not monotone: " + countNotMonotone);
            }
        }
 protected bool Equals(EventOne other)
 {
     return(string.Equals(Key, other.Key));
 }
Beispiel #10
0
        public async Task HandleEventOneAsync([ServiceBusTrigger("event-one")] EventOne @event, CancellationToken token)
        {
            _logger.LogDebug("Processing {@EventOne}", @event);

            await Task.CompletedTask;
        }