当前位置: 首页>>代码示例>>C#>>正文


C# Session.WaitForSchemaAgreement方法代码示例

本文整理汇总了C#中Session.WaitForSchemaAgreement方法的典型用法代码示例。如果您正苦于以下问题:C# Session.WaitForSchemaAgreement方法的具体用法?C# Session.WaitForSchemaAgreement怎么用?C# Session.WaitForSchemaAgreement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Session的用法示例。


在下文中一共展示了Session.WaitForSchemaAgreement方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: mixedDurationTestCCM

        public void mixedDurationTestCCM()
        {
            if (CCMCluster != null)
                CCMCluster.Discard();
            CCMCluster = CCMBridge.CCMCluster.Create(3, Cluster.Builder());
            cluster = CCMCluster.Cluster;
            session = CCMCluster.Session;

            session.CreateKeyspace("large_data", ReplicationStrategies.CreateSimpleStrategyReplicationProperty(3));
            session.ChangeKeyspace("large_data");
            session.WaitForSchemaAgreement(
                session.Execute(String.Format("CREATE TABLE {0} (k INT, i INT, PRIMARY KEY(k, i))", "wide_rows")));
            session.WaitForSchemaAgreement(
                session.Execute(String.Format("CREATE TABLE {0} (k INT, i INT, PRIMARY KEY(k, i))", "wide_batch_rows")));
            session.WaitForSchemaAgreement(
                session.Execute(String.Format("CREATE TABLE {0} (k INT, i BLOB, PRIMARY KEY(k, i))", "wide_byte_rows")));
            session.WaitForSchemaAgreement(
                session.Execute(String.Format("CREATE TABLE {0} (k int PRIMARY KEY, i text)", "large_text")));

            // Create the extra wide table definition
            StringBuilder tableDeclaration = new StringBuilder();
            tableDeclaration.Append("CREATE TABLE wide_table (");
            tableDeclaration.Append("k INT PRIMARY KEY");
            for (int i = 0; i < 330; ++i)
            {
                tableDeclaration.Append(String.Format(", {0} INT", createColumnName(i)));
            }
            tableDeclaration.Append(")");
            session.WaitForSchemaAgreement(
                session.Execute(tableDeclaration.ToString())
            );

            Random rndm = new Random(DateTime.Now.Millisecond);
            try
            {
                for (int i = 0; i < 10; ++i)
                {
                    switch ((int)rndm.Next(0,5))
                    {
                        case 0: testWideRows(); break;
                        case 1: testWideBatchRows(); break;
                        case 2: testByteRows(); break;
                        case 3: testLargeText(); break;
                        case 4: testWideTable(); break;
                        default: break;
                    }
                }
            }
            catch (Exception e)
            {
                CCMCluster.ErrorOut();
                throw e;
            }
            finally
            {
                CCMCluster.Discard();
            }
        }
开发者ID:randacc,项目名称:csharp-driver,代码行数:58,代码来源:LargeDataTests.cs

示例2: createMultiDCSchema

 public static void createMultiDCSchema(Session session, int dc1RF = 1, int dc2RF = 1)
 {
     session.WaitForSchemaAgreement(
         session.Execute(String.Format(TestUtils.CREATE_KEYSPACE_GENERIC_FORMAT, TestUtils.SIMPLE_KEYSPACE, "NetworkTopologyStrategy", string.Format("'dc1' : {0}, 'dc2' : {1}", dc1RF, dc2RF))));
     session.ChangeKeyspace(TestUtils.SIMPLE_KEYSPACE);
     session.WaitForSchemaAgreement(
         session.Execute(String.Format("CREATE TABLE {0} (k int PRIMARY KEY, i int)", TABLE)));
 }
开发者ID:ntent-ad,项目名称:csharp-driver,代码行数:8,代码来源:PolicyTestTools.cs

示例3: parallelInsertTestGeneric

        public void parallelInsertTestGeneric(int nThreads, int cpCon)
        {
            //CCMBridge.ReusableCCMCluster.Setup(3, 0, true);
            string datacenter = "datacenter1";
            long constDelayMS = 500;
            int queryTimeout = Timeout.Infinite;
            int coreConnectionPerHost = 2;
            int maxConnectionPerHost = 8;

            CCMBridge.CCMCluster  ccmCluster = CCMBridge.CCMCluster.Create(3, initialize(datacenter, constDelayMS, queryTimeout, coreConnectionPerHost, maxConnectionPerHost, cpCon));

            //            CCMBridge.ReusableCCMCluster.Build(initialize(datacenter, constDelayMS, queryTimeout, coreConnectionPerHost, maxConnectionPerHost,cpCon));
            Session = ccmCluster.Session;

            Console.WriteLine("Start parallel insert test (" + nThreads + " , " + cpCon + ")");
            string keyspaceName = "testkeyspace1" + nThreads + "x" + cpCon;
            //            Console.WriteLine("Creating keyspace");
            try
            {
                Session.WaitForSchemaAgreement(
                     Session.Execute(
                        string.Format(@"CREATE KEYSPACE {0}
                        WITH replication = {{ 'class' : 'SimpleStrategy', 'replication_factor' : 1 }};"
                            , keyspaceName)));
            }
            catch (AlreadyExistsException) { }
            Session.ChangeKeyspace(keyspaceName);
            string tableName = "testtable";
            try
            {
                Session.WaitForSchemaAgreement(
                        Session.Execute(string.Format(@"CREATE TABLE {0}(
                         tweet_id int,
                         author text,
                         body text,
                         isok boolean,
                         PRIMARY KEY(tweet_id))", tableName)));
            }
            catch (AlreadyExistsException)
            { }
            //            Console.WriteLine("Prepare statement");
            PreparedStatement insertPrep = Session.Prepare("INSERT INTO " + tableName + @" (
                tweet_id,
                author,
                isok,
                body)
                VALUES (?,?,?,?);");
            //    Console.WriteLine("Insert Values");

            int RowsNo = 100000;
            int stepSize = RowsNo / nThreads;

            Thread[] tasks = new Thread[nThreads];
            object monit = new object();
            int readyCnt = 0;

            for (int i = 0; i < nThreads; i++)
            {
                var startIndex = i * stepSize;
                var endIndex = (i + 1) * stepSize;
                tasks[i] = new Thread(() =>
                {
                    lock (monit)
                    {
                        readyCnt++;
                        Monitor.Wait(monit);
                    }
                    insertRange(insertPrep, startIndex, endIndex);
                });
                tasks[i].Start();
            }

            Stopwatch t = Stopwatch.StartNew();

            lock (monit)
            {
                while (true)
                {
                    if (readyCnt < nThreads)
                    {
                        Monitor.Exit(monit);
                        Thread.Sleep(100);
                        Monitor.Enter(monit);
                    }
                    else
                    {
                        t.Restart();
                        Monitor.PulseAll(monit);
                        break;
                    }
                }
            }

            foreach (var task in tasks)
                task.Join();

            Console.WriteLine("Avg query response time " + ((double)totalElapsedTime) / (double)RowsNo + "ms");
            Console.WriteLine("Avg single insert time " + ((double)t.ElapsedMilliseconds) / (double)RowsNo + "ms");

            RETRY:
//.........这里部分代码省略.........
开发者ID:randacc,项目名称:csharp-driver,代码行数:101,代码来源:StressTest1.cs

示例4: createSchema

 public static void createSchema(Session session, int replicationFactor)
 {
     session.WaitForSchemaAgreement(
         session.Execute(String.Format(TestUtils.CREATE_KEYSPACE_SIMPLE_FORMAT, TestUtils.SIMPLE_KEYSPACE, replicationFactor)));
     session.ChangeKeyspace(TestUtils.SIMPLE_KEYSPACE);
     session.WaitForSchemaAgreement(
         session.Execute(String.Format("CREATE TABLE {0} (k int PRIMARY KEY, i int)", TABLE)));
 }
开发者ID:ntent-ad,项目名称:csharp-driver,代码行数:8,代码来源:PolicyTestTools.cs


注:本文中的Session.WaitForSchemaAgreement方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。