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);
        }
Esempio n. 2
0
 public GeneratorEnumerator(
     int maxNumEvents,
     GeneratorEnumeratorCallback callback)
 {
     this.maxNumEvents = maxNumEvents;
     this.callback = callback;
 }
        public void Run(RegressionEnvironment env)
        {
            ICollection <string> vals = Arrays.AsList("a", "b", "c", "d", "e", "f", "g", "h", "i", "j");

            GeneratorEnumeratorCallback enumCallback = numEvent => {
                var bean = new SupportCollection();
                bean.Strvals = vals;
                return(bean);
            };

            var enumFilter = "@Name('s0') select Strvals.anyOf(v -> v = 'j') from SupportCollection";

            TryCount(env, 4, 1000, enumFilter, enumCallback);
            env.UndeployAll();
        }
Esempio n. 4
0
        private void tryCount(
            RegressionEnvironment env,
            int numThreads,
            int numMessages,
            string epl,
            GeneratorEnumeratorCallback generatorEnumeratorCallback)
        {
            var threadPool = Executors.NewFixedThreadPool(
                numThreads,
                new SupportThreadFactory(typeof(MultithreadStmtFilter)).ThreadFactory);

            env.CompileDeploy(epl);
            var listener = new MTListener("mycount");

            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);

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

            foreach (var row in listener.Values)
            {
                result.Add(row.AsInt32());
            }

            Assert.AreEqual(numMessages * numThreads, result.Count);
            Assert.AreEqual(1, result.First());
            Assert.AreEqual(numMessages * numThreads, result.Last());

            env.UndeployAll();
        }
Esempio n. 5
0
        public void Run(RegressionEnvironment env)
        {
            var plainFilter = "@Name('s0') select count(*) as mycount from SupportBean";

            tryCount(env, 2, 1000, plainFilter, GeneratorEnumerator.DEFAULT_SUPPORTEBEAN_CB);
            tryCount(env, 4, 1000, plainFilter, GeneratorEnumerator.DEFAULT_SUPPORTEBEAN_CB);

            ICollection <string> vals = Arrays.AsList("a", "b", "c", "d", "e", "f", "g", "h", "i", "j");

            GeneratorEnumeratorCallback enumCallback = numEvent => {
                var bean = new SupportCollection();
                bean.Strvals = vals;
                return(bean);
            };

            var enumFilter =
                "@Name('s0') select count(*) as mycount from SupportCollection(Strvals.anyOf(v -> v = 'j'))";

            tryCount(env, 4, 1000, enumFilter, enumCallback);
        }
Esempio n. 6
0
 public GeneratorEnumerator(int maxNumEvents)
 {
     this.maxNumEvents = maxNumEvents;
     callback = DEFAULT_SUPPORTEBEAN_CB;
     nextValue = null;
 }