Esempio n. 1
0
        public void Run(RegressionEnvironment env)
        {
            var runnable = new MySendRunnable(env.Runtime);
            var thread = new Thread(runnable.Run);
            thread.Name = "MultithreadDeployAtomic-" + typeof(MultithreadDeployAtomic).FullName;
            thread.Start();

            var listener = new MyKeepFirstPerStmtListener();
            env.Deployment.AddDeploymentStateListener(
                new ProxyDeploymentStateListener {
                    ProcOnDeployment = @event => {
                        foreach (var stmt in @event.Statements) {
                            stmt.AddListener(listener);
                        }
                    },

                    ProcOnUndeployment = @event => { }
                });

            // deploy
            var buf = new StringBuilder();
            for (var i = 0; i < NUM_STMTS; i++) {
                buf.Append("select * from SupportBean;");
            }

            var deploymentResult = CompileDeploy(buf.ToString(), env.Runtime, env.Configuration);

            // wait for some deliveries
            ThreadSleep(1000);

            // undeploy
            env.Undeploy(deploymentResult.DeploymentId);

            // cooldown
            ThreadSleep(500);

            runnable.Shutdown = true;
            ThreadJoin(thread);

            Assert.IsNull(runnable.Exception);
            Assert.AreEqual(NUM_STMTS, listener.FirstLastPerStmt.Count);

            // all first events should be the same
            var reference = listener.FirstLastPerStmt.Values.First();
            Assert.IsNotNull(reference.First);
            Assert.IsNotNull(reference.Second);
            Assert.AreNotSame(reference.First, reference.Second);
            foreach (var other in listener.FirstLastPerStmt.Values) {
                Assert.AreSame(reference.Second, other.Second, "last event not the same");
            }

            foreach (var other in listener.FirstLastPerStmt.Values) {
                Assert.AreSame(reference.First, other.First, "first event not the same");
            }

            env.Deployment.RemoveAllDeploymentStateListeners();
        }
Esempio n. 2
0
        public override void Run(EPServiceProvider epService)
        {
            epService.EPAdministrator.Configuration.AddEventType<SupportBean>();
            var runnable = new MySendRunnable(epService);
            var thread = new Thread(runnable.Run);
            thread.Start();

            var listener = new MyKeepFirstPerStmtListener();
            epService.StatementCreate += (sender, args) => args.Statement.Events += listener.Update;

            // deploy
            var buf = new StringWriter();
            for (var i = 0; i < NUM_STMTS; i++)
            {
                buf.Write("select * from SupportBean;");
            }

            var deploymentResult = epService.EPAdministrator.DeploymentAdmin.ParseDeploy(buf.ToString());

            // wait for some deliveries
            Thread.Sleep(1000);

            // undeploy
            epService.EPAdministrator.DeploymentAdmin.Undeploy(deploymentResult.DeploymentId);

            // cooldown
            Thread.Sleep(500);

            runnable.IsShutdown = true;
            thread.Join();

            Assert.IsNull(runnable.Throwable);
            Assert.AreEqual(NUM_STMTS, listener.FirstLastPerStmt.Count);

            // all first events should be the same
            UniformPair<EventBean> reference = listener.FirstLastPerStmt.Values.First();
            Assert.IsNotNull(reference.First);
            Assert.IsNotNull(reference.Second);
            Assert.AreNotSame(reference.First, reference.Second);
            foreach (UniformPair<EventBean> other in listener.FirstLastPerStmt.Values)
            {
                Assert.AreSame(reference.First, other.First);
                Assert.AreSame(reference.Second, other.Second);
            }
        }