예제 #1
0
        public override bool Equals(object obj)
        {
            if (this == obj) {
                return true;
            }

            if (!(obj is FilterSpecParamInForge)) {
                return false;
            }

            var other = (FilterSpecParamInForge) obj;
            if (!base.Equals(other)) {
                return false;
            }

            if (_listOfValues.Count != other._listOfValues.Count) {
                return false;
            }

            if (!CompatExtensions.DeepEqualsWithType(_listOfValues, other._listOfValues)) {
                return false;
            }

            return true;
        }
        private static void AssertStatement(RegressionEnvironment env)
        {
            Assert.AreEqual(2, env.Statement("s0").Annotations.Length);

            var array = (MyAnnotationValueArrayAttribute) env
                .Statement("s0")
                .Annotations[0];
            Assert.IsTrue(CompatExtensions.DeepEqualsWithType(ToObjectArray(array.Value), new object[] {1L, 2L, 3L}));
            Assert.IsTrue(CompatExtensions.DeepEqualsWithType(ToObjectArray(array.IntArray), new object[] {4, 5}));
            Assert.IsTrue(CompatExtensions.DeepEqualsWithType(ToObjectArray(array.DoubleArray), new object[] { }));
            Assert.IsTrue(CompatExtensions.DeepEqualsWithType(ToObjectArray(array.StringArray), new object[] {"X"}));
            Assert.IsTrue(CompatExtensions.DeepEqualsWithType(ToObjectArray(array.StringArrayDef), new object[] {"XYZ"}));
        }
        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);
        }
        private static void TrySend(
            RegressionEnvironment env,
            RegressionPath path,
            SupportMTUpdateListener listenerWindow,
            int numThreads,
            int numRepeats,
            int numConsumers)
        {
            var listenerConsumers = new SupportMTUpdateListener[numConsumers];
            var compiled = env.Compile("select TheString, LongPrimitive from MyWindow", path);
            for (var i = 0; i < listenerConsumers.Length; i++) {
                var stmtName = "c" + i;
                try {
                    env.Deployment.Deploy(compiled, new DeploymentOptions().WithStatementNameRuntime(ctx => stmtName));
                }
                catch (EPDeployException e) {
                    throw new EPException(e);
                }

                var stmtConsumer = env.Statement(stmtName);
                listenerConsumers[i] = new SupportMTUpdateListener();
                stmtConsumer.AddListener(listenerConsumers[i]);
            }

            var threadPool = Executors.NewFixedThreadPool(
                numThreads,
                new SupportThreadFactory(typeof(MultithreadStmtNamedWindowConsume)).ThreadFactory);
            var future = new IFuture<object>[numThreads];
            for (var i = 0; i < numThreads; i++) {
                var callable = new StmtNamedWindowConsumeCallable(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(numThreads * numRepeats, listenerWindow.NewDataList.Count); // old and new each

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

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

                Array.Sort(receivedIds);
                Array.Sort(expectedIds);
                CompatExtensions.DeepEqualsWithType(expectedIds, receivedIds);
            }
        }