Пример #1
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();
        }
Пример #2
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();
        }
Пример #3
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();
        }