private static void TryCount(
            RegressionEnvironment env,
            int numThreads,
            int numMessages,
            string epl,
            GeneratorEnumeratorCallback generatorEnumeratorCallback)
        {
            var threadPool = Executors.NewFixedThreadPool(
                numThreads,
                new SupportThreadFactory(typeof(MultithreadStmtStatelessEnummethod)).ThreadFactory);

            env.CompileDeploy(epl);
            var listener = new SupportMTUpdateListener();

            env.Statement("s0").AddListener(listener);

            var future = new IFuture <bool> [numThreads];

            for (var i = 0; i < numThreads; i++)
            {
                future[i] = threadPool.Submit(
                    new SendEventCallable(
                        i,
                        env.Runtime,
                        new GeneratorEnumerator(numMessages, generatorEnumeratorCallback)));
            }

            threadPool.Shutdown();
            SupportCompileDeployUtil.ExecutorAwait(threadPool, 10, TimeUnit.SECONDS);
            SupportCompileDeployUtil.AssertFutures(future);

            Assert.AreEqual(numMessages * numThreads, listener.GetNewDataListFlattened().Length);
        }
Пример #2
0
            public void Update(object sender, UpdateEventArgs e)
            {
                _isCalled = true;

                // create statement for thread - this can be called multiple times as other threads send SupportBean
                var stmt = _engine.EPAdministrator.CreateEPL(
                    "select * from " + typeof(SupportMarketDataBean).FullName + " where volume=" + _numThread);
                var listener = new SupportMTUpdateListener();

                stmt.Events += listener.Update;

                var theEvent = new SupportMarketDataBean("", 0, (long)_numThread, null);

                _engine.EPRuntime.SendEvent(theEvent);
                stmt.Stop();

                var eventsReceived = listener.GetNewDataListFlattened();

                var found = false;

                for (var i = 0; i < eventsReceived.Length; i++)
                {
                    if (eventsReceived[i].Underlying == theEvent)
                    {
                        found = true;
                    }
                }
                Assert.IsTrue(found);
            }
Пример #3
0
        private void TrySendContextCountSimple(int numThreads, int numRepeats)
        {
            var listener = new SupportMTUpdateListener();

            _engine.EPAdministrator.GetStatement("select").Events += listener.Update;

            var events = new List <Object>();

            for (int i = 0; i < numRepeats; i++)
            {
                events.Add(new SupportBean("E" + i, i));
            }

            var threadPool = Executors.NewFixedThreadPool(numThreads);
            var future     = new Future <object> [numThreads];

            for (int i = 0; i < numThreads; i++)
            {
                var callable = new SendEventCallable(i, _engine, events.GetEnumerator());
                future[i] = threadPool.Submit(callable);
            }

            threadPool.Shutdown();
            threadPool.AwaitTermination(TimeSpan.FromSeconds(10));

            EventBean[] result = listener.GetNewDataListFlattened();
            Assert.AreEqual(numRepeats * numThreads, result.Length);
        }
Пример #4
0
            public void Update(
                object sender,
                UpdateEventArgs eventArgs)
            {
                isCalled = true;

                // create statement for thread - this can be called multiple times as other threads send SupportBean
                env.Deploy(compiled);
                var listener = new SupportMTUpdateListener();
                env.Statement("t" + numThread).AddListener(listener);

                object theEvent = new SupportMarketDataBean("", 0, numThread, null);
                env.SendEventBean(theEvent, theEvent.GetType().Name);
                env.UndeployModuleContaining("t" + numThread);

                var eventsReceived = listener.GetNewDataListFlattened();

                var found = false;
                for (var i = 0; i < eventsReceived.Length; i++) {
                    if (eventsReceived[i].Underlying == theEvent) {
                        found = true;
                    }
                }

                Assert.IsTrue(found);
            }
Пример #5
0
        public bool Call()
        {
            try
            {
                // Add assertListener
                var assertListener = new SupportMTUpdateListener();
                ThreadLogUtil.Trace("adding listeners ", assertListener);
                _stmt.Events += assertListener.Update;

                for (var loop = 0; loop < _numRepeats; loop++)
                {
                    long id = _threadNum * 100000000 + loop;
                    object eventS0 = MakeEvent("s0", id);
                    object eventS1 = MakeEvent("s1", id);

                    ThreadLogUtil.Trace("SENDING s0 event ", id, eventS0);
                    _engine.EPRuntime.SendEvent(eventS0);
                    ThreadLogUtil.Trace("SENDING s1 event ", id, eventS1);
                    _engine.EPRuntime.SendEvent(eventS1);

                    //ThreadLogUtil.Info("sent", eventS0, eventS1);
                    // Should have received one that's mine, possible multiple since the statement is used by other threads
                    var found = false;
                    var events = assertListener.GetNewDataListFlattened();
                    foreach (var theEvent in events)
                    {
                        var s0Received = theEvent.Get("s0");
                        var s1Received = theEvent.Get("s1");
                        //ThreadLogUtil.Info("received", @event.Get("s0"), @event.Get("s1"));
                        if (s0Received == eventS0 && s1Received == eventS1)
                        {
                            found = true;
                        }
                    }

                    if (!found)
                    {
                    }

                    Assert.IsTrue(found);
                    assertListener.Reset();
                }
            }
            catch (AssertionException ex)
            {
                Log.Error("Assertion error in thread " + Thread.CurrentThread.ManagedThreadId, ex);
                return false;
            }
            catch (Exception ex)
            {
                Log.Error("Error in thread " + Thread.CurrentThread.ManagedThreadId, ex);
                return false;
            }

            return true;
        }
Пример #6
0
        private void TrySend(EPServiceProvider epService, SupportMTUpdateListener listener, int numThreads, int numRepeats)
        {
            // set time to 0
            epService.EPRuntime.SendEvent(new CurrentTimeEvent(0));

            var threadPool = Executors.NewFixedThreadPool(numThreads);
            var future     = new Future <bool> [numThreads];

            for (var i = 0; i < numThreads; i++)
            {
                var callable = new SendEventCallable(i, epService, new GeneratorIterator(numRepeats));
                future[i] = threadPool.Submit(callable);
            }

            // Advance time window every 100 milliseconds for 1 second
            for (var i = 0; i < 10; i++)
            {
                epService.EPRuntime.SendEvent(new CurrentTimeEvent(i * 1000));
                Thread.Sleep(100);
            }

            threadPool.Shutdown();
            threadPool.AwaitTermination(10, TimeUnit.SECONDS);

            for (var i = 0; i < numThreads; i++)
            {
                Assert.IsTrue(future[i].GetValueOrDefault());
            }

            // set time to a large value
            epService.EPRuntime.SendEvent(new CurrentTimeEvent(10000000000L));

            // Assert results
            var totalExpected = numThreads * numRepeats;

            // assert new data
            var resultNewData = listener.GetNewDataListFlattened();

            Assert.AreEqual(totalExpected, resultNewData.Length);
            var resultsNewData = SortPerIntKey(resultNewData);

            AssertResult(numRepeats, numThreads, resultsNewData);

            // assert old data
            var resultOldData = listener.GetOldDataListFlattened();

            Assert.AreEqual(totalExpected, resultOldData.Length);
            var resultsOldData = SortPerIntKey(resultOldData);

            AssertResult(numRepeats, numThreads, resultsOldData);

            listener.Reset();
        }
Пример #7
0
        private void TrySend(EPServiceProvider epService, SupportMTUpdateListener listener, int numThreads, int numRepeats)
        {
            var threadPool = Executors.NewFixedThreadPool(numThreads);
            var future     = new Future <bool> [numThreads];

            for (int i = 0; i < numThreads; i++)
            {
                var callable = new StmtInsertIntoCallable(Convert.ToString(i), epService, numRepeats);
                future[i] = threadPool.Submit(callable);
            }

            threadPool.Shutdown();
            threadPool.AwaitTermination(10, TimeUnit.SECONDS);

            for (int i = 0; i < numThreads; i++)
            {
                Assert.IsTrue(future[i].GetValueOrDefault());
            }

            // Assert results
            int totalExpected = numThreads * numRepeats * 2;

            EventBean[] result = listener.GetNewDataListFlattened();
            Assert.AreEqual(totalExpected, result.Length);
            var results = new LinkedHashMap <long, ISet <string> >();

            foreach (EventBean theEvent in result)
            {
                long   count = (long)theEvent.Get("mycount");
                string key   = (string)theEvent.Get("key");

                ISet <string> entries = results.Get(count);
                if (entries == null)
                {
                    entries = new HashSet <string>();
                    results.Put(count, entries);
                }
                entries.Add(key);
            }

            Assert.AreEqual(numRepeats, results.Count);
            foreach (ISet <string> value in results.Values)
            {
                Assert.AreEqual(2 * numThreads, value.Count);
                for (int i = 0; i < numThreads; i++)
                {
                    Assert.IsTrue(value.Contains("E1_" + i));
                    Assert.IsTrue(value.Contains("E2_" + i));
                }
            }

            listener.Reset();
        }
Пример #8
0
        private void TrySend(int numThreads, int numRepeats)
        {
            var threadPool = Executors.NewFixedThreadPool(numThreads);
            var future     = new Future <bool> [numThreads];

            for (int i = 0; i < numThreads; i++)
            {
                var callable = new StmtInsertIntoCallable(Convert.ToString(i), _engine, numRepeats);
                future[i] = threadPool.Submit(callable);
            }

            threadPool.Shutdown();
            threadPool.AwaitTermination(TimeSpan.FromSeconds(10));

            for (int i = 0; i < numThreads; i++)
            {
                Assert.IsTrue(future[i].GetValueOrDefault());
            }

            // Assert results
            int totalExpected = numThreads * numRepeats * 2;

            EventBean[] result = _listener.GetNewDataListFlattened();
            Assert.AreEqual(totalExpected, result.Length);
            var results = new LinkedHashMap <long, ICollection <String> >();

            foreach (EventBean theEvent in result)
            {
                var count = theEvent.Get("mycount").AsLong();
                var key   = (String)theEvent.Get("key");

                ICollection <String> entries = results.Get(count);
                if (entries == null)
                {
                    entries = new HashSet <String>();
                    results.Put(count, entries);
                }
                entries.Add(key);
            }

            Assert.AreEqual(numRepeats, results.Count);
            foreach (ICollection <String> value in results.Values)
            {
                Assert.AreEqual(2 * numThreads, value.Count);
                for (int i = 0; i < numThreads; i++)
                {
                    Assert.IsTrue(value.Contains("E1_" + i));
                    Assert.IsTrue(value.Contains("E2_" + i));
                }
            }

            _listener.Reset();
        }
        private void TrySend(int numThreads, int numEvents, bool isPreserveOrder, ConfigurationEngineDefaults.ThreadingConfig.Locking?locking)
        {
            Configuration config = SupportConfigFactory.GetConfiguration();

            config.EngineDefaults.Threading.IsListenerDispatchPreserveOrder = isPreserveOrder;
            config.EngineDefaults.Threading.ListenerDispatchLocking         = locking.GetValueOrDefault();

            EPServiceProvider engine = EPServiceProviderManager.GetProvider(
                SupportContainer.Instance, this.GetType().Name, config);

            engine.Initialize();

            // setup statements
            EPStatement stmtInsert = engine.EPAdministrator.CreateEPL("select count(*) as cnt from " + typeof(SupportBean).FullName);
            var         listener   = new SupportMTUpdateListener();

            stmtInsert.Events += listener.Update;

            // execute
            var threadPool = Executors.NewFixedThreadPool(numThreads);
            var future     = new Future <bool> [numThreads];

            for (int i = 0; i < numThreads; i++)
            {
                future[i] = threadPool.Submit(new SendEventCallable(i, engine, new GeneratorIterator(numEvents)));
            }

            threadPool.Shutdown();
            threadPool.AwaitTermination(10, TimeUnit.SECONDS);

            for (int i = 0; i < numThreads; i++)
            {
                Assert.IsTrue(future[i].GetValueOrDefault());
            }

            EventBean[] events = listener.GetNewDataListFlattened();
            var         result = new long[events.Length];

            for (int i = 0; i < events.Length; i++)
            {
                result[i] = (long)events[i].Get("cnt");
            }
            //Log.Info(".trySend result=" + CompatExtensions.Render(result));

            // assert result
            Assert.AreEqual(numEvents * numThreads, events.Length);
            for (int i = 0; i < numEvents * numThreads; i++)
            {
                Assert.AreEqual(result[i], (long)i + 1);
            }

            engine.Dispose();
        }
Пример #10
0
        private static void TrySend(
            RegressionEnvironment env,
            int numThreads,
            int numRepeats)
        {
            // set time to 0
            env.AdvanceTime(0);

            var listener = new SupportMTUpdateListener();
            env.CompileDeploy(
                "@Name('s0') select irstream IntPrimitive, TheString as key from SupportBean#time(1 sec)");
            env.Statement("s0").AddListener(listener);

            var threadPool = Executors.NewFixedThreadPool(
                numThreads,
                new SupportThreadFactory(typeof(MultithreadStmtTimeWindow)).ThreadFactory);
            var futures = new List<IFuture<bool>>();
            for (var i = 0; i < numThreads; i++) {
                var callable = new SendEventCallable(i, env.Runtime, new GeneratorEnumerator(numRepeats));
                futures.Add(threadPool.Submit(callable));
            }

            // Advance time window every 100 milliseconds for 1 second
            for (var i = 0; i < 10; i++) {
                env.AdvanceTime(i * 1000);
                SupportCompileDeployUtil.ThreadSleep(100);
            }

            threadPool.Shutdown();
            SupportCompileDeployUtil.ExecutorAwait(threadPool, 10, TimeUnit.SECONDS);
            SupportCompileDeployUtil.AssertFutures(futures);

            // set time to a large value
            env.AdvanceTime(10000000000L);

            // Assert results
            var totalExpected = numThreads * numRepeats;

            // assert new data
            var resultNewData = listener.GetNewDataListFlattened();
            Assert.AreEqual(totalExpected, resultNewData.Length);
            var resultsNewData = SortPerIntKey(resultNewData);
            AssertResult(numRepeats, numThreads, resultsNewData);

            // assert old data
            var resultOldData = listener.GetOldDataListFlattened();
            Assert.AreEqual(totalExpected, resultOldData.Length);
            var resultsOldData = SortPerIntKey(resultOldData);
            AssertResult(numRepeats, numThreads, resultsOldData);

            env.UndeployAll();
        }
        private void RunAssertionPatternFollowedBy(ConfigurationEngineDefaults.FilterServiceProfile profile)
        {
            Configuration config = SupportConfigFactory.GetConfiguration();

            config.AddEventType("S0", typeof(SupportBean_S0));
            String            engineURI = GetType().Name + "_" + profile;
            EPServiceProvider epService = EPServiceProviderManager.GetProvider(engineURI, config);

            epService.Initialize();

            String[] epls =
            {
                "select sa.Id,sb.Id,sc.Id,sd.Id from pattern [(sa=S0(Id=0)->sb=S0(Id=1)) or (sc=S0(Id=1)->sd=S0(Id=0))]",
                "select sa.Id,sb.Id,sc.Id,sd.Id from pattern [(sa=S0(Id=1)->sb=S0(Id=2)) or (sc=S0(Id=2)->sd=S0(Id=1))]",
                "select sa.Id,sb.Id,sc.Id,sd.Id from pattern [(sa=S0(Id=2)->sb=S0(Id=3)) or (sc=S0(Id=3)->sd=S0(Id=2))]",
                "select sa.Id,sb.Id,sc.Id,sd.Id from pattern [(sa=S0(Id=3)->sb=S0(Id=4)) or (sc=S0(Id=4)->sd=S0(Id=3))]",
                "select sa.Id,sb.Id,sc.Id,sd.Id from pattern [(sa=S0(Id=4)->sb=S0(Id=5)) or (sc=S0(Id=5)->sd=S0(Id=4))]",
                "select sa.Id,sb.Id,sc.Id,sd.Id from pattern [(sa=S0(Id=5)->sb=S0(Id=6)) or (sc=S0(Id=6)->sd=S0(Id=5))]",
                "select sa.Id,sb.Id,sc.Id,sd.Id from pattern [(sa=S0(Id=6)->sb=S0(Id=7)) or (sc=S0(Id=7)->sd=S0(Id=6))]",
                "select sa.Id,sb.Id,sc.Id,sd.Id from pattern [(sa=S0(Id=7)->sb=S0(Id=8)) or (sc=S0(Id=8)->sd=S0(Id=7))]",
                "select sa.Id,sb.Id,sc.Id,sd.Id from pattern [(sa=S0(Id=8)->sb=S0(Id=9)) or (sc=S0(Id=9)->sd=S0(Id=8))]"
            };

            for (int i = 0; i < 100; i++)
            {
                var listener = new SupportMTUpdateListener();
                var stmts    = new EPStatement[epls.Length];
                for (int j = 0; j < epls.Length; j++)
                {
                    stmts[j]         = epService.EPAdministrator.CreateEPL(epls[j]);
                    stmts[j].Events += listener.Update;
                }

                var threadOneValues = new int[] { 0, 2, 4, 6, 8 };
                var threadTwoValues = new int[] { 1, 3, 5, 7, 9 };
                var threadArray     = new[] { threadOneValues, threadTwoValues };

                Parallel.ForEach(
                    threadArray,
                    threadValues => ExecuteSender(epService.EPRuntime, threadValues));

                EventBean[] events = listener.GetNewDataListFlattened();
                Assert.AreEqual(9, events.Length);

                for (int j = 0; j < epls.Length; j++)
                {
                    stmts[j].Dispose();
                }
            }

            epService.Dispose();
        }
Пример #12
0
        public bool Call()
        {
            try
            {
                // Add assertListener
                var assertListener = new SupportMTUpdateListener();
                ThreadLogUtil.Trace("adding listeners ", assertListener);
                _stmt.Events += assertListener.Update;

                for (var loop = 0; loop < _numRepeats; loop++)
                {
                    var intPrimitive = loop % 10 + 1;
                    object eventS0 = MakeEvent(intPrimitive);

                    _engine.EPRuntime.SendEvent(eventS0);

                    // Should have received one that's mine, possible multiple since the statement is used by other threads
                    var found = false;
                    var events = assertListener.GetNewDataListFlattened();
                    foreach (var theEvent in events)
                    {
                        var s0Received = theEvent.Get("s0");
                        var s1Received = (IDictionary<string, object>) theEvent.Get("s1");
                        if (s0Received == eventS0 ||
                            s1Received.Get("myvarchar").Equals(_myvarcharValues[intPrimitive - 1]))
                        {
                            found = true;
                        }
                    }

                    if (!found)
                    {
                    }

                    Assert.IsTrue(found);
                    assertListener.Reset();
                }
            }
            catch (AssertionException ex)
            {
                Log.Error("Assertion error in thread " + Thread.CurrentThread.ManagedThreadId, ex);
                return false;
            }
            catch (Exception ex)
            {
                Log.Error("Error in thread " + Thread.CurrentThread.ManagedThreadId, ex);
                return false;
            }

            return true;
        }
Пример #13
0
        private void TrySend(int numThreads, int numRepeats)
        {
            // set time to 0
            _engine.EPRuntime.SendEvent(new CurrentTimeEvent(0));

            var threadPool = Executors.NewFixedThreadPool(numThreads);
            var future     = new Future <object> [numThreads];

            for (int i = 0; i < numThreads; i++)
            {
                var callable = new SendEventCallable(i, _engine, EventGenerator.MakeEvents(numRepeats));
                future[i] = threadPool.Submit(callable);
            }

            // Advance time window every 100 milliseconds for 1 second
            for (int i = 0; i < 10; i++)
            {
                _engine.EPRuntime.SendEvent(new CurrentTimeEvent(i * 1000));
                Thread.Sleep(100);
            }

            threadPool.Shutdown();
            threadPool.AwaitTermination(TimeSpan.FromSeconds(10));

            for (int i = 0; i < numThreads; i++)
            {
                Assert.IsTrue(future[i].GetValueOrDefault().AsBoolean());
            }

            // set time to a large value
            _engine.EPRuntime.SendEvent(new CurrentTimeEvent(10000000000L));

            // Assert results
            int totalExpected = numThreads * numRepeats;

            // assert new data
            EventBean[] resultNewData = _listener.GetNewDataListFlattened();
            Assert.AreEqual(totalExpected, resultNewData.Length);
            IDictionary <int, IList <String> > resultsNewData = SortPerIntKey(resultNewData);

            AssertResult(numRepeats, numThreads, resultsNewData);

            // assert old data
            EventBean[] resultOldData = _listener.GetOldDataListFlattened();
            Assert.AreEqual(totalExpected, resultOldData.Length);
            IDictionary <int, IList <String> > resultsOldData = SortPerIntKey(resultOldData);

            AssertResult(numRepeats, numThreads, resultsOldData);

            _listener.Reset();
        }
        private static void TrySend(
            int numThreads,
            int numEvents,
            bool isPreserveOrder,
            Locking locking,
            Configuration configuration)
        {
            configuration.Runtime.Threading.IsListenerDispatchPreserveOrder = isPreserveOrder;
            configuration.Runtime.Threading.ListenerDispatchLocking = locking;
            configuration.Common.AddEventType(typeof(SupportBean));

            var runtime = EPRuntimeProvider.GetRuntime(typeof(MultithreadDeterminismListener).Name, configuration);
            runtime.Initialize();

            // setup statements
            var deployed = SupportCompileDeployUtil.CompileDeploy(
                "@Name('s0') select count(*) as cnt from SupportBean",
                runtime,
                configuration);
            var listener = new SupportMTUpdateListener();
            deployed.Statements[0].AddListener(listener);

            // execute
            var threadPool = Executors.NewFixedThreadPool(
                numThreads,
                new SupportThreadFactory(typeof(MultithreadDeterminismListener)).ThreadFactory);
            var future = new IFuture<bool>[numThreads];
            for (var i = 0; i < numThreads; i++) {
                future[i] = threadPool.Submit(new SendEventCallable(i, runtime, new GeneratorEnumerator(numEvents)));
            }

            threadPool.Shutdown();
            SupportCompileDeployUtil.ExecutorAwait(threadPool, 10, TimeUnit.SECONDS);
            SupportCompileDeployUtil.AssertFutures(future);

            var events = listener.GetNewDataListFlattened();
            var result = new long[events.Length];
            for (var i = 0; i < events.Length; i++) {
                result[i] = events[i].Get("cnt").AsInt64();
            }
            //log.info(".trySend result=" + Arrays.toString(result));

            // assert result
            Assert.AreEqual(numEvents * numThreads, events.Length);
            for (var i = 0; i < numEvents * numThreads; i++) {
                Assert.AreEqual(result[i], (long) i + 1);
            }

            runtime.Destroy();
        }
Пример #15
0
        private void TrySend(int numThreads, int numEvents, bool isPreserveOrder, ConfigurationEngineDefaults.Threading.Locking?locking)
        {
            var config = SupportConfigFactory.GetConfiguration();

            config.EngineDefaults.ThreadingConfig.IsListenerDispatchPreserveOrder = isPreserveOrder;
            config.EngineDefaults.ThreadingConfig.ListenerDispatchLocking         = locking.GetValueOrDefault();

            _engine = EPServiceProviderManager.GetDefaultProvider(config);
            _engine.Initialize();

            // setup statements
            var stmtInsert = _engine.EPAdministrator.CreateEPL("select count(*) as cnt from " + typeof(SupportBean).FullName);
            var listener   = new SupportMTUpdateListener();

            stmtInsert.Events += listener.Update;

            // execute
            var threadPool = Executors.NewFixedThreadPool(numThreads);
            var future     = new Future <object> [numThreads];

            for (var i = 0; i < numThreads; i++)
            {
                future[i] = threadPool.Submit(new SendEventCallable(i, _engine, EnumerationGenerator.Create(numEvents)));
            }

            threadPool.Shutdown();
            threadPool.AwaitTermination(new TimeSpan(0, 0, 10));

            for (var i = 0; i < numThreads; i++)
            {
                Assert.IsTrue(future[i].GetValueOrDefault().AsBoolean());
            }

            var events = listener.GetNewDataListFlattened();
            var result = new long[events.Length];

            for (var i = 0; i < events.Length; i++)
            {
                result[i] = (long)events[i].Get("cnt");
            }
            //Log.Info(".trySend result=" + CompatExtensions.Render(result));

            // assert result
            Assert.AreEqual(numEvents * numThreads, events.Length);
            for (var i = 0; i < numEvents * numThreads; i++)
            {
                Assert.AreEqual(result[i], (long)i + 1);
            }
        }
        private static void TrySend(
            RegressionEnvironment env,
            SupportMTUpdateListener listenerWindow,
            SupportMTUpdateListener listenerConsumer,
            int numThreads,
            int numRepeats)
        {
            var threadPool = Executors.NewFixedThreadPool(
                numThreads,
                new SupportThreadFactory(typeof(MultithreadStmtNamedWindowDelete)).ThreadFactory);
            var future = new IFuture<object>[numThreads];
            for (var i = 0; i < numThreads; i++) {
                var callable = new StmtNamedWindowDeleteCallable(Convert.ToString(i), env.Runtime, numRepeats);
                future[i] = threadPool.Submit(callable);
            }

            threadPool.Shutdown();
            SupportCompileDeployUtil.ExecutorAwait(threadPool, 10, TimeUnit.SECONDS);

            // compute list of expected
            IList<string> expectedIdsList = new List<string>();
            for (var i = 0; i < numThreads; i++) {
                try {
                    expectedIdsList.AddAll((IList<string>) future[i].Get());
                }
                catch (Exception t) {
                    throw new EPException(t);
                }
            }

            var expectedIds = expectedIdsList.ToArray();

            Assert.AreEqual(2 * numThreads * numRepeats, listenerWindow.NewDataList.Count); // old and new each
            Assert.AreEqual(2 * numThreads * numRepeats, listenerConsumer.NewDataList.Count); // old and new each

            // compute list of received
            var newEvents = listenerWindow.GetNewDataListFlattened();
            var receivedIds = new string[newEvents.Length];
            for (var i = 0; i < newEvents.Length; i++) {
                receivedIds[i] = (string) newEvents[i].Get("TheString");
            }

            Assert.AreEqual(receivedIds.Length, expectedIds.Length);

            Array.Sort(receivedIds);
            Array.Sort(expectedIds);
            CompatExtensions.DeepEqualsWithType(expectedIds, receivedIds);
        }
Пример #17
0
        private static void TryListener(
            RegressionEnvironment env,
            int numThreads,
            int numRoutes)
        {
            env.CompileDeploy("@Name('trigger') select * from SupportBean");
            env.CompileDeploy("@Name('s0') select * from SupportMarketDataBean");
            var listener = new SupportMTUpdateListener();
            env.Statement("s0").AddListener(listener);

            // Set of events routed by each listener
            ISet<SupportMarketDataBean> routed = new HashSet<SupportMarketDataBean>().AsSyncSet();

            var threadPool = Executors.NewFixedThreadPool(
                numThreads,
                new SupportThreadFactory(typeof(MultithreadStmtListenerRoute)).ThreadFactory);
            var future = new IFuture<object>[numThreads];
            for (var i = 0; i < numThreads; i++) {
                var callable = new StmtListenerCreateStmtCallable(
                    i,
                    env.Runtime,
                    env.Statement("trigger"),
                    numRoutes,
                    routed);
                future[i] = threadPool.Submit(callable);
            }

            threadPool.Shutdown();
            SupportCompileDeployUtil.ExecutorAwait(threadPool, 10, TimeUnit.SECONDS);
            SupportCompileDeployUtil.AssertFutures(future);

            // assert
            var results = listener.GetNewDataListFlattened();
            Assert.IsTrue(results.Length >= numThreads * numRoutes);

            foreach (var routedEvent in routed) {
                var found = false;
                for (var i = 0; i < results.Length; i++) {
                    if (results[i].Underlying == routedEvent) {
                        found = true;
                    }
                }

                Assert.IsTrue(found);
            }

            env.UndeployAll();
        }
Пример #18
0
        private static void TrySend(
            RegressionEnvironment env,
            SupportMTUpdateListener listener,
            int numThreads,
            int numRepeats)
        {
            var threadPool = Executors.NewFixedThreadPool(
                numThreads,
                new SupportThreadFactory(typeof(MultithreadStmtInsertInto)).ThreadFactory);
            var future = new IFuture<object>[numThreads];
            for (var i = 0; i < numThreads; i++) {
                var callable = new StmtInsertIntoCallable(Convert.ToString(i), env.Runtime, numRepeats);
                future[i] = threadPool.Submit(callable);
            }

            threadPool.Shutdown();
            SupportCompileDeployUtil.ExecutorAwait(threadPool, 10, TimeUnit.SECONDS);
            SupportCompileDeployUtil.AssertFutures(future);

            // Assert results
            var totalExpected = numThreads * numRepeats * 2;
            var result = listener.GetNewDataListFlattened();
            Assert.AreEqual(totalExpected, result.Length);
            IDictionary<long, ICollection<string>> results = new Dictionary<long, ICollection<string>>();
            foreach (var theEvent in result) {
                var count = theEvent.Get("mycount").AsInt64();
                var key = (string) theEvent.Get("key");

                var entries = results.Get(count);
                if (entries == null) {
                    entries = new HashSet<string>();
                    results.Put(count, entries);
                }

                entries.Add(key);
            }

            Assert.AreEqual(numRepeats, results.Count);
            foreach (var value in results.Values) {
                Assert.AreEqual(2 * numThreads, value.Count);
                for (var i = 0; i < numThreads; i++) {
                    Assert.IsTrue(value.Contains("E1_" + i));
                    Assert.IsTrue(value.Contains("E2_" + i));
                }
            }

            listener.Reset();
        }
Пример #19
0
        private void TryListener(EPServiceProvider epService, int numThreads, int numRoutes)
        {
            EPStatement stmtTrigger = epService.EPAdministrator.CreateEPL(
                " select * from " + typeof(SupportBean).FullName);

            EPStatement stmtListen = epService.EPAdministrator.CreateEPL(
                " select * from " + typeof(SupportMarketDataBean).FullName);
            var listener = new SupportMTUpdateListener();

            stmtListen.Events += listener.Update;

            // Set of events routed by each listener
            var routed = CompatExtensions.AsSyncSet(new HashSet <SupportMarketDataBean>());

            var threadPool = Executors.NewFixedThreadPool(numThreads);
            var future     = new Future <bool> [numThreads];

            for (int i = 0; i < numThreads; i++)
            {
                var callable = new StmtListenerCreateStmtCallable(i, epService, stmtTrigger, numRoutes, routed);
                future[i] = threadPool.Submit(callable);
            }

            threadPool.Shutdown();
            threadPool.AwaitTermination(10, TimeUnit.SECONDS);

            for (int i = 0; i < numThreads; i++)
            {
                Assert.IsTrue(future[i].GetValueOrDefault());
            }

            // assert
            EventBean[] results = listener.GetNewDataListFlattened();
            Assert.IsTrue(results.Length >= numThreads * numRoutes);

            foreach (SupportMarketDataBean routedEvent in routed)
            {
                bool found = false;
                for (int i = 0; i < results.Length; i++)
                {
                    if (results[i].Underlying == routedEvent)
                    {
                        found = true;
                    }
                }
                Assert.IsTrue(found);
            }
        }
Пример #20
0
        private static void TrySendContextCountSimple(
            RegressionEnvironment env,
            int numThreads,
            int numRepeats)
        {
            var listener = new SupportMTUpdateListener();
            env.Statement("select").AddListener(listener);

            IList<object>[] eventsPerThread = new List<object>[numThreads];
            for (var t = 0; t < numThreads; t++) {
                eventsPerThread[t] = new List<object>();
                for (var i = 0; i < numRepeats; i++) {
                    eventsPerThread[t].Add(new SupportBean_S0(-1, "E" + i, i + "_" + t));
                }
            }

            var threadPool = Executors.NewFixedThreadPool(
                numThreads,
                new SupportThreadFactory(typeof(MultithreadContextCountSimple)).ThreadFactory);
            var future = new IFuture<bool>[numThreads];
            for (var i = 0; i < numThreads; i++) {
                var callable = new SendEventCallable(i, env.Runtime, eventsPerThread[i].GetEnumerator());
                future[i] = threadPool.Submit(callable);
            }

            SupportCompileDeployUtil.ThreadSleep(2000);
            threadPool.Shutdown();
            SupportCompileDeployUtil.ExecutorAwait(threadPool, 10, TimeUnit.SECONDS);
            SupportCompileDeployUtil.AssertFutures(future);

            var result = listener.GetNewDataListFlattened();
            ISet<string> received = new HashSet<string>();
            foreach (var @event in result) {
                var key = (string) @event.Get("P01");
                if (received.Contains(key)) {
                    Assert.Fail("key " + key + " received multiple times");
                }

                received.Add(key);
            }

            if (received.Count != numRepeats * numThreads) {
                log.Info("Received are " + received.Count + " entries");
                Assert.Fail();
            }
        }
Пример #21
0
        public bool Call()
        {
            try {
                // Add assertListener
                var assertListener1 = new SupportMTUpdateListener(Thread.CurrentThread.Name + "#1");
                ThreadLogUtil.Trace("adding listeners ", assertListener1);
                //stmt.Events += assertListener1.Update;
                _stmt.Events += assertListener1.Update;

                for (int loop = 0; loop < _numRepeats; loop++)
                {
                    var intPrimitive = loop % 10 + 1;
                    var eventS0      = MakeEvent(intPrimitive);
                    _engine.EPRuntime.SendEvent(eventS0);

                    // Should have received one that's mine, possible multiple since the statement is used by other threads
                    var found  = false;
                    var events = assertListener1.GetNewDataListFlattened();

                    foreach (var theEvent in events)
                    {
                        var s0Received = theEvent.Get("s0");
                        var s1Received = (DataMap)theEvent.Get("s1");
                        if ((s0Received == eventS0) ||
                            (s1Received.Get("myvarchar").Equals(_myvarcharValues[intPrimitive - 1])))
                        {
                            found = true;
                        }
                    }

                    Assert.IsTrue(found);
                    assertListener1.Reset();
                }
            }
            catch (AssertionException ex) {
                Console.WriteLine(ex.Message);
                Log.Fatal("Assertion error in thread " + Thread.CurrentThread.ManagedThreadId, ex);
                return(false);
            }
            catch (Exception ex) {
                Log.Fatal("Error in thread " + Thread.CurrentThread.ManagedThreadId, ex);
                return(false);
            }
            return(true);
        }
Пример #22
0
        private void TrySend(EPServiceProvider epService, int numThreads, int numRepeats)
        {
            EPStatement stmt = epService.EPAdministrator.CreateEPL(
                "select (select id from S0#length(1000000) where id = s1.id) as value from S1 as s1");

            var listener = new SupportMTUpdateListener();

            stmt.Events += listener.Update;

            var threadPool = Executors.NewFixedThreadPool(numThreads);
            var future     = new Future <bool> [numThreads];

            for (int i = 0; i < numThreads; i++)
            {
                var callable = new StmtSubqueryCallable(i, epService, numRepeats);
                future[i] = threadPool.Submit(callable);
            }

            threadPool.Shutdown();
            threadPool.AwaitTermination(10, TimeUnit.SECONDS);

            for (int i = 0; i < numThreads; i++)
            {
                Assert.IsTrue(future[i].GetValueOrDefault());
            }

            // Assert results
            int totalExpected = numThreads * numRepeats;

            // assert new data
            EventBean[] resultNewData = listener.GetNewDataListFlattened();
            Assert.AreEqual(totalExpected, resultNewData.Length);

            var values = new HashSet <int?>();

            foreach (EventBean theEvent in resultNewData)
            {
                values.Add((int?)theEvent.Get("value"));
            }
            Assert.AreEqual(totalExpected, values.Count, "Unexpected duplicates");

            listener.Reset();
            stmt.Stop();
        }
Пример #23
0
        private void TryListener(int numThreads, int numRoutes)
        {
            EPStatement stmtTrigger = _engine.EPAdministrator.CreateEPL(
                " select * from " + typeof(SupportBean).FullName);

            EPStatement stmtListen = _engine.EPAdministrator.CreateEPL(
                " select * from " + typeof(SupportMarketDataBean).FullName);
            SupportMTUpdateListener listener = new SupportMTUpdateListener();

            stmtListen.Events += listener.Update;

            // Set of events routed by each listener
            ICollection <SupportMarketDataBean> routed = new HashSet <SupportMarketDataBean>().AsSyncCollection();

            var threadPool = Executors.NewFixedThreadPool(numThreads);
            var future     = new Future <bool> [numThreads];

            for (int i = 0; i < numThreads; i++)
            {
                var callable = new StmtListenerCreateStmtCallable(i, _engine, stmtTrigger, numRoutes, routed);
                future[i] = threadPool.Submit(callable);
            }

            threadPool.Shutdown();
            threadPool.AwaitTermination(TimeSpan.FromSeconds(10));

            for (int i = 0; i < numThreads; i++)
            {
                Assert.IsTrue(future[i].GetValueOrDefault());
            }

            // assert
            EventBean[] results = listener.GetNewDataListFlattened();
            Assert.IsTrue(results.Length >= numThreads * numRoutes);

            foreach (var found in routed.Select(routedEvent => results.Any(eventBean => eventBean.Underlying == routedEvent)))
            {
                Assert.IsTrue(found);
            }
        }
Пример #24
0
        private static void TrySend(
            RegressionEnvironment env,
            int numThreads,
            int numRepeats)
        {
            env.CompileDeploy(
                "@Name('s0') select (select Id from SupportBean_S0#length(1000000) where Id = S1.Id) as value from SupportBean_S1 as S1");
            var listener = new SupportMTUpdateListener();
            env.Statement("s0").AddListener(listener);

            var threadPool = Executors.NewFixedThreadPool(
                numThreads,
                new SupportThreadFactory(typeof(MultithreadStmtSubquery)).ThreadFactory);
            var future = new IFuture<object>[numThreads];
            for (var i = 0; i < numThreads; i++) {
                var callable = new StmtSubqueryCallable(i, env.Runtime, numRepeats);
                future[i] = threadPool.Submit(callable);
            }

            threadPool.Shutdown();
            SupportCompileDeployUtil.ExecutorAwait(threadPool, 10, TimeUnit.SECONDS);
            SupportCompileDeployUtil.AssertFutures(future);

            // Assert results
            var totalExpected = numThreads * numRepeats;

            // assert new data
            var resultNewData = listener.GetNewDataListFlattened();
            Assert.AreEqual(totalExpected, resultNewData.Length);

            ISet<int> values = new HashSet<int>();
            foreach (var theEvent in resultNewData) {
                values.Add(theEvent.Get("value").AsInt32());
            }

            Assert.AreEqual(totalExpected, values.Count, "Unexpected duplicates");

            listener.Reset();
            env.UndeployAll();
        }
Пример #25
0
        private void TrySend(int numThreads, int numRepeats)
        {
            var threadPool = Executors.NewFixedThreadPool(numThreads);
            var future     = new Future <IList <string> > [numThreads];

            for (int i = 0; i < numThreads; i++)
            {
                var callable = new StmtNamedWindowDeleteCallable(Convert.ToString(i), _engine, numRepeats);
                future[i] = threadPool.Submit(callable);
            }

            threadPool.Shutdown();
            threadPool.AwaitTermination(TimeSpan.FromSeconds(10));

            // Compute list of expected
            List <String> expectedIdsList = new List <String>();

            for (int i = 0; i < numThreads; i++)
            {
                expectedIdsList.AddAll(future[i].GetValueOrDefault());
            }
            String[] expectedIds = expectedIdsList.ToArray();

            Assert.AreEqual(2 * numThreads * numRepeats, _listenerWindow.GetNewDataList().Count);   // old and new each
            Assert.AreEqual(2 * numThreads * numRepeats, _listenerConsumer.GetNewDataList().Count); // old and new each

            // Compute list of received
            EventBean[] newEvents   = _listenerWindow.GetNewDataListFlattened();
            String[]    receivedIds = new String[newEvents.Length];
            for (int i = 0; i < newEvents.Length; i++)
            {
                receivedIds[i] = (String)newEvents[i].Get("TheString");
            }
            Assert.AreEqual(receivedIds.Length, expectedIds.Length);

            Array.Sort(receivedIds);
            Array.Sort(expectedIds);

            CompatExtensions.DeepEquals(expectedIds, receivedIds);
        }
        private void TrySend(EPServiceProvider epService, SupportMTUpdateListener listenerWindow, SupportMTUpdateListener listenerConsumer, int numThreads, int numRepeats)
        {
            var threadPool = Executors.NewFixedThreadPool(numThreads);
            var future     = new Future <IList <string> > [numThreads];

            for (int i = 0; i < numThreads; i++)
            {
                var callable = new StmtNamedWindowDeleteCallable(Convert.ToString(i), epService, numRepeats);
                future[i] = threadPool.Submit(callable);
            }

            threadPool.Shutdown();
            threadPool.AwaitTermination(10, TimeUnit.SECONDS);

            // compute list of expected
            var expectedIdsList = new List <string>();

            for (int i = 0; i < numThreads; i++)
            {
                expectedIdsList.AddAll(future[i].GetValueOrDefault());
            }
            string[] expectedIds = expectedIdsList.ToArray();

            Assert.AreEqual(2 * numThreads * numRepeats, listenerWindow.NewDataList.Count);   // old and new each
            Assert.AreEqual(2 * numThreads * numRepeats, listenerConsumer.NewDataList.Count); // old and new each

            // compute list of received
            EventBean[] newEvents   = listenerWindow.GetNewDataListFlattened();
            var         receivedIds = new string[newEvents.Length];

            for (int i = 0; i < newEvents.Length; i++)
            {
                receivedIds[i] = (string)newEvents[i].Get("TheString");
            }
            Assert.AreEqual(receivedIds.Length, expectedIds.Length);

            Array.Sort(receivedIds);
            Array.Sort(expectedIds);
            CompatExtensions.DeepEquals(expectedIds, receivedIds);
        }
Пример #27
0
        private void TrySetAndReadAtomic(int numThreads, int numRepeats)
        {
            var threadPool = Executors.NewFixedThreadPool(numThreads);
            var future     = new Future <bool> [numThreads];

            for (int i = 0; i < numThreads; i++)
            {
                var callable = new VariableReadWriteCallable(i, _epService, numRepeats);
                future[i] = threadPool.Submit(callable);
            }

            threadPool.Shutdown();
            threadPool.AwaitTermination(TimeSpan.FromSeconds(10));

            for (int i = 0; i < numThreads; i++)
            {
                Assert.IsTrue(future[i].GetValueOrDefault());
            }

            // Determine if we have all numbers for var3 and didn't skip one.
            // Since "var3 = var3 + 1" is executed by multiple statements and threads we need to have
            // this counter have all the values from 0 to Count-1.
            var var3Values = new SortedSet <long>();

            foreach (EventBean theEvent in _listenerSetOne.GetNewDataListFlattened())
            {
                var3Values.Add(theEvent.Get("var3").AsLong());
            }
            foreach (EventBean theEvent in _listenerSetTwo.GetNewDataListFlattened())
            {
                var3Values.Add(theEvent.Get("var3").AsLong());
            }
            Assert.AreEqual(numThreads * numRepeats, var3Values.Count);
            for (int i = 1; i < numThreads * numRepeats + 1; i++)
            {
                Assert.IsTrue(var3Values.Contains((long)i));
            }
        }
Пример #28
0
        private static void TrySetAndReadAtomic(
            RegressionEnvironment env,
            SupportMTUpdateListener listenerSetOne,
            SupportMTUpdateListener listenerSetTwo,
            int numThreads,
            int numRepeats)
        {
            var threadPool = Executors.NewFixedThreadPool(
                numThreads,
                new SupportThreadFactory(typeof(MultithreadVariables)).ThreadFactory);
            var future = new IFuture<object>[numThreads];
            for (var i = 0; i < numThreads; i++) {
                var callable = new VariableReadWriteCallable(i, env, numRepeats);
                future[i] = threadPool.Submit(callable);
            }

            threadPool.Shutdown();
            SupportCompileDeployUtil.ExecutorAwait(threadPool, 10, TimeUnit.SECONDS);
            SupportCompileDeployUtil.AssertFutures(future);

            // Determine if we have all numbers for var3 and didn't skip one.
            // Since "var3 = var3 + 1" is executed by multiple statements and threads we need to have
            // this counter have all the values from 0 to N-1.
            ISet<long> var3Values = new SortedSet<long>();
            foreach (var theEvent in listenerSetOne.GetNewDataListFlattened()) {
                var3Values.Add(theEvent.Get("var3").AsInt64());
            }

            foreach (var theEvent in listenerSetTwo.GetNewDataListFlattened()) {
                var3Values.Add(theEvent.Get("var3").AsInt64());
            }

            Assert.AreEqual(numThreads * numRepeats, var3Values.Count);
            for (var i = 1; i < numThreads * numRepeats + 1; i++) {
                Assert.IsTrue(var3Values.Contains(i));
            }
        }
Пример #29
0
        public bool Call()
        {
            try {
                for (int loop = 0; loop < _numRepeats; loop++)
                {
                    // Add assertListener
                    var assertListener = new SupportMTUpdateListener();
                    LogUpdateListener logListener;
                    if (_isEPL)
                    {
                        logListener = new LogUpdateListener(null);
                    }
                    else
                    {
                        logListener = new LogUpdateListener("a");
                    }
                    ThreadLogUtil.Trace("adding listeners ", assertListener, logListener);
                    _stmt.Events += assertListener.Update;
                    _stmt.Events += logListener.Update;

                    // send event
                    Object theEvent = MakeEvent();
                    ThreadLogUtil.Trace("sending event ", theEvent);
                    _engine.EPRuntime.SendEvent(theEvent);

                    // Should have received one or more events, one of them must be mine
                    EventBean[] newEvents = assertListener.GetNewDataListFlattened();
                    Assert.IsTrue(newEvents.Length >= 1, "No event received");
                    ThreadLogUtil.Trace("assert received, size is", newEvents.Length);
                    bool found = false;
                    for (int i = 0; i < newEvents.Length; i++)
                    {
                        Object underlying = newEvents[i].Underlying;
                        if (!_isEPL)
                        {
                            underlying = newEvents[i].Get("a");
                        }
                        if (underlying == theEvent)
                        {
                            found = true;
                        }
                    }
                    Assert.IsTrue(found);
                    assertListener.Reset();

                    // Remove assertListener
                    ThreadLogUtil.Trace("removing assertListener");
                    _stmt.Events -= assertListener.Update;
                    _stmt.Events -= logListener.Update;

                    // Send another event
                    theEvent = MakeEvent();
                    ThreadLogUtil.Trace("send non-matching event ", theEvent);
                    _engine.EPRuntime.SendEvent(theEvent);

                    // Make sure the event was not received
                    newEvents = assertListener.GetNewDataListFlattened();
                    found     = false;
                    for (int i = 0; i < newEvents.Length; i++)
                    {
                        Object underlying = newEvents[i].Underlying;
                        if (!_isEPL)
                        {
                            underlying = newEvents[i].Get("a");
                        }
                        if (underlying == theEvent)
                        {
                            found = true;
                        }
                    }
                    Assert.IsFalse(found);
                }
            }
            catch (AssertionException ex) {
                Log.Error("Assertion error in thread " + Thread.CurrentThread.ManagedThreadId, ex);
                return(false);
            }
            catch (Exception ex) {
                Log.Error("Error in thread " + Thread.CurrentThread.ManagedThreadId, ex);
                return(false);
            }
            return(true);
        }
Пример #30
0
        private void RunAssertionPatternFollowedBy(ConfigurationEngineDefaults.FilterServiceProfile profile)
        {
            Configuration config = SupportConfigFactory.GetConfiguration();

            config.AddEventType("S0", typeof(SupportBean_S0));
            string            engineUri = this.GetType().Name + "_" + profile;
            EPServiceProvider epService = EPServiceProviderManager.GetProvider(
                SupportContainer.Instance, engineUri, config);

            epService.Initialize();

            string[] epls =
            {
                "select sa.id,sb.id,sc.id,sd.id from pattern [(sa=S0(id=0)->sb=S0(id=1)) or (sc=S0(id=1)->sd=S0(id=0))]",
                "select sa.id,sb.id,sc.id,sd.id from pattern [(sa=S0(id=1)->sb=S0(id=2)) or (sc=S0(id=2)->sd=S0(id=1))]",
                "select sa.id,sb.id,sc.id,sd.id from pattern [(sa=S0(id=2)->sb=S0(id=3)) or (sc=S0(id=3)->sd=S0(id=2))]",
                "select sa.id,sb.id,sc.id,sd.id from pattern [(sa=S0(id=3)->sb=S0(id=4)) or (sc=S0(id=4)->sd=S0(id=3))]",
                "select sa.id,sb.id,sc.id,sd.id from pattern [(sa=S0(id=4)->sb=S0(id=5)) or (sc=S0(id=5)->sd=S0(id=4))]",
                "select sa.id,sb.id,sc.id,sd.id from pattern [(sa=S0(id=5)->sb=S0(id=6)) or (sc=S0(id=6)->sd=S0(id=5))]",
                "select sa.id,sb.id,sc.id,sd.id from pattern [(sa=S0(id=6)->sb=S0(id=7)) or (sc=S0(id=7)->sd=S0(id=6))]",
                "select sa.id,sb.id,sc.id,sd.id from pattern [(sa=S0(id=7)->sb=S0(id=8)) or (sc=S0(id=8)->sd=S0(id=7))]",
                "select sa.id,sb.id,sc.id,sd.id from pattern [(sa=S0(id=8)->sb=S0(id=9)) or (sc=S0(id=9)->sd=S0(id=8))]"
            };

            for (int i = 0; i < 20; i++)
            {
                Log.Info("i=" + i);
                var listener = new SupportMTUpdateListener();
                var stmts    = new EPStatement[epls.Length];
                for (int j = 0; j < epls.Length; j++)
                {
                    stmts[j]         = epService.EPAdministrator.CreateEPL(epls[j]);
                    stmts[j].Events += listener.Update;
                }

                var threadOneValues = new int[] { 0, 2, 4, 6, 8 };
                var threadTwoValues = new int[] { 1, 3, 5, 7, 9 };

                var threadOne = new Thread(new SenderRunnable(epService.EPRuntime, threadOneValues).Run);
                var threadTwo = new Thread(new SenderRunnable(epService.EPRuntime, threadTwoValues).Run);

                threadOne.Start();
                threadTwo.Start();
                threadOne.Join();
                threadTwo.Join();

                EventBean[] events = listener.GetNewDataListFlattened();

#if INTERNAL_DEBUG
                for (int j = 0; j < events.Length; j++)
                {
                    EventBean @out = events[j];
                    Log.Info(" sa=" + GetNull(@out.Get("sa.id")) +
                             " sb=" + GetNull(@out.Get("sb.id")) +
                             " sc=" + GetNull(@out.Get("sc.id")) +
                             " sd=" + GetNull(@out.Get("sd.id")));
                }
#endif
                Assert.AreEqual(9, events.Length);

                for (int j = 0; j < epls.Length; j++)
                {
                    stmts[j].Dispose();
                }
            }

            epService.Dispose();
        }