コード例 #1
0
        public override void Run(EPServiceProvider epService)
        {
            string joinStatement = "select id, p00, TheString from " +
                                   typeof(SupportBean).FullName + "()#length(100) as s1, " +
                                   " method:SupportStaticMethodInvocations.FetchObjectLog(TheString, IntPrimitive)";
            EPStatement stmt     = epService.EPAdministrator.CreateEPL(joinStatement);
            var         listener = new SupportUpdateListener();

            stmt.Events += listener.Update;

            // set sleep off
            SupportStaticMethodInvocations.GetInvocationSizeAndReset();

            SendTimer(epService, 1000);
            var fields = new string[] { "id", "p00", "TheString" };

            SendBeanEvent(epService, "E1", 1);
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { 1, "|E1|", "E1" });

            SendTimer(epService, 1500);
            SendBeanEvent(epService, "E2", 2);
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { 2, "|E2|", "E2" });

            SendTimer(epService, 2000);
            SendBeanEvent(epService, "E3", 3);
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { 3, "|E3|", "E3" });
            Assert.AreEqual(3, SupportStaticMethodInvocations.GetInvocationSizeAndReset());

            // should be cached
            SendBeanEvent(epService, "E3", 3);
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { 3, "|E3|", "E3" });
            Assert.AreEqual(0, SupportStaticMethodInvocations.GetInvocationSizeAndReset());

            SendTimer(epService, 2100);
            // should not be cached
            SendBeanEvent(epService, "E4", 4);
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { 4, "|E4|", "E4" });
            Assert.AreEqual(1, SupportStaticMethodInvocations.GetInvocationSizeAndReset());

            // should be cached
            SendBeanEvent(epService, "E2", 2);
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { 2, "|E2|", "E2" });
            Assert.AreEqual(0, SupportStaticMethodInvocations.GetInvocationSizeAndReset());

            // should not be cached
            SendBeanEvent(epService, "E1", 1);
            EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { 1, "|E1|", "E1" });
            Assert.AreEqual(1, SupportStaticMethodInvocations.GetInvocationSizeAndReset());
        }
コード例 #2
0
        public void Run(RegressionEnvironment env)
        {
            var joinStatement = "@Name('s0') select Id, P00, TheString from " +
                                "SupportBean#length(100) as S1, " +
                                " method:SupportStaticMethodInvocations.FetchObjectLog(TheString, IntPrimitive)";
            env.CompileDeploy(joinStatement).AddListener("s0");

            // set sleep off
            SupportStaticMethodInvocations.GetInvocationSizeReset();

            // The LRU cache caches per same keys
            string[] fields = {"Id", "P00", "TheString"};
            SendBeanEvent(env, "E1", 1);
            EPAssertionUtil.AssertProps(
                env.Listener("s0").AssertOneGetNewAndReset(),
                fields,
                new object[] {1, "|E1|", "E1"});

            SendBeanEvent(env, "E2", 2);
            EPAssertionUtil.AssertProps(
                env.Listener("s0").AssertOneGetNewAndReset(),
                fields,
                new object[] {2, "|E2|", "E2"});

            SendBeanEvent(env, "E3", 3);
            EPAssertionUtil.AssertProps(
                env.Listener("s0").AssertOneGetNewAndReset(),
                fields,
                new object[] {3, "|E3|", "E3"});
            Assert.AreEqual(3, SupportStaticMethodInvocations.GetInvocationSizeReset());

            // should be cached
            SendBeanEvent(env, "E3", 3);
            EPAssertionUtil.AssertProps(
                env.Listener("s0").AssertOneGetNewAndReset(),
                fields,
                new object[] {3, "|E3|", "E3"});
            Assert.AreEqual(0, SupportStaticMethodInvocations.GetInvocationSizeReset());

            // should not be cached
            SendBeanEvent(env, "E4", 4);
            EPAssertionUtil.AssertProps(
                env.Listener("s0").AssertOneGetNewAndReset(),
                fields,
                new object[] {4, "|E4|", "E4"});
            Assert.AreEqual(1, SupportStaticMethodInvocations.GetInvocationSizeReset());

            // should be cached
            SendBeanEvent(env, "E2", 2);
            EPAssertionUtil.AssertProps(
                env.Listener("s0").AssertOneGetNewAndReset(),
                fields,
                new object[] {2, "|E2|", "E2"});
            Assert.AreEqual(0, SupportStaticMethodInvocations.GetInvocationSizeReset());

            // should not be cached
            SendBeanEvent(env, "E1", 1);
            EPAssertionUtil.AssertProps(
                env.Listener("s0").AssertOneGetNewAndReset(),
                fields,
                new object[] {1, "|E1|", "E1"});
            Assert.AreEqual(1, SupportStaticMethodInvocations.GetInvocationSizeReset());

            env.UndeployAll();
        }
コード例 #3
0
        public void TestLRUCache()
        {
            Configuration          config       = SupportConfigFactory.GetConfiguration();
            ConfigurationMethodRef methodConfig = new ConfigurationMethodRef();

            methodConfig.SetLRUCache(3);
            config.AddMethodRef(typeof(SupportStaticMethodInvocations).FullName, methodConfig);
            config.AddImport(typeof(SupportStaticMethodInvocations).Namespace);

            _epService = EPServiceProviderManager.GetDefaultProvider(config);
            _epService.Initialize();
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.StartTest(_epService, GetType(), GetType().FullName);
            }
            _listener = new SupportUpdateListener();

            String joinStatement = "select Id, P00, TheString from " +
                                   typeof(SupportBean).FullName + "().win:length(100) as s1, " +
                                   " method:SupportStaticMethodInvocations.FetchObjectLog(TheString, IntPrimitive)";
            EPStatement stmt = _epService.EPAdministrator.CreateEPL(joinStatement);

            stmt.Events += _listener.Update;

            // set sleep off
            SupportStaticMethodInvocations.GetInvocationSizeAndReset();

            // The LRU cache caches per same keys
            String[] fields = new String[] { "Id", "P00", "TheString" };
            SendBeanEvent("E1", 1);
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new Object[] { 1, "|E1|", "E1" });

            SendBeanEvent("E2", 2);
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new Object[] { 2, "|E2|", "E2" });

            SendBeanEvent("E3", 3);
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new Object[] { 3, "|E3|", "E3" });
            Assert.AreEqual(3, SupportStaticMethodInvocations.GetInvocationSizeAndReset());

            // should be cached
            SendBeanEvent("E3", 3);
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new Object[] { 3, "|E3|", "E3" });
            Assert.AreEqual(0, SupportStaticMethodInvocations.GetInvocationSizeAndReset());

            // should not be cached
            SendBeanEvent("E4", 4);
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new Object[] { 4, "|E4|", "E4" });
            Assert.AreEqual(1, SupportStaticMethodInvocations.GetInvocationSizeAndReset());

            // should be cached
            SendBeanEvent("E2", 2);
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new Object[] { 2, "|E2|", "E2" });
            Assert.AreEqual(0, SupportStaticMethodInvocations.GetInvocationSizeAndReset());

            // should not be cached
            SendBeanEvent("E1", 1);
            EPAssertionUtil.AssertProps(_listener.AssertOneGetNewAndReset(), fields, new Object[] { 1, "|E1|", "E1" });
            Assert.AreEqual(1, SupportStaticMethodInvocations.GetInvocationSizeAndReset());

            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.EndTest();
            }
        }