private void TryMT(int numInserted)
        {
            var epl = "create table MyTable (key int primary key, p0 int);";

            _epService.EPAdministrator.DeploymentAdmin.ParseDeploy(epl);

            var runnables = new List <BaseRunnable>();

            var insertOutQ = new LinkedBlockingQueue <int>();
            var insert     = new InsertRunnable(_epService, numInserted, insertOutQ);

            runnables.Add(insert);

            var selectOutQ = new LinkedBlockingQueue <int>();
            var select     = new SelectRunnable(_epService, insertOutQ, selectOutQ);

            runnables.Add(select);

            var updateOutQ = new LinkedBlockingQueue <int>();
            var update     = new UpdateRunnable(_epService, selectOutQ, updateOutQ);

            runnables.Add(update);

            var deleteOutQ = new LinkedBlockingQueue <int>();
            var delete     = new DeleteRunnable(_epService, updateOutQ, deleteOutQ);

            runnables.Add(delete);

            // start
            var threads = new Thread[runnables.Count];

            for (var i = 0; i < runnables.Count; i++)
            {
                threads[i] = new Thread(runnables[i].Run);
                threads[i].Start();
            }

            // join
            foreach (var t in threads)
            {
                t.Join();
            }

            // assert
            foreach (var runnable in runnables)
            {
                Assert.IsNull(runnable.Exception);
                Assert.AreEqual(numInserted + 1, runnable.NumberOfOperations, "failed for " + runnable);    // account for -1 indicator
            }
        }
        private static void TryMT(
            RegressionEnvironment env,
            int numInserted)
        {
            var path = new RegressionPath();
            var epl = "create table MyTable (key int primary key, p0 int);";
            env.CompileDeploy(epl, path);

            IList<BaseRunnable> runnables = new List<BaseRunnable>();

            var insertOutQ = new LinkedBlockingQueue<int>();
            var insert = new InsertRunnable(env, path, numInserted, insertOutQ);
            runnables.Add(insert);

            var selectOutQ = new LinkedBlockingQueue<int>();
            var select = new SelectRunnable(env, path, insertOutQ, selectOutQ);
            runnables.Add(select);

            var updateOutQ = new LinkedBlockingQueue<int>();
            var update = new UpdateRunnable(env, path, selectOutQ, updateOutQ);
            runnables.Add(update);

            IBlockingQueue<int> deleteOutQ = new LinkedBlockingQueue<int>();
            var delete = new DeleteRunnable(env, path, updateOutQ, deleteOutQ);
            runnables.Add(delete);

            // start
            var threads = new Thread[runnables.Count];
            for (var i = 0; i < runnables.Count; i++) {
                threads[i] = new Thread(runnables[i].Run);
                threads[i].Name = typeof(InfraTableMTGroupedFAFReadFAFWriteChain).Name + "-" + i;
                threads[i].Start();
            }

            // join
            foreach (var t in threads) {
                t.Join(TimeSpan.FromSeconds(60));
            }

            env.UndeployAll();

            // assert
            foreach (var runnable in runnables) {
                Assert.IsNull(runnable.Exception);
                Assert.AreEqual(
                    numInserted + 1,
                    runnable.NumberOfOperations,
                    "failed for " + runnable); // account for -1 indicator
            }
        }
Beispiel #3
0
 public void StartVimbaAndShutDown(InsertRunnable runnable = null)
 {
     {
         var response =
             _client.VimbaInstanceControl(
                 new VimbaInstanceControlRequest()
         {
             Command = ConnectionCommands.Connect
         });
         Assert.IsNull(response.Error);
         Assert.IsTrue(response.IsStarted);
     }
     runnable?.Invoke();
     {
         var response =
             _client.VimbaInstanceControl(
                 new VimbaInstanceControlRequest()
         {
             Command = ConnectionCommands.Disconnect
         });
         Assert.IsNull(response.Error);
         Assert.IsFalse(response.IsStarted);
     }
 }