Example #1
0
        private void TrySend(EPStatement stmtWindow, int numThreads, int numRepeats)
        {
            var threadPool = Executors.NewFixedThreadPool(numThreads);
            var future     = new Future <object> [numThreads];

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

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

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

            EventBean[] events = stmtWindow.ToArray();
            Assert.AreEqual(numThreads * numRepeats, events.Length);
            for (int i = 0; i < events.Length; i++)
            {
                String valueC1 = (String)events[i].Get("c1");
                Assert.AreEqual("y", valueC1);
            }
        }
        private void TrySend(EPServiceProvider epService, EPStatement stmtWindow, int numThreads, int numRepeats)
        {
            var threadPool = Executors.NewFixedThreadPool(numThreads);
            var future     = new Future <object> [numThreads];

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

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

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

            EventBean[] events = EPAssertionUtil.EnumeratorToArray(stmtWindow.GetEnumerator());
            Assert.AreEqual(numThreads * numRepeats, events.Length);
            for (int i = 0; i < events.Length; i++)
            {
                string valueC1 = (string)events[i].Get("c1");
                Assert.AreEqual("y", valueC1);
            }
        }