public void Run(Configuration configuration) { idCounter = new AtomicLong(0); executorService = Executors.NewCachedThreadPool(); noActionUpdateListener = new NoActionUpdateListener(); configuration.Runtime.Threading.IsInternalTimerEnabled = true; configuration.Common.AddEventType(typeof(SupportBean)); configuration.Runtime.Threading.InsertIntoDispatchLocking = Locking.SUSPEND; var runtime = EPRuntimeProvider.GetRuntime(GetType().Name, configuration); runtime.Initialize(); epRuntime = runtime.EventService; var path = new RegressionPath(); var epl = "insert into Stream1 select count(*) as cnt from SupportBean#time(7 sec)"; var compiled = SupportCompileDeployUtil.Compile(epl, configuration, path); path.Add(compiled); SupportCompileDeployUtil.Deploy(compiled, runtime); epl = epl + " output every 10 seconds"; compiled = SupportCompileDeployUtil.Compile(epl, configuration, path); SupportCompileDeployUtil.DeployAddListener(compiled, "insert", noActionUpdateListener, runtime); var sendTickEventRunnable = new SendEventRunnable(this, 10000); Start(sendTickEventRunnable, 4); // Adjust here for long-running test SupportCompileDeployUtil.ThreadSleep(3000); sendTickEventRunnable.Shutdown = true; executorService.Shutdown(); SupportCompileDeployUtil.ExecutorAwait(executorService, 1, TimeUnit.SECONDS); runtime.Destroy(); }
public void Run(RegressionEnvironment env) { var epl = "create schema ScoreCycle (userId string, keyword string, ProductId string, score long);\n" + "\n" + "create schema UserKeywordTotalStream (userId string, keyword string, sumScore long);\n" + "\n" + "create context HashByUserCtx as\n" + "coalesce by consistent_hash_crc32(userId) from ScoreCycle,\n" + "consistent_hash_crc32(userId) from UserKeywordTotalStream \n" + "granularity 10000000;\n" + "\n" + "context HashByUserCtx create window ScoreCycleWindow#unique(userId, keyword, ProductId) as ScoreCycle;\n" + "\n" + "context HashByUserCtx insert into ScoreCycleWindow select * from ScoreCycle;\n" + "\n" + "@Name('Select') context HashByUserCtx insert into UserKeywordTotalStream\n" + "select userId, keyword, sum(score) as sumScore from ScoreCycleWindow group by userId, keyword;"; env.CompileDeployWBusPublicType(epl, new RegressionPath()); var listener = new MyUpdateListener(); env.Statement("Select").AddListener(listener); IList<IDictionary<string, object>> sendsT1 = new List<IDictionary<string, object>>(); sendsT1.Add(MakeEvent("A", "house", "P0", 1)); sendsT1.Add(MakeEvent("B", "house", "P0", 2)); IList<IDictionary<string, object>> sendsT2 = new List<IDictionary<string, object>>(); sendsT2.Add(MakeEvent("B", "house", "P0", 3)); sendsT1.Add(MakeEvent("A", "house", "P0", 4)); var threadPool = Executors.NewFixedThreadPool( 2, new SupportThreadFactory(typeof(MultithreadContextUnique)).ThreadFactory); var runnableOne = new SendEventRunnable(env.Runtime, sendsT1, "ScoreCycle"); var runnableTwo = new SendEventRunnable(env.Runtime, sendsT2, "ScoreCycle"); threadPool.Submit(runnableOne.Run); threadPool.Submit(runnableTwo.Run); threadPool.Shutdown(); SupportCompileDeployUtil.ExecutorAwait(threadPool, 1, TimeUnit.SECONDS); Assert.IsNull(runnableOne.LastException); Assert.IsNull(runnableTwo.LastException); // compare var received = listener.Received; foreach (var item in received) { Console.Out.WriteLine(item); } Assert.AreEqual(4, received.Count); env.UndeployAll(); }
private void RunAssertion() { _idCounter = new AtomicLong(0); _executorService = Executors.NewCachedThreadPool(); _noActionUpdateListener = new NoActionUpdateListener(); var epConfig = new Configuration(SupportContainer.Instance); epConfig.AddEventType <SupportBean>(); epConfig.EngineDefaults.Threading.InsertIntoDispatchLocking = ConfigurationEngineDefaults.ThreadingConfig.Locking.SUSPEND; EPServiceProvider epServiceProvider = EPServiceProviderManager.GetProvider( SupportContainer.Instance, this.GetType().Name, epConfig); epServiceProvider.Initialize(); _epAdministrator = epServiceProvider.EPAdministrator; _epRuntime = epServiceProvider.EPRuntime; _epAdministrator.StartAllStatements(); string epl = "insert into Stream1 select count(*) as cnt from SupportBean#time(7 sec)"; CreateEPL(epl, _noActionUpdateListener.Update); epl = epl + " output every 10 seconds"; CreateEPL(epl, _noActionUpdateListener.Update); var sendTickEventRunnable = new SendEventRunnable(10000, SendEvent); Start(sendTickEventRunnable, 4); // Adjust here for long-running test Thread.Sleep(3000); _executorService.Shutdown(); _executorService.AwaitTermination(1, TimeUnit.SECONDS); }
public void TestRun() { _idCounter = 0L; _executorService = Executors.NewCachedThreadPool(); _noActionUpdateEventHandler = (sender, arg) => { }; var epConfig = new Configuration(); epConfig.AddEventType <SupportBean>(); epConfig.EngineDefaults.ThreadingConfig.InsertIntoDispatchLocking = ConfigurationEngineDefaults.Threading.Locking.SUSPEND; EPServiceProvider epServiceProvider = EPServiceProviderManager.GetDefaultProvider(epConfig); epServiceProvider.Initialize(); _epAdministrator = epServiceProvider.EPAdministrator; _epRuntime = epServiceProvider.EPRuntime; _epAdministrator.StartAllStatements(); String epl = "insert into Stream1 select count(*) as cnt from SupportBean.win:time(7 sec)"; CreateEPL(epl, delegate { }); epl = epl + " output every 10 seconds"; CreateEPL(epl, delegate { }); var sendTickEventRunnable = new SendEventRunnable <object>(SendEvent, 10000); Start(sendTickEventRunnable, 4); // Adjust here for long-running test Thread.Sleep(3000); _executorService.Shutdown(); _executorService.AwaitTermination(new TimeSpan(0, 0, 1)); }