/**
         * Reproducing the issue #29 in cassandra-sharp
         * https://github.com/pchalamet/cassandra-sharp/issues/29
         * malformed prepared query cause issues to be swallwoed and hold indefinelty to stream_id.
         * */

        public void FailingThread(IPreparedQuery <NonQuery> prepared)
        {
            logger.Debug("Starting Failing thread ");
            Thread.Sleep(5000);

            for (int i = 0; i < NUM_UPDATES; i++)
            {
                logger.Debug("start fail update #" + i);
                try
                {
                    if (0 == (i % 2))
                    {
                        prepared.Execute(new { bar = "bar" + 1, strid = "1" }).AsFuture().Wait();
                        Assert.IsTrue(false, "Update should have failed");
                    }
                    else
                    {
                        prepared.Execute(new { bar = "bar" + 1, intid = i, strid = "1" }).AsFuture().Wait();
                        Console.WriteLine("Update {0} sucessful", i);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Update {0} failed with error {1}", i, ex.Message);
                }

                logger.Debug("end fail update #" + i);
                //Thread.Sleep(2000);
            }
        }
Ejemplo n.º 2
0
        private static long InsertData(string data, IPreparedQuery <NonQuery> preparedQuery)
        {
            Console.WriteLine("Buffer size {0}", data.Length);
            Stopwatch totalwatch = Stopwatch.StartNew();

            // warmup
            for (int i = 0; i < 10; ++i)
            {
                preparedQuery.Execute(new { x = "abc", y = data }).AsFuture().Wait();
            }

            const long nbQueries = 5000;

            for (var i = 0; i < nbQueries; ++i)
            {
                Stopwatch stopwatch = Stopwatch.StartNew();
                preparedQuery.Execute(new { x = "abc", y = data }).AsFuture().Wait();
                stopwatch.Stop();
                //Console.WriteLine("Insert: {0}", stopwatch.ElapsedMilliseconds);
            }
            totalwatch.Stop();
            Console.WriteLine("Total inserts time ms: {0}", totalwatch.ElapsedMilliseconds);
            Console.WriteLine("Total inserts/s: {0}", (1000.0 * nbQueries) / totalwatch.ElapsedMilliseconds);

            return(totalwatch.ElapsedMilliseconds);
        }
        private static long InsertData(string data, IPreparedQuery<NonQuery> preparedQuery)
        {
            Console.WriteLine("Buffer size {0}", data.Length);
            Stopwatch totalwatch = Stopwatch.StartNew();

            // warmup
            for (int i = 0; i < 10; ++i)
            {
                preparedQuery.Execute(new {x = "abc", y = data}).AsFuture().Wait();
            }

            const long nbQueries = 5000;
            for (var i = 0; i < nbQueries; ++i)
            {
                Stopwatch stopwatch = Stopwatch.StartNew();
                preparedQuery.Execute(new {x = "abc", y = data}).AsFuture().Wait();
                stopwatch.Stop();
                //Console.WriteLine("Insert: {0}", stopwatch.ElapsedMilliseconds);
            }
            totalwatch.Stop();
            Console.WriteLine("Total inserts time ms: {0}", totalwatch.ElapsedMilliseconds);
            Console.WriteLine("Total inserts/s: {0}", (1000.0*nbQueries)/totalwatch.ElapsedMilliseconds);

            return totalwatch.ElapsedMilliseconds;
        }
        /**
         * Reproducing the issue #29 in cassandra-sharp
         * https://github.com/pchalamet/cassandra-sharp/issues/29
         * malformed prepared query cause issues to be swallwoed and hold indefinelty to stream_id.
         * */
        public void FailingThread(IPreparedQuery prepared)
        {
            logger.Debug("Starting Failing thread ");
            Thread.Sleep(5000);

            for (int i = 0; i < NUM_UPDATES; i++)
            {
                logger.Debug("start fail update #" + i);
                try
                {
                    if (0 == (i%2))
                    {
                        prepared.Execute(new {bar = "bar" + 1, strid = "1"}, ConsistencyLevel.ONE).Wait();
                        Assert.IsTrue(false, "Update should have failed");
                    }
                    else
                    {
                        prepared.Execute(new { bar = "bar" + 1, intid = i, strid = "1" }, ConsistencyLevel.ONE).Wait();
                        Console.WriteLine("Update {0} sucessful", i);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Update {0} failed with error {1}", i, ex.Message);
                }

                logger.Debug("end fail update #" + i);
                //Thread.Sleep(2000);
            }
        }
Ejemplo n.º 5
0
 public override void Execute(params object[] prms)
 {
     _prepared.Execute(prms).AsFuture().Wait();
 }