public void Run(Configuration configuration)
        {
            idCounter = new AtomicLong(0);
            executorService = Executors.NewCachedThreadPool();
            noActionUpdateListener = new NoActionUpdateListener();

            configuration.Runtime.Threading.IsInternalTimerEnabled = true;
            configuration.Common.AddEventType(typeof(SupportBean));
            configuration.Runtime.Threading.InsertIntoDispatchLocking = Locking.SUSPEND;

            var runtime = EPRuntimeProvider.GetRuntime(GetType().Name, configuration);
            runtime.Initialize();
            epRuntime = runtime.EventService;

            var path = new RegressionPath();
            var epl = "insert into Stream1 select count(*) as cnt from SupportBean#time(7 sec)";
            var compiled = SupportCompileDeployUtil.Compile(epl, configuration, path);
            path.Add(compiled);
            SupportCompileDeployUtil.Deploy(compiled, runtime);

            epl = epl + " output every 10 seconds";
            compiled = SupportCompileDeployUtil.Compile(epl, configuration, path);
            SupportCompileDeployUtil.DeployAddListener(compiled, "insert", noActionUpdateListener, runtime);

            var sendTickEventRunnable = new SendEventRunnable(this, 10000);
            Start(sendTickEventRunnable, 4);

            // Adjust here for long-running test
            SupportCompileDeployUtil.ThreadSleep(3000);
            sendTickEventRunnable.Shutdown = true;

            executorService.Shutdown();
            SupportCompileDeployUtil.ExecutorAwait(executorService, 1, TimeUnit.SECONDS);
            runtime.Destroy();
        }
Пример #2
0
        private void RunAssertion(
            FilterServiceProfile profile,
            Configuration configuration)
        {
            configuration.Runtime.Execution.FilterServiceProfile = profile;
            configuration.Common.AddEventType(typeof(MyEvent));

            var runtimeURI = GetType().Name + "_" + profile;
            var runtime = EPRuntimeProvider.GetRuntime(runtimeURI, configuration);

            var path = new RegressionPath();
            var eplContext = "create context MyContext start @now end after 100 milliseconds;\n";
            var compiledContext = SupportCompileDeployUtil.Compile(eplContext, configuration, path);
            SupportCompileDeployUtil.Deploy(compiledContext, runtime);
            path.Add(compiledContext);

            var epl = "context MyContext select FieldOne, count(*) as cnt from MyEvent " +
                      "group by FieldOne output last when terminated;\n";
            var compiledStmt = SupportCompileDeployUtil.Compile(epl, configuration, path);
            var listeners = new SupportUpdateListener[100];

            for (var i = 0; i < 100; i++) {
                listeners[i] = new SupportUpdateListener();
                var stmtName = "s" + i;
                SupportCompileDeployUtil.DeployAddListener(compiledStmt, stmtName, listeners[i], runtime);
            }

            var eventCount = 100000; // keep this divisible by 1000
            for (var i = 0; i < eventCount; i++) {
                var group = Convert.ToString(eventCount % 1000);
                runtime.EventService.SendEventBean(new MyEvent(Convert.ToString(i), group), "MyEvent");
            }

            SupportCompileDeployUtil.ThreadSleep(2000);

            AssertReceived(eventCount, listeners);

            try {
                runtime.DeploymentService.UndeployAll();
            }
            catch (EPUndeployException e) {
                throw new EPException(e);
            }

            runtime.Destroy();
        }