private static void TryMT( RegressionEnvironment env, int numEvents) { var epl = "create table varTotal (key string primary key, total sum(int));\n" + "into table varTotal select TheString, sum(IntPrimitive) as total from SupportBean group by TheString;\n" + "@Name('s0') select varTotal[P00].total as c0 from SupportBean_S0;\n"; env.CompileDeploy(epl).AddListener("s0"); env.SendEventBean(new SupportBean("A", 10)); var queueCreated = new LinkedBlockingQueue<string>(); var writeRunnable = new WriteRunnable(env, numEvents, queueCreated); var readRunnable = new ReadRunnable(env, numEvents, queueCreated); // start var t1 = new Thread(writeRunnable.Run); t1.Name = typeof(InfraTableMTGroupedAccessReadIntoTableWriteNewRowCreation).Name + "-write"; var t2 = new Thread(readRunnable.Run); t2.Name = typeof(InfraTableMTGroupedAccessReadIntoTableWriteNewRowCreation).Name + "-read"; t1.Start(); t2.Start(); // join log.Info("Waiting for completion"); t1.Join(); t2.Join(); env.UndeployAll(); Assert.IsNull(writeRunnable.Exception); Assert.IsNull(readRunnable.Exception); }
private static void TryMT( RegressionEnvironment env, int numSeconds) { var path = new RegressionPath(); var eplCreateVariable = "create table vartotal (topgroup int primary key, subgroup int primary key)"; env.CompileDeploy(eplCreateVariable, path); var eplCreateIndex = "create index myindex on vartotal (topgroup)"; env.CompileDeploy(eplCreateIndex, path); // insert and delete merge var eplMergeInsDel = "on SupportTopGroupSubGroupEvent as lge merge vartotal as vt " + "where vt.topgroup = lge.Topgroup and vt.subgroup = lge.Subgroup " + "when not matched and lge.Op = 'insert' then insert select lge.Topgroup as topgroup, lge.Subgroup as subgroup " + "when matched and lge.Op = 'delete' then delete"; env.CompileDeploy(eplMergeInsDel, path); // seed with {0, 0} group env.SendEventBean(new SupportTopGroupSubGroupEvent(0, 0, "insert")); // select/read var eplSubselect = "@Name('s0') select (select count(*) from vartotal where topgroup=sb.IntPrimitive) as c0 " + "from SupportBean as sb"; env.CompileDeploy(eplSubselect, path).AddListener("s0"); var writeRunnable = new WriteRunnable(env); var readRunnable = new ReadRunnable(env, env.Listener("s0")); // start var writeThread = new Thread(writeRunnable.Run); writeThread.Name = typeof(InfraTableMTGroupedSubqueryReadMergeWriteSecondaryIndexUpd).Name + "-write"; var readThread = new Thread(readRunnable.Run); readThread.Name = typeof(InfraTableMTGroupedSubqueryReadMergeWriteSecondaryIndexUpd).Name + "-read"; writeThread.Start(); readThread.Start(); // wait Thread.Sleep(numSeconds * 1000); // shutdown writeRunnable.Shutdown = true; readRunnable.Shutdown = true; // join log.Info("Waiting for completion"); writeThread.Join(); readThread.Join(); env.UndeployAll(); Assert.IsNull(writeRunnable.Exception); Assert.IsNull(readRunnable.Exception); Assert.IsTrue(writeRunnable.numLoops > 100); Assert.IsTrue(readRunnable.numQueries > 100); Console.Out.WriteLine( "Send " + writeRunnable.numLoops + " and performed " + readRunnable.numQueries + " reads"); }
private static void TryMT( RegressionEnvironment env, int numGroups, int numSeconds) { var path = new RegressionPath(); var eplCreateVariable = "create table vartotal (key string primary key, " + CollectionUtil.ToString(GetDeclareCols()) + ")"; env.CompileDeploy(eplCreateVariable, path); var eplInto = "into table vartotal select " + CollectionUtil.ToString(GetIntoCols()) + " from Support10ColEvent group by GroupKey"; env.CompileDeploy(eplInto, path); // initialize groups var groups = new string[numGroups]; for (var i = 0; i < numGroups; i++) { groups[i] = "G" + i; env.SendEventBean(new Support10ColEvent(groups[i], 0)); } var writeRunnable = new WriteRunnable(env, groups); var readRunnable = new ReadRunnable(env, path, groups); // start var t1 = new Thread(writeRunnable.Run) { Name = typeof(InfraTableMTGroupedAccessReadIntoTableWriteAggColConsistency).Name + "-write" }; var t2 = new Thread(readRunnable.Run) { Name = typeof(InfraTableMTGroupedAccessReadIntoTableWriteAggColConsistency).Name + "-read" }; t1.Start(); t2.Start(); // wait Thread.Sleep(numSeconds * 1000); // shutdown writeRunnable.Shutdown = true; readRunnable.Shutdown = true; // join log.Info("Waiting for completion"); t1.Join(); t2.Join(); env.UndeployAll(); Assert.IsNull(writeRunnable.Exception); Assert.IsNull(readRunnable.Exception); Assert.IsTrue(writeRunnable.numEvents > 100); Assert.IsTrue(readRunnable.numQueries > 100); Console.Out.WriteLine( "Send " + writeRunnable.numEvents + " and performed " + readRunnable.numQueries + " reads"); }
private static void TryMT( RegressionEnvironment env, int numSeconds) { var epl = "create table MyTable (p0 string, p1 string, p2 string, p3 string, p4 string);\n" + "on SupportBean merge MyTable " + " when not matched then insert select '1' as p0, '1' as p1, '1' as p2, '1' as p3, '1' as p4;\n" + "on SupportBean_S0 merge MyTable " + " when matched then update set p0=P00, p1=P00, p2=P00, p3=P00, p4=P00;\n" + "@Name('out') select p0 from SupportBean_S1 unidirectional, MyTable where " + "(p0='1' and p1='1' and p2='1' and p3='1' and p4='1')" + " or (p0='2' and p1='2' and p2='2' and p3='2' and p4='2')" + ";\n"; env.CompileDeploy(epl); // preload env.SendEventBean(new SupportBean()); var writeRunnable = new UpdateWriteRunnable(env); var readRunnable = new ReadRunnable(env); // start var threadWrite = new Thread(writeRunnable.Run) { Name = typeof(InfraTableMTUngroupedJoinColumnConsistency).Name + "-write" }; var threadRead = new Thread(readRunnable.Run) { Name = typeof(InfraTableMTUngroupedJoinColumnConsistency).Name + "-read" }; threadWrite.Start(); threadRead.Start(); // wait Thread.Sleep(numSeconds * 1000); // shutdown writeRunnable.Shutdown = true; readRunnable.Shutdown = true; // join log.Info("Waiting for completion"); threadWrite.Join(); threadRead.Join(); env.UndeployAll(); Assert.IsNull(writeRunnable.Exception); Assert.IsNull(readRunnable.Exception); Console.Out.WriteLine( "Write loops " + writeRunnable.numLoops + " and performed " + readRunnable.numQueries + " reads"); Assert.IsTrue(writeRunnable.numLoops > 1); Assert.IsTrue(readRunnable.numQueries > 100); }
private static void TryMT( RegressionEnvironment env, int numSeconds) { var epl = "create table MyTable (key1 string primary key, value int);\n" + "create index MyIndex on MyTable (value);\n" + "on SupportBean merge MyTable where TheString = key1 when not matched then insert select TheString as key1, IntPrimitive as value;\n" + "@Name('out') select * from SupportBean_S0, MyTable where value = Id;\n" + "on SupportBean_S1 delete from MyTable where key1 like 'B%';\n"; env.CompileDeploy(epl).AddListener("out"); // preload A_n events for (var i = 0; i < NUM_KEYS; i++) { env.SendEventBean(new SupportBean("A_" + i, i)); } var writeRunnable = new WriteRunnable(env); var readRunnable = new ReadRunnable(env); // start var threadWrite = new Thread(writeRunnable.Run) { Name = typeof(InfraTableMTGroupedJoinReadMergeWriteSecondaryIndexUpd).Name + "-write" }; var threadRead = new Thread(readRunnable.Run) { Name = typeof(InfraTableMTGroupedJoinReadMergeWriteSecondaryIndexUpd).Name + "-read" }; threadWrite.Start(); threadRead.Start(); // wait Thread.Sleep(numSeconds * 1000); // shutdown writeRunnable.Shutdown = true; readRunnable.Shutdown = true; // join log.Info("Waiting for completion"); threadWrite.Join(); threadRead.Join(); env.UndeployAll(); Assert.IsNull(writeRunnable.Exception); Assert.IsNull(readRunnable.Exception); Console.Out.WriteLine( "Write loops " + writeRunnable.numLoops + " and performed " + readRunnable.numQueries + " reads"); Assert.IsTrue(writeRunnable.numLoops > 1); Assert.IsTrue(readRunnable.numQueries > 100); }
private static void TryMT( RegressionEnvironment env, int numSeconds, int numWriteThreads) { var path = new RegressionPath(); var eplCreateVariable = "create table varagg (c0 int, c1 int, c2 int, c3 int, c4 int, c5 int)"; env.CompileDeploy(eplCreateVariable, path); var eplMerge = "on SupportBean_S0 merge varagg " + "when not matched then insert select -1 as c0, -1 as c1, -1 as c2, -1 as c3, -1 as c4, -1 as c5 " + "when matched then update set c0=Id, c1=Id, c2=Id, c3=Id, c4=Id, c5=Id"; env.CompileDeploy(eplMerge, path); var eplQuery = "@Name('s0') select varagg.c0 as c0, varagg.c1 as c1, varagg.c2 as c2," + "varagg.c3 as c3, varagg.c4 as c4, varagg.c5 as c5 from SupportBean_S1"; env.CompileDeploy(eplQuery, path).AddListener("s0"); var writeThreads = new Thread[numWriteThreads]; var writeRunnables = new WriteRunnable[numWriteThreads]; for (var i = 0; i < writeThreads.Length; i++) { writeRunnables[i] = new WriteRunnable(env, i); writeThreads[i] = new Thread(writeRunnables[i].Run) { Name = typeof(InfraTableMTUngroupedAccessReadMergeWrite).Name + "-write" }; writeThreads[i].Start(); } var readRunnable = new ReadRunnable(env, env.Listener("s0")); var readThread = new Thread(readRunnable.Run) { Name = typeof(InfraTableMTUngroupedAccessReadMergeWrite).Name + "-read" }; readThread.Start(); Thread.Sleep(numSeconds * 1000); // join log.Info("Waiting for completion"); for (var i = 0; i < writeThreads.Length; i++) { writeRunnables[i].Shutdown = true; writeThreads[i].Join(); Assert.IsNull(writeRunnables[i].Exception); } readRunnable.Shutdown = true; readThread.Join(); env.UndeployAll(); Assert.IsNull(readRunnable.Exception); }
private static void TryMT( RegressionEnvironment env, int numSeconds) { var path = new RegressionPath(); var eplCreateVariable = "create table MyTable (pkey string primary key)"; env.CompileDeploy(eplCreateVariable, path); var eplInsertInto = "insert into MyTable select TheString as pkey from SupportBean"; env.CompileDeploy(eplInsertInto, path); // seed with count 1 env.SendEventBean(new SupportBean("E0", 0)); // select/read var eplSubselect = "@Name('s0') select (select count(*) from MyTable) as c0 from SupportBean_S0"; env.CompileDeploy(eplSubselect, path).AddListener("s0"); var writeRunnable = new WriteRunnable(env); var readRunnable = new ReadRunnable(env, env.Listener("s0")); // start var writeThread = new Thread(writeRunnable.Run); writeThread.Name = typeof(InfraTableMTGroupedSubqueryReadInsertIntoWriteConcurr).Name + "-write"; var readThread = new Thread(readRunnable.Run); readThread.Name = typeof(InfraTableMTGroupedSubqueryReadInsertIntoWriteConcurr).Name + "-read"; writeThread.Start(); readThread.Start(); // wait Thread.Sleep(numSeconds * 1000); // shutdown writeRunnable.Shutdown = true; readRunnable.Shutdown = true; // join log.Info("Waiting for completion"); writeThread.Join(); readThread.Join(); env.UndeployAll(); Assert.IsNull(writeRunnable.Exception); Assert.IsNull(readRunnable.Exception); Assert.IsTrue(writeRunnable.numLoops > 100); Assert.IsTrue(readRunnable.numQueries > 100); Console.Out.WriteLine( "Send " + writeRunnable.numLoops + " and performed " + readRunnable.numQueries + " reads"); }
private static void TryMT( RegressionEnvironment env, int numSeconds) { var path = new RegressionPath(); var eplCreateVariable = "create table vartotal (total sum(int))"; env.CompileDeploy(eplCreateVariable, path); var eplInto = "into table vartotal select sum(IntPrimitive) as total from SupportBean"; env.CompileDeploy(eplInto, path); env.CompileDeploy("@Name('s0') select * from SupportBean_S0(1 = vartotal.total)", path).AddListener("s0"); env.CompileDeploy("@Name('s1') select * from SupportBean_S0(0 = vartotal.total)", path).AddListener("s1"); var writeRunnable = new WriteRunnable(env); var readRunnable = new ReadRunnable(env, env.Listener("s0"), env.Listener("s1")); // start var t1 = new Thread(writeRunnable.Run) { Name = typeof(InfraTableMTUngroupedAccessReadIntoTableWriteFilterUse).Name + "-write" }; var t2 = new Thread(readRunnable.Run) { Name = typeof(InfraTableMTUngroupedAccessReadIntoTableWriteFilterUse).Name + "-read" }; t1.Start(); t2.Start(); // wait Thread.Sleep(numSeconds * 1000); // shutdown writeRunnable.Shutdown = true; readRunnable.Shutdown = true; // join log.Info("Waiting for completion"); t1.Join(); t2.Join(); env.UndeployAll(); Assert.IsNull(writeRunnable.Exception); Assert.IsNull(readRunnable.Exception); Assert.IsTrue(writeRunnable.numEvents > 100); Assert.IsTrue(readRunnable.numQueries > 100); Console.Out.WriteLine( "Send " + writeRunnable.numEvents + " and performed " + readRunnable.numQueries + " reads"); }
private static void TryMT( RegressionEnvironment env, int numSeconds) { var path = new RegressionPath(); var eplCreateVariable = "create table vartotal (cnt count(*), sumint sum(int), avgint avg(int))"; env.CompileDeploy(eplCreateVariable, path); var eplInto = "into table vartotal select count(*) as cnt, sum(IntPrimitive) as sumint, avg(IntPrimitive) as avgint from SupportBean"; env.CompileDeploy(eplInto, path); env.CompileDeploy("create window MyWindow#lastevent as SupportBean_S0", path); env.CompileDeploy("insert into MyWindow select * from SupportBean_S0", path); env.SendEventBean(new SupportBean_S0(0)); var writeRunnable = new WriteRunnable(env); var readRunnable = new ReadRunnable(env, path); // start var t1 = new Thread(writeRunnable.Run); t1.Name = typeof(InfraTableMTUngroupedAccessWithinRowFAFConsistency).Name + "-write"; var t2 = new Thread(readRunnable.Run); t2.Name = typeof(InfraTableMTUngroupedAccessWithinRowFAFConsistency).Name + "-read"; t1.Start(); t2.Start(); // wait Thread.Sleep(numSeconds * 1000); // shutdown writeRunnable.Shutdown = true; readRunnable.Shutdown = true; // join log.Info("Waiting for completion"); t1.Join(); t2.Join(); Assert.IsNull(writeRunnable.Exception); Assert.IsNull(readRunnable.Exception); log.Info("Send " + writeRunnable.numEvents + " and performed " + readRunnable.numQueries + " reads"); Assert.IsTrue(writeRunnable.numEvents > 100); Assert.IsTrue(readRunnable.numQueries > 20); env.UndeployAll(); }
private static void TryMT( RegressionEnvironment env, int numReadThreads, int numSeconds) { var path = new RegressionPath(); var eplCreateVariable = "create table vartotal (S0 sum(int), S1 sum(double), S2 sum(long))"; env.CompileDeploy(eplCreateVariable, path); var eplInto = "into table vartotal select " + "sum(IntPrimitive) as S0, " + "sum(DoublePrimitive) as S1, " + "sum(LongPrimitive) as S2 " + "from SupportBean"; env.CompileDeploy(eplInto, path); env.SendEventBean(MakeSupportBean("E", 1, 1, 1)); env.CompileDeploy( "@Name('iterate') select vartotal.S0 as c0, vartotal.S1 as c1, vartotal.S2 as c2 from SupportBean_S0#lastevent", path); env.SendEventBean(new SupportBean_S0(0)); // setup writer var writeRunnable = new WriteRunnable(env); var writeThread = new Thread(writeRunnable.Run) { Name = typeof(InfraTableMTUngroupedAccessReadInotTableWriteIterate).Name + "-write" }; // setup readers var readThreads = new Thread[numReadThreads]; var readRunnables = new ReadRunnable[numReadThreads]; for (var i = 0; i < readThreads.Length; i++) { readRunnables[i] = new ReadRunnable(env.Statement("iterate")); readThreads[i] = new Thread(readRunnables[i].Run) { Name = typeof(InfraTableMTUngroupedAccessReadInotTableWriteIterate).Name + "-read" }; } // start foreach (var readThread in readThreads) { readThread.Start(); } writeThread.Start(); // wait Thread.Sleep(numSeconds * 1000); // shutdown writeRunnable.Shutdown = true; foreach (var readRunnable in readRunnables) { readRunnable.Shutdown = true; } // join log.Info("Waiting for completion"); writeThread.Join(); foreach (var readThread in readThreads) { readThread.Join(); } env.UndeployAll(); // assert Assert.IsNull(writeRunnable.Exception); Assert.IsTrue(writeRunnable.numEvents > 100); foreach (var readRunnable in readRunnables) { Assert.IsNull(readRunnable.Exception); Assert.IsTrue(readRunnable.numQueries > 100); } }
private static void TryMT( RegressionEnvironment env, int numSeconds) { var path = new RegressionPath(); var eplCreateVariable = "create table vartotal (topgroup int primary key, subgroup int primary key, thecnt count(*))"; env.CompileDeploy(eplCreateVariable, path); var eplCreateIndex = "create index myindex on vartotal (topgroup)"; env.CompileDeploy(eplCreateIndex, path); // populate var eplInto = "into table vartotal select count(*) as thecnt from SupportTopGroupSubGroupEvent#length(100) group by Topgroup, Subgroup"; env.CompileDeploy(eplInto, path); // delete empty groups var eplDelete = "on SupportBean_S0 merge vartotal when matched and thecnt = 0 then delete"; env.CompileDeploy(eplDelete, path); // seed with {0, 0} group env.SendEventBean(new SupportTopGroupSubGroupEvent(0, 0)); // select/read var eplMergeSelect = "on SupportBean merge vartotal as vt " + "where vt.topgroup = IntPrimitive and vt.thecnt > 0 " + "when matched then insert into MyOutputStream select *"; env.CompileDeploy(eplMergeSelect, path); env.CompileDeploy("@Name('s0') select * from MyOutputStream", path).AddListener("s0"); var listener = env.Listener("s0"); var writeRunnable = new WriteRunnable(env); var readRunnable = new ReadRunnable(env, listener); // start var writeThread = new Thread(writeRunnable.Run); writeThread.Name = typeof(InfraTableMTGroupedMergeReadMergeWriteSecondaryIndexUpd).Name + "-write"; var readThread = new Thread(readRunnable.Run); readThread.Name = typeof(InfraTableMTGroupedMergeReadMergeWriteSecondaryIndexUpd).Name + "-read"; writeThread.Start(); readThread.Start(); // wait Thread.Sleep(numSeconds * 1000); // shutdown writeRunnable.Shutdown = true; readRunnable.Shutdown = true; // join log.Info("Waiting for completion"); writeThread.Join(); readThread.Join(); Assert.IsNull(writeRunnable.Exception); Assert.IsNull(readRunnable.Exception); Assert.IsTrue(writeRunnable.numEvents > 100); Assert.IsTrue(readRunnable.numQueries > 100); Console.Out.WriteLine( "Send " + writeRunnable.numEvents + " and performed " + readRunnable.numQueries + " reads"); env.UndeployAll(); }
private static void TryMT( RegressionEnvironment env, int numSeconds, bool grouped) { var path = new RegressionPath(); var eplCreateTable = "create table MyTable (key string " + (grouped ? "primary key" : "") + ", p0 int, p1 int, p2 int, p3 int, p4 int, p5 int)"; env.CompileDeploy(eplCreateTable, path); var eplSelect = grouped ? "@Name('s0') select MyTable['K1'].p0 as c0, MyTable['K1'].p1 as c1, MyTable['K1'].p2 as c2, " + "MyTable['K1'].p3 as c3, MyTable['K1'].p4 as c4, MyTable['K1'].p5 as c5 from SupportBean_S0" : "@Name('s0') select MyTable.p0 as c0, MyTable.p1 as c1, MyTable.p2 as c2, " + "MyTable.p3 as c3, MyTable.p4 as c4, MyTable.p5 as c5 from SupportBean_S0"; env.CompileDeploy(eplSelect, path).AddListener("s0"); var eplMerge = "on SupportBean merge MyTable " + "when not matched then insert select 'K1' as key, 1 as p0, 1 as p1, 1 as p2, 1 as p3, 1 as p4, 1 as p5 " + "when matched then delete"; env.CompileDeploy(eplMerge, path); var writeRunnable = new WriteRunnable(env); var readRunnable = new ReadRunnable(env, env.Listener("s0")); // start var t1 = new Thread(writeRunnable.Run); t1.Name = typeof(InfraTableMTAccessReadMergeWriteInsertDeleteRowVisible).Name + "-write"; var t2 = new Thread(readRunnable.Run); t2.Name = typeof(InfraTableMTAccessReadMergeWriteInsertDeleteRowVisible).Name + "Read"; t1.Start(); t2.Start(); // wait Thread.Sleep(numSeconds * 1000); // shutdown writeRunnable.Shutdown = true; readRunnable.Shutdown = true; // join log.Info("Waiting for completion"); t1.Join(); t2.Join(); Assert.IsNull(writeRunnable.Exception); Assert.IsTrue(writeRunnable.numEvents > 100); Assert.IsNull(readRunnable.Exception); Assert.IsTrue(readRunnable.numQueries > 100); Assert.IsTrue(readRunnable.NotFoundCount > 2); Assert.IsTrue(readRunnable.FoundCount > 2); Console.Out.WriteLine( "Send " + writeRunnable.numEvents + " and performed " + readRunnable.numQueries + " reads (found " + readRunnable.FoundCount + ") (not found " + readRunnable.NotFoundCount + ")"); env.UndeployAll(); }