public void Run(RegressionEnvironment env) { var args = new CompilerArguments(env.Configuration); args.Options.AccessModifierEventType = ctx => NameAccessModifier.PUBLIC; var first = env.Compile( "@Name('s0') insert into SomeStream select TheString as a, IntPrimitive as b from SupportBean", args); var second = env.Compile( "@Name('s1') select a, b from SomeStream", new CompilerArguments(env.Configuration).SetPath(new CompilerPath().Add(first))); env.Deploy(first).Milestone(0); env.SendEventBean(new SupportBean("E1", 1)); env.Deploy(second).AddListener("s1").Milestone(1); SendAssert(env, "E2", 2); SendAssert(env, "E3", 3); env.Milestone(2); SendAssert(env, "E4", 4); env.UndeployAll(); }
public void Run(RegressionEnvironment env) { var compiledCreate = env.Compile( "create window MyWindow#length(2) as SupportBean", options => options.AccessModifierNamedWindow = ctx => NameAccessModifier.PUBLIC); env.Deploy(compiledCreate); var compiledInsert = env.Compile( "insert into MyWindow select * from SupportBean", new CompilerArguments(env.MinimalConfiguration()).SetPath(new CompilerPath().Add(compiledCreate))); env.Deploy(compiledInsert); var compiledSelect = env.Compile( "@Name('s0') select TheString as c0, sum(IntPrimitive) as c1 from MyWindow;\n", new CompilerArguments(env.MinimalConfiguration()).SetPath(new CompilerPath().Add(compiledCreate))); env.Deploy(compiledSelect).AddListener("s0"); env.SendEventBean(new SupportBean("E1", 10)); EPAssertionUtil.AssertProps(env.Listener("s0").AssertOneGetNewAndReset(), fields, new object[] {"E1", 10}); env.SendEventBean(new SupportBean("E2", 20)); EPAssertionUtil.AssertProps(env.Listener("s0").AssertOneGetNewAndReset(), fields, new object[] {"E2", 30}); env.SendEventBean(new SupportBean("E3", 25)); EPAssertionUtil.AssertProps(env.Listener("s0").AssertOneGetNewAndReset(), fields, new object[] {"E3", 45}); env.SendEventBean(new SupportBean("E4", 26)); EPAssertionUtil.AssertProps(env.Listener("s0").AssertOneGetNewAndReset(), fields, new object[] {"E4", 51}); env.UndeployAll(); }
public void Run(RegressionEnvironment env) { var epl = "@Name('s0') @IterableUnbound select * from pattern[every tag=SupportBean]"; var compiled = env.Compile(epl); env.Deploy(compiled).AddListener("s0"); Assert.AreEqual(StatementType.SELECT, env.Statement("s0").GetProperty(StatementProperty.STATEMENTTYPE)); // Pattern started when created Assert.IsFalse(env.Statement("s0").GetEnumerator().MoveNext()); using (var safe = env.Statement("s0").GetSafeEnumerator()) { Assert.IsFalse(safe.MoveNext()); } // Stop pattern var listener = env.Listener("s0"); listener.Reset(); env.UndeployModuleContaining("s0"); SendEvent(env); Assert.IsFalse(listener.IsInvoked); // Start pattern env.Deploy(compiled).AddListener("s0"); Assert.IsFalse(env.GetEnumerator("s0").MoveNext()); // Send event var theEvent = SendEvent(env); Assert.AreSame(theEvent, env.GetEnumerator("s0").Advance().Get("tag")); using (var safe = env.Statement("s0").GetSafeEnumerator()) { Assert.AreSame(theEvent, safe.Advance().Get("tag")); } // Stop pattern listener = env.Listener("s0"); listener.Reset(); var stmt = env.Statement("s0"); env.UndeployModuleContaining("s0"); SendEvent(env); try { stmt.GetEnumerator(); } catch (IllegalStateException ex) { Assert.AreEqual("Statement has already been undeployed", ex.Message); } Assert.IsFalse(listener.IsInvoked); // Start again, iterator is zero env.Deploy(compiled); Assert.IsFalse(env.GetEnumerator("s0").MoveNext()); env.UndeployAll(); }
public void Run(RegressionEnvironment env) { env.CompileDeploy( "@public create window MyWindow#keepall as SupportBean;\n" + "insert into MyWindow select * from SupportBean;\n"); env.SendEventBean(new SupportBean("E1", 10)); var spi = (EPRuntimeSPI) env.Runtime; var svc = spi.ReflectiveCompileSvc; Assert.IsTrue(svc.IsCompilerAvailable); var compiledFAF = svc.ReflectiveCompileFireAndForget("select * from MyWindow"); var result = env.Runtime.FireAndForgetService.ExecuteQuery(compiledFAF); EPAssertionUtil.AssertPropsPerRow( result.GetEnumerator(), new string[] {"TheString"}, new object[][] { new object[] {"E1"} }); var compiledFromEPL = svc.ReflectiveCompile("@Name('s0') select * from MyWindow"); env.Deploy(compiledFromEPL); EPAssertionUtil.AssertPropsPerRow( env.GetEnumerator("s0"), new string[] {"TheString"}, new object[][] { new object[] {"E1"} }); var module = new Module(); module.Items.Add(new ModuleItem("@Name('s1') select * from MyWindow")); var compiledFromModule = svc.ReflectiveCompile(module); env.Deploy(compiledFromModule); EPAssertionUtil.AssertPropsPerRow( env.GetEnumerator("s1"), new string[] {"TheString"}, new object[][] { new object[] {"E1"} }); var node = svc.ReflectiveCompileExpression("1*1", null, null); Assert.AreEqual(1, node.Forge.ExprEvaluator.Evaluate(null, true, null)); var model = spi.ReflectiveCompileSvc.ReflectiveEPLToModel("select * from MyWindow"); Assert.IsNotNull(model); var moduleParsed = spi.ReflectiveCompileSvc.ReflectiveParseModule("select * from MyWindow"); Assert.AreEqual(1, moduleParsed.Items.Count); Assert.AreEqual("select * from MyWindow", moduleParsed.Items[0].Expression); env.UndeployAll(); }
public void Run(RegressionEnvironment env) { // External clocking SendTimer(0, env); // Set up a timer:within var compiled = env.Compile( "@Name('s0') select * from pattern [(every SupportBean) where timer:within(?::int days ?::int hours ?::int minutes ?::int seconds ?::int milliseconds)]"); env.Deploy( compiled, new DeploymentOptions().WithStatementSubstitutionParameter( prepared => { prepared.SetObject(1, 1); prepared.SetObject(2, 2); prepared.SetObject(3, 3); prepared.SetObject(4, 4); prepared.SetObject(5, 5); })); env.AddListener("s0"); TryAssertion(env); env.UndeployAll(); }
public void Run(RegressionEnvironment env) { var ns = NamespaceGenerator.Create(); var prefix = INLINEDCLASS_PREFIXMAP.Replace("${NAMESPACE}", ns); var eplCreateInlined = "@Name('clazz') @public create " + prefix + ";\n"; var path = new RegressionPath(); env.Compile(eplCreateInlined, path); var epl = "@public @buseventtype create schema PersonEvent(name string, id string);" + "@Name('table') create table TableWithTrie(nameTrie trieState(string));\n" + "into table TableWithTrie select trieEnter(name) as nameTrie from PersonEvent;\n"; var compiledTable = env.Compile(epl, path); env.CompileDeploy(eplCreateInlined); env.Deploy(compiledTable); MakeSendPerson(env, "Andreas", "P1"); MakeSendPerson(env, "Andras", "P2"); MakeSendPerson(env, "Andras", "P3"); MakeSendPerson(env, "And", "P4"); var trie = (SupportTrie <string, IList <object> >)env.GetEnumerator("table").Advance().Get("nameTrie"); Assert.AreEqual(3, trie.PrefixMap("And").Count); // assert dependencies SupportDeploymentDependencies.AssertSingle(env, "table", "clazz", EPObjectType.CLASSPROVIDED, ns + ".TrieAggForge"); env.UndeployAll(); }
public void Run(RegressionEnvironment env) { var expression = "@Name('s0') select * from pattern [every timer:at(?::int,?::int,*,*,[1,2,3,4,5])]"; var dateTimeEx = DateTimeEx.GetInstance(TimeZoneInfo.Utc); dateTimeEx.SetMillis(0); dateTimeEx.Set(2008, 8, 3, 10); // start on a Sunday at 6am, August 3 2008 SendTimer(dateTimeEx.UtcMillis, env); var compiled = env.Compile(expression); env.Deploy( compiled, new DeploymentOptions().WithStatementSubstitutionParameter( prepared => { prepared.SetObject(1, 0); prepared.SetObject(2, 8); })); env.AddListener("s0"); TryAssertion(env); env.UndeployAll(); }
private static void TrySend( RegressionEnvironment env, int numThreads, int numRepeats) { var compiled = env.Compile("@Name('upd') update istream SupportBean set TheString='a'"); var threadPool = Executors.NewFixedThreadPool( numThreads, new SupportThreadFactory(typeof(MultithreadUpdate)).ThreadFactory); var future = new IFuture<object>[numThreads]; for (var i = 0; i < numThreads; i++) { var callable = new StmtUpdateSendCallable(i, env.Runtime, numRepeats); future[i] = threadPool.Submit(callable); } for (var i = 0; i < 50; i++) { env.Deploy(compiled); SupportCompileDeployUtil.ThreadSleep(10); env.UndeployModuleContaining("upd"); } threadPool.Shutdown(); SupportCompileDeployUtil.ExecutorAwait(threadPool, 5, TimeUnit.SECONDS); SupportCompileDeployUtil.AssertFutures(future); }
private static void DeployWithOptionsWUndeploy( RegressionEnvironment env, EPCompiled compiled, DeploymentOptions options) { env.Deploy(compiled, options).UndeployAll(); }
public void Run(RegressionEnvironment env) { var epl = "@Name('s0') select * from SupportBean(IntPrimitive in (1, 10))"; env.CompileDeployAddListenerMile(epl, "s0", 0); SendBeanInt(env, 10); Assert.IsTrue(env.Listener("s0").GetAndClearIsInvoked()); SendBeanInt(env, 11); Assert.IsFalse(env.Listener("s0").GetAndClearIsInvoked()); SendBeanInt(env, 1); Assert.IsTrue(env.Listener("s0").GetAndClearIsInvoked()); env.UndeployAll(); // try enum collection with substitution param ISet<SupportEnum> types = new HashSet<SupportEnum>(); types.Add(SupportEnum.ENUM_VALUE_2); var collectionType = typeof(ICollection<SupportEnum>).CleanName(); var compiled = env.Compile( "@Name('s0') select * from SupportBean ev " + "where ev.EnumValue in (?::`" + collectionType + "`)"); env.Deploy( compiled, new DeploymentOptions().WithStatementSubstitutionParameter( prepared => prepared.SetObject(1, types))); env.AddListener("s0"); var theEvent = new SupportBean(); theEvent.EnumValue = SupportEnum.ENUM_VALUE_2; env.SendEventBean(theEvent); Assert.IsTrue(env.Listener("s0").IsInvoked); env.UndeployAll(); }
public void Run(RegressionEnvironment env) { SendTimer(env, 0); var epl = "@Name('s0') select " + "current_evaluation_context() as c0, " + "current_evaluation_context(), " + "current_evaluation_context().GetRuntimeURI() as c2 from SupportBean"; var resolver = new StatementUserObjectOption(_ => "my_user_object"); var arguments = new CompilerArguments(new Configuration()); arguments.Options.StatementUserObject = resolver; var compiled = env.Compile(soda, epl, arguments); env.Deploy(compiled).AddListener("s0").Milestone(0); Assert.AreEqual(typeof(EPLExpressionEvaluationContext), env.Statement("s0").EventType.GetPropertyType("current_evaluation_context()")); env.SendEventBean(new SupportBean()); var @event = env.Listener("s0").AssertOneGetNewAndReset(); var ctx = (EPLExpressionEvaluationContext)@event.Get("c0"); Assert.AreEqual(env.RuntimeURI, ctx.RuntimeURI); Assert.AreEqual(env.Statement("s0").Name, ctx.StatementName); Assert.AreEqual(-1, ctx.ContextPartitionId); Assert.AreEqual("my_user_object", ctx.StatementUserObject); Assert.AreEqual(env.RuntimeURI, @event.Get("c2")); env.UndeployAll(); }
private static void TryAssertionReturnTypeIsEvents( RegressionEnvironment env, string methodName, AtomicLong milestone) { var path = new RegressionPath(); var compiled = env.CompileWBusPublicType("create schema MyItem(Id string)"); env.Deploy(compiled); path.Add(compiled); env.CompileDeploy( "@Name('s0') select " + methodName + "(TheString).where(v -> v.Id in ('id1', 'id3')) as c0 from SupportBean", path); env.AddListener("s0"); env.SendEventBean(new SupportBean("id0,id1,id2,id3,id4", 0)); var real = env.Listener("s0").AssertOneGetNewAndReset().Get("c0"); var coll = real.Unwrap<IDictionary<string, object>>(); EPAssertionUtil.AssertPropsPerRow( coll.ToArray(), new [] { "Id" }, new[] { new object[] {"id1"}, new object[] {"id3"} }); env.UndeployAll(); }
public void Run(RegressionEnvironment env) { var compiled = env.Compile( "expression myindex {pointregionquadtree(0, 0, 100, 100)}" + "select * from SupportSpatialAABB(point(?::int, ?::int, filterindex:myindex).inside(rectangle(X, Y, Width, Height)))"); var listener = new SupportUpdateListener(); var count = 0; for (var x = 0; x < 10; x++) { for (var y = 0; y < 10; y++) { var finalX = x; var finalY = y; var name = x + "_" + y; var options = new DeploymentOptions().WithStatementSubstitutionParameter( prepared => { prepared.SetObject(1, finalX); prepared.SetObject(2, finalY); }) .WithStatementNameRuntime(ctx => name); env.Deploy(compiled, options).Statement(name).AddListener(listener); // System.out.println("Deployed #" + count); count++; } } SendAssertSpatialAABB(env, listener, 10, 10, 1000); env.UndeployAll(); }
public void Run(RegressionEnvironment env) { var ns = NamespaceGenerator.Create(); var inlined = INLINEDCLASS_CONCAT.Replace("${NAMESPACE}", ns); var eplCreateInlined = "@Name('clazz') @public create " + inlined + ";\n"; var path = new RegressionPath(); env.Compile(eplCreateInlined.Replace("builder.ToString()", "null"), path); var eplSelect = "@Name('s0') select concat(TheString) as c0 from SupportBean"; var compiledSelect = env.Compile(eplSelect, path); env.CompileDeploy(eplCreateInlined); env.Deploy(compiledSelect).AddListener("s0"); SendAssertConcat(env, "A", "A"); env.Milestone(0); SendAssertConcat(env, "B", "A,B"); // assert dependencies SupportDeploymentDependencies.AssertSingle(env, "s0", "clazz", EPObjectType.CLASSPROVIDED, "ConcatAggForge"); env.UndeployAll(); }
public void Run(RegressionEnvironment env) { SupportUpdateListener listener = new SupportUpdateListener(); for (int i = 0; i < 100; i++) { string epl = "@Name('s" + i + "') select * from SupportBean(TheString = '" + i + "' or IntPrimitive=" + i + ")"; EPCompiled compiled = env.Compile(epl); env.Deploy(compiled).Statement("s" + i).AddListener(listener); } var delta = PerformanceObserver.TimeMillis( () => { // System.out.println("Starting " + DateTime.print(new Date())); for (int i = 0; i < 10000; i++) { env.SendEventBean(new SupportBean("100", 1)); Assert.IsTrue(listener.IsInvoked); listener.Reset(); } }); #if DEBUG Assert.That(delta, Is.LessThan(1500)); #else Assert.That(delta, Is.LessThan(500)); #endif env.UndeployAll(); }
private static void TryString( RegressionEnvironment env, EPStatementObjectModel model, string epl, string[] input, bool?[] result) { var compiled = env.Compile(model, new CompilerArguments(env.Configuration)); Assert.AreEqual(epl, model.ToEPL()); var objectmodel = env.EplToModel(epl); objectmodel = SerializableObjectCopier.GetInstance(env.Container).Copy(objectmodel); Assert.AreEqual(epl, objectmodel.ToEPL()); env.Deploy(compiled).AddListener("s0"); Assert.AreEqual(typeof(bool?), env.Statement("s0").EventType.GetPropertyType("result")); for (var i = 0; i < input.Length; i++) { SendSupportBeanEvent(env, input[i]); var theEvent = env.Listener("s0").AssertOneGetNewAndReset(); Assert.AreEqual(result[i], theEvent.Get("result"), "Wrong result for " + input[i]); } env.UndeployAll(); }
// Compares the performance of // select * from SupportBean(TheString = 'xyz') // against // select * from SupportBean where theString = 'xyz' public void Run(RegressionEnvironment env) { var module = new StringWriter(); for (var i = 0; i < 100; i++) { var epl = string.Format( "@Name('s{0}') select * from SupportBean where TheString = '{1}';\n", i, Convert.ToString(i)); module.Write(epl); } var compiled = env.Compile(module.ToString()); env.Deploy(compiled); var start = PerformanceObserver.MilliTime; for (var i = 0; i < 10000; i++) { var bean = new SupportBean("NOMATCH", 0); env.SendEventBean(bean); } var end = PerformanceObserver.MilliTime; var delta = end - start; Assert.That(delta, Is.LessThan(500), "Delta=" + delta); env.UndeployAll(); }
public void Update( object sender, UpdateEventArgs eventArgs) { isCalled = true; // create statement for thread - this can be called multiple times as other threads send SupportBean env.Deploy(compiled); var listener = new SupportMTUpdateListener(); env.Statement("t" + numThread).AddListener(listener); object theEvent = new SupportMarketDataBean("", 0, numThread, null); env.SendEventBean(theEvent, theEvent.GetType().Name); env.UndeployModuleContaining("t" + numThread); var eventsReceived = listener.GetNewDataListFlattened(); var found = false; for (var i = 0; i < eventsReceived.Length; i++) { if (eventsReceived[i].Underlying == theEvent) { found = true; } } Assert.IsTrue(found); }
public void Run(RegressionEnvironment env) { var stmtText = "@Name('s0') select P00 like P01 as r1, " + "P00 like P01 escape \"!\" as r2, " + "P02 regexp P03 as r3 " + "from SupportBean_S0"; var model = new EPStatementObjectModel(); model.Annotations = Collections.SingletonList(AnnotationPart.NameAnnotation("s0")); model.SelectClause = SelectClause.Create() .Add(Expressions.Like(Expressions.Property("P00"), Expressions.Property("P01")), "r1") .Add(Expressions.Like(Expressions.Property("P00"), Expressions.Property("P01"), Expressions.Constant("!")), "r2") .Add(Expressions.Regexp(Expressions.Property("P02"), Expressions.Property("P03")), "r3"); model.FromClause = FromClause.Create(FilterStream.Create("SupportBean_S0")); model = SerializableObjectCopier.GetInstance(env.Container).Copy(model); Assert.AreEqual(stmtText, model.ToEPL()); var compiled = env.Compile(model, new CompilerArguments(env.Configuration)); env.Deploy(compiled).AddListener("s0").Milestone(0); RunLikeRegexStringAndNull(env); env.UndeployAll(); }
public void Run(RegressionEnvironment env) { // External clocking SendTimer(0, env); // Set up a timer:within var compiled = env .Compile("@Name('s0') select * from pattern [timer:interval(?::int minute ?::int seconds)]"); env.Deploy( compiled, new DeploymentOptions().WithStatementSubstitutionParameter( prepared => { prepared.SetObject(1, 1); prepared.SetObject(2, 2); })); env.AddListener("s0"); SendTimer(62 * 1000 - 1, env); Assert.IsFalse(env.Listener("s0").IsInvoked); SendTimer(62 * 1000, env); Assert.IsTrue(env.Listener("s0").IsInvoked); env.UndeployAll(); }
public void Run(RegressionEnvironment env) { var text = "module test.test1;\n" + "create schema MyTypeOne(col1 string, col2 int);" + "create window MyWindowOne#keepall as select * from MyTypeOne;" + "insert into MyWindowOne select * from MyTypeOne;"; env.CompileDeploy(text).UndeployAll(); env.CompileDeploy(text).UndeployAll(); text = "module test.test1;\n" + "create schema MyTypeOne(col1 string, col2 int, col3 long);" + "create window MyWindowOne#keepall as select * from MyTypeOne;" + "insert into MyWindowOne select * from MyTypeOne;"; env.CompileDeploy(text).UndeployAll(); Assert.AreEqual(0, SupportFilterServiceHelper.GetFilterSvcCountApprox(env)); // test on-merge var moduleString = "@Name('S0') create window MyWindow#unique(IntPrimitive) as SupportBean;\n" + "@Name('S1') on MyWindow insert into SecondStream select *;\n" + "@Name('S2') on SecondStream merge MyWindow when matched then insert into ThirdStream select * then delete\n"; var compiled = env.Compile(moduleString); env.Deploy(compiled).UndeployAll().Deploy(compiled).UndeployAll(); // test table var moduleTableOne = "create table MyTable(c0 string, c1 string)"; env.CompileDeploy(moduleTableOne).UndeployAll(); var moduleTableTwo = "create table MyTable(c0 string, c1 string, c2 string)"; env.CompileDeploy(moduleTableTwo).UndeployAll(); }
public void Run(RegressionEnvironment env) { string epl = "@Name('s0') select * from SupportBean(TheString = ?::string)"; EPCompiled compiled = env.Compile(epl); DeploymentOptions options = new DeploymentOptions(); options.WithStatementSubstitutionParameter(opt => opt.SetObject(1, "ax")); env.Deploy(compiled, options).AddListener("s0"); RunAssertionSB(env, epl, EQUAL); }
public void Run(RegressionEnvironment env) { var path = new RegressionPath(); string epl; EPCompiled compiled; env.CompileDeploy("create table MyTable (col1 string primary key, col2 string)", path); epl = "create index MyIndexOnTable on MyTable(col2)"; compiled = env.Compile(epl, path); env.Deploy(compiled); TryInvalidDeploy(env, compiled, "An index by name 'MyIndexOnTable'", MODULE_NAME_UNNAMED); env.CompileDeploy("create window MyWindow#keepall as SupportBean", path); epl = "create index MyIndexOnNW on MyWindow(IntPrimitive)"; compiled = env.Compile(epl, path); env.Deploy(compiled); TryInvalidDeploy(env, compiled, "An index by name 'MyIndexOnNW'", MODULE_NAME_UNNAMED); env.UndeployAll(); }
public void Run(RegressionEnvironment env) { var compiled = env.Compile("@Name('s0') select * from SupportBean"); var listener = new MyUnmatchedListener(); env.EventService.UnmatchedListener = listener.Update; // no statement, should be unmatched var theEvent = SendEvent(env, "E1"); Assert.AreEqual(1, listener.Received.Count); Assert.AreSame(theEvent, listener.Received[0].Underlying); listener.Reset(); // no unmatched listener env.EventService.UnmatchedListener = null; SendEvent(env, "E1"); Assert.AreEqual(0, listener.Received.Count); // create statement and re-register unmatched listener env.Deploy(compiled); env.EventService.UnmatchedListener = listener.Update; SendEvent(env, "E1"); Assert.AreEqual(0, listener.Received.Count); // stop statement env.UndeployModuleContaining("s0"); theEvent = SendEvent(env, "E1"); Assert.AreEqual(1, listener.Received.Count); Assert.AreSame(theEvent, listener.Received[0].Underlying); listener.Reset(); // start statement env.Deploy(compiled); SendEvent(env, "E1"); Assert.AreEqual(0, listener.Received.Count); // destroy statement env.UndeployModuleContaining("s0"); theEvent = SendEvent(env, "E1"); Assert.AreEqual(1, listener.Received.Count); Assert.AreSame(theEvent, listener.Received[0].Underlying); }
public void Run(RegressionEnvironment env) { env.CompileDeploy("@public @buseventtype create json schema SimpleJson(fruit string, size string, color string)"); string epl = "@Name('s0') select fruit, size, color from SimpleJson#keepall"; EPCompiled compiled = env.Compile(epl, new CompilerArguments(env.Runtime.RuntimePath)); env.Deploy(compiled).AddListener("s0"); RunAssertionSimple(env); env.UndeployAll(); }
private static void RunAssertionDisambiguate( RegressionEnvironment env, string firstEpl, string secondEpl, string useEpl, Runnable assertion) { var first = env.Compile("module a;\n @public " + firstEpl + "\n"); var second = env.Compile("module b;\n @public " + secondEpl + "\n"); env.Deploy(first); env.Deploy(second); var path = new RegressionPath(); path.Add(first); path.Add(second); env.CompileDeploy("uses b;\n @name('s0') " + useEpl + "\n", path).AddListener("s0"); assertion.Invoke(); env.UndeployAll(); }
public void Run(RegressionEnvironment env) { var stmtText = "@Name('s0') select mychar from " + "SupportBean_S0 as S0," + " sql:MyDBWithRetain ['select mychar from mytesttable where ${Id} = mytesttable.myBigint'] as S1"; var compiled = env.Compile(stmtText); env.Deploy(compiled); // Too many connections unless the stop actually relieves them for (var i = 0; i < 100; i++) { env.UndeployModuleContaining("s0"); SendEventS0(env, 1); env.Deploy(compiled).AddListener("s0"); SendEventS0(env, 1); Assert.AreEqual("Z", env.Listener("s0").AssertOneGetNewAndReset().Get("mychar")); } env.UndeployAll(); }
public void Run(RegressionEnvironment env) { string epl = "create schema MANE as MyAutoNameEvent;\n" + "@Name('s0') select P0 from MANE;\n"; EPCompiled compiled = env.CompileWBusPublicType(epl); env.Deploy(compiled).AddListener("s0"); env.SendEventBean(new MyAutoNameEvent("test"), "MANE"); Assert.AreEqual("test", env.Listener("s0").AssertOneGetNewAndReset().Get("P0")); env.UndeployAll(); }
private static void TryPattern( RegressionEnvironment env, string pattern, int numThreads, int numEvents) { var sendLock = new object(); var executor = Executors.NewMultiThreadedExecutor(numThreads); // new SupportThreadFactory(typeof(MultithreadStmtPattern)).ThreadFactory); var futures = new List<IFuture<object>>(); var callables = new SendEventWaitCallable[numThreads]; for (var i = 0; i < numThreads; i++) { callables[i] = new SendEventWaitCallable(i, env.Runtime, sendLock, new GeneratorEnumerator(numEvents)); futures.Add(executor.Submit(callables[i])); } var listener = new SupportMTUpdateListener[numEvents]; var epl = "select * from pattern[" + pattern + "]"; var compiled = env.Compile(epl); for (var i = 0; i < numEvents; i++) { var stmtName = "p" + i; env.Deploy(compiled, new DeploymentOptions().WithStatementNameRuntime(ctx => stmtName)); var stmt = env.Statement(stmtName); listener[i] = new SupportMTUpdateListener(); stmt.AddListener(listener[i]); lock (sendLock) { Monitor.PulseAll(sendLock); } } foreach (var callable in callables) { callable.Shutdown(); } lock (sendLock) { Monitor.PulseAll(sendLock); } executor.Shutdown(); SupportCompileDeployUtil.ExecutorAwait(executor, TimeSpan.FromSeconds(10)); for (var i = 0; i < numEvents; i++) { var theEventReceived = listener[i].AssertOneGetNewAndReset(); Assert.NotNull(theEventReceived); var theEventValue = theEventReceived.Get("a"); Assert.NotNull(theEventValue); Assert.IsInstanceOf<SupportBean>(theEventValue); } env.UndeployAll(); }
public void Run(RegressionEnvironment env) { env.AdvanceTime(0); var text = "select rstream TheString from SupportBean#time(?::int)"; var compiled = env.Compile(text); env.Deploy( compiled, new DeploymentOptions() .WithStatementSubstitutionParameter(prepared => prepared.SetObject(1, 4)) .WithStatementNameRuntime(ctx => "s0")); env.Deploy( compiled, new DeploymentOptions() .WithStatementSubstitutionParameter(prepared => prepared.SetObject(1, 3)) .WithStatementNameRuntime(ctx => "s1")); env.AddListener("s0").AddListener("s1"); RunAssertion(env); env.UndeployAll(); }