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


C# Session.ChangeKeyspace方法代码示例

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


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

示例1: createSchema

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

示例2: createMultiDCSchema

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

示例3: 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.Cluster.WaitForSchemaAgreement(
                session.Execute(String.Format("CREATE TABLE {0} (k INT, i INT, PRIMARY KEY(k, i))", "wide_rows")).QueriedHost);
            session.Cluster.WaitForSchemaAgreement(
                session.Execute(String.Format("CREATE TABLE {0} (k INT, i INT, PRIMARY KEY(k, i))", "wide_batch_rows")).QueriedHost);
            session.Cluster.WaitForSchemaAgreement(
                session.Execute(String.Format("CREATE TABLE {0} (k INT, i BLOB, PRIMARY KEY(k, i))", "wide_byte_rows")).QueriedHost);
            session.Cluster.WaitForSchemaAgreement(
                session.Execute(String.Format("CREATE TABLE {0} (k int PRIMARY KEY, i text)", "large_text")).QueriedHost);

            // 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.Cluster.WaitForSchemaAgreement(
                session.Execute(tableDeclaration.ToString()).QueriedHost
            );

            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:joaquincasares,项目名称:csharp-driver,代码行数:58,代码来源:LargeDataTests.cs

示例4: SetFixture

 public void SetFixture()
 {
     Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-US");
     CCMCluster = CCMBridge.CCMCluster.Create(2, Cluster.Builder());
     session = CCMCluster.Session;
     Cluster = CCMCluster.Cluster;
     session.CreateKeyspaceIfNotExists(keyspaceName);
     session.ChangeKeyspace(keyspaceName);
     ents = new TweetsContext(session);
 }
开发者ID:joaquincasares,项目名称:csharp-driver,代码行数:10,代码来源:Basics.cs

示例5: parallelInsertTestGeneric

        public void parallelInsertTestGeneric(int nThreads, int cpCon)
        {
            CCMBridge.ReusableCCMCluster.Setup(1);
            string datacenter = "datacenter1";
            long constDelayMS = 100;
            int queryTimeout = 50000;
            int coreConnectionPerHost = 64;
            int maxConnectionPerHost = 64;

            CCMBridge.ReusableCCMCluster.Build(initialize(datacenter, constDelayMS, queryTimeout, coreConnectionPerHost, maxConnectionPerHost,cpCon));
            Session = CCMBridge.ReusableCCMCluster.Connect("tester");

            Console.WriteLine("Start parallel insert test (" + nThreads + " , " + cpCon + ")");
            string keyspaceName = "testkeyspace1" + nThreads + "x" + cpCon;
            //            Console.WriteLine("Creating keyspace");
            Session.Cluster.WaitForSchemaAgreement(
                 Session.Execute(
                    string.Format(@"CREATE KEYSPACE {0}
                        WITH replication = {{ 'class' : 'SimpleStrategy', 'replication_factor' : 1 }};"
                        , keyspaceName)));
            Session.ChangeKeyspace(keyspaceName);
            string tableName = "testtable";
            try
            {
                Session.Cluster.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");

            //using (var res = Session.Execute(string.Format(@"SELECT COUNT(*) FROM {0} LIMIT {1}", tableName, RowsNo + 100), ConsistencyLevel.Quorum))
            //{
            //    var cnt = res.GetRows().FirstOrDefault().GetValue<long>(0);
            //    Assert.Equal(RowsNo, cnt);
            //}

            Session.Execute(string.Format(@"DROP TABLE {0};", tableName));
//.........这里部分代码省略.........
开发者ID:hjarraya,项目名称:csharp-driver,代码行数:101,代码来源:StressTest1.cs

示例6: SetupDefaultCluster

        private void SetupDefaultCluster()
        {
            if (CCMCluster != null)
                CCMCluster.Discard();

            CCMCluster = CCMBridge.CCMCluster.Create(2, Cluster.Builder());
            session = CCMCluster.Session;
            cluster = CCMCluster.Cluster;
            session.CreateKeyspaceIfNotExists(ksname);
            session.ChangeKeyspace(ksname);
        }
开发者ID:randacc,项目名称:csharp-driver,代码行数:11,代码来源:LargeDataTests.cs

示例7: SetFixture

 public void SetFixture()
 {
     Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-US");
     CCMBridge.ReusableCCMCluster.Setup(2);
     CCMBridge.ReusableCCMCluster.Build(Cluster.Builder());
     Session = CCMBridge.ReusableCCMCluster.Connect("tester");
     Session.CreateKeyspaceIfNotExists(KeyspaceName);
     Session.ChangeKeyspace(KeyspaceName);
 }
开发者ID:hjarraya,项目名称:csharp-driver,代码行数:9,代码来源:FoundBugTests.cs

示例8: SetFixture

 public void SetFixture()
 {
     Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-US");
     CCMCluster = CCMBridge.CCMCluster.Create(2, Cluster.Builder());
     Session = CCMCluster.Session;
     Cluster = CCMCluster.Cluster;
     Session.CreateKeyspaceIfNotExists(Keyspace);
     Session.ChangeKeyspace(Keyspace);
 }
开发者ID:joaquincasares,项目名称:csharp-driver,代码行数:9,代码来源:Collections.cs

示例9: createSchema

 private void createSchema(Session session, int replicationFactor)
 {
     session.Execute(String.Format(TestUtils.CREATE_KEYSPACE_SIMPLE_FORMAT, TestUtils.SIMPLE_KEYSPACE, replicationFactor), ConsistencyLevel.All);
     Thread.Sleep(1000);
     session.ChangeKeyspace(TestUtils.SIMPLE_KEYSPACE);
     session.Execute(String.Format("CREATE TABLE {0} (k int PRIMARY KEY, i int)", TABLE));
     Thread.Sleep(1000);
 }
开发者ID:abhijitchanda,项目名称:csharp-driver,代码行数:8,代码来源:LoadBalancingPolicyTests.cs

示例10: createMultiDCSchema

 private void createMultiDCSchema(Session session)
 {
     session.Execute(String.Format(TestUtils.CREATE_KEYSPACE_GENERIC_FORMAT, TestUtils.SIMPLE_KEYSPACE, "NetworkTopologyStrategy", "'dc1' : 1, 'dc2' : 1"));
     session.ChangeKeyspace(TestUtils.SIMPLE_KEYSPACE);
     session.Execute(String.Format("CREATE TABLE {0} (k int PRIMARY KEY, i int)", TABLE));
 }
开发者ID:abhijitchanda,项目名称:csharp-driver,代码行数:6,代码来源:LoadBalancingPolicyTests.cs


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