Beispiel #1
0
        public void TryCount(EPServiceProvider epService, int numThreads, int numMessages, string epl, GeneratorIteratorCallback generatorIteratorCallback)
        {
            var threadPool = Executors.NewFixedThreadPool(numThreads);
            var stmt       = epService.EPAdministrator.CreateEPL(epl);
            var listener   = new MTListener("mycount");

            stmt.Events += listener.Update;

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

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

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

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

            // verify results
            Assert.AreEqual(numMessages * numThreads, listener.Values.Count);
            var result = new SortedSet <int>();

            foreach (var row in listener.Values)
            {
                result.Add(row.AsInt());
            }
            Assert.AreEqual(numMessages * numThreads, result.Count);
            Assert.AreEqual(1, result.First());
            Assert.AreEqual(numMessages * numThreads, result.Last());
        }
Beispiel #2
0
        public void TryCount(int numThreads, int numMessages, String epl, GeneratorIteratorCallback generatorCallback)
        {
            var threadPool = Executors.NewFixedThreadPool(numThreads);
            var stmt       = _engine.EPAdministrator.CreateEPL(epl);
            var listener   = new MTListener("mycount");

            stmt.Events += listener.Update;

            var future = new Future <object> [numThreads];

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

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

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

            // verify results
            Assert.AreEqual(numMessages * numThreads, listener.Values.Count);
            SortedSet <int> result = new SortedSet <int>();

            foreach (Object row in listener.Values)
            {
                result.Add(row.AsInt());
            }
            Assert.AreEqual(numMessages * numThreads, result.Count);
            Assert.AreEqual(1, (Object)result.First());
            Assert.AreEqual(numMessages * numThreads, (Object)result.Last());
        }