Beispiel #1
0
            public void Run(RegressionEnvironment env)
            {
                var listener = new SupportContextListener(env);
                env.Runtime.ContextPartitionService.AddContextStateListener(listener);

                var path = new RegressionPath();
                env.CompileDeploy(
                    "@Name('ctx') create context MyContext " +
                    "context ContextPosNeg group by IntPrimitive > 0 as pos, group by IntPrimitive < 0 as neg from SupportBean, " +
                    "context ByString partition by TheString from SupportBean",
                    path);
                var depIdCtx = env.DeploymentId("ctx");
                listener.AssertAndReset(EventContext(depIdCtx, "MyContext", typeof(ContextStateEventContextCreated)));

                env.CompileDeploy("@Name('s0') context MyContext select count(*) from SupportBean", path);
                var depIdStmt = env.DeploymentId("s0");
                listener.AssertAndReset(
                    EventContextWStmt(
                        depIdCtx,
                        "MyContext",
                        typeof(ContextStateEventContextStatementAdded),
                        depIdStmt,
                        "s0"),
                    EventContext(depIdCtx, "MyContext", typeof(ContextStateEventContextActivated)));

                env.SendEventBean(new SupportBean("E1", 1));
                var allocated = listener.GetAllocatedEvents();
                Assert.AreEqual(1, allocated.Count);
                var nested = (ContextPartitionIdentifierNested) allocated[0].Identifier;
                EPAssertionUtil.AssertEqualsExactOrder(
                    new [] { "E1" },
                    ((ContextPartitionIdentifierPartitioned) nested.Identifiers[1]).Keys);
                Assert.AreEqual(1, listener.GetAndReset().Count);

                env.UndeployModuleContaining("s0");
                listener.AssertAndReset(
                    EventContextWStmt(
                        depIdCtx,
                        "MyContext",
                        typeof(ContextStateEventContextStatementRemoved),
                        depIdStmt,
                        "s0"),
                    EventPartitionInitTerm(depIdCtx, "MyContext", typeof(ContextStateEventContextPartitionDeallocated)),
                    EventContext(depIdCtx, "MyContext", typeof(ContextStateEventContextDeactivated)));

                env.UndeployModuleContaining("ctx");
                listener.AssertAndReset(EventContext(depIdCtx, "MyContext", typeof(ContextStateEventContextDestroyed)));

                env.Runtime.ContextPartitionService.RemoveContextStateListeners();
            }
Beispiel #2
0
            public void Run(RegressionEnvironment env)
            {
                var listener = new SupportContextListener(env);
                env.Runtime.ContextPartitionService.AddContextStateListener(listener);

                var path = new RegressionPath();
                env.CompileDeploy(
                    "@Name('ctx') create context MyContext group by IntPrimitive > 0 as pos, group by IntPrimitive < 0 as neg from SupportBean",
                    path);
                env.CompileDeploy("@Name('s0') context MyContext select count(*) from SupportBean", path);

                var allocated = listener.GetAllocatedEvents();
                Assert.AreEqual(2, allocated.Count);
                Assert.AreEqual("neg", ((ContextPartitionIdentifierCategory) allocated[1].Identifier).Label);
                listener.GetAndReset();

                env.UndeployModuleContaining("s0");
                env.UndeployModuleContaining("ctx");
                env.Runtime.ContextPartitionService.RemoveContextStateListeners();
            }
Beispiel #3
0
            public void Run(RegressionEnvironment env)
            {
                var listener = new SupportContextListener(env);
                env.Runtime.ContextPartitionService.AddContextStateListener(listener);

                var epl =
                    "@Name('ctx') create context MyContext coalesce by consistent_hash_crc32(TheString) from SupportBean granularity 2 preallocate;\n" +
                    "@Name('s0') context MyContext select count(*) from SupportBean;\n";
                env.CompileDeploy(epl);
                var deploymentId = env.DeploymentId("s0");

                var allocated = listener.GetAllocatedEvents();
                Assert.AreEqual(2, allocated.Count);
                Assert.AreEqual(1, ((ContextPartitionIdentifierHash) allocated[1].Identifier).Hash);
                listener.GetAndReset();

                env.UndeployAll();

                listener.AssertAndReset(
                    EventContextWStmt(
                        deploymentId,
                        "MyContext",
                        typeof(ContextStateEventContextStatementRemoved),
                        deploymentId,
                        "s0"),
                    EventPartitionInitTerm(
                        deploymentId,
                        "MyContext",
                        typeof(ContextStateEventContextPartitionDeallocated)),
                    EventPartitionInitTerm(
                        deploymentId,
                        "MyContext",
                        typeof(ContextStateEventContextPartitionDeallocated)),
                    EventContext(deploymentId, "MyContext", typeof(ContextStateEventContextDeactivated)),
                    EventContext(deploymentId, "MyContext", typeof(ContextStateEventContextDestroyed)));

                env.Runtime.ContextPartitionService.RemoveContextStateListeners();
            }