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()); }
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(); } }