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


C# ISession.WaitForSchemaAgreement方法代码示例

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


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

示例1: CheckKeyspaceMetadata

        public void CheckKeyspaceMetadata()
        {
            var clusterInfo = TestUtils.CcmSetup(2);
            try
            {
                Session = clusterInfo.Session;
                Cluster = clusterInfo.Cluster;
                Session.CreateKeyspaceIfNotExists(Keyspace);
                Session.ChangeKeyspace(Keyspace);

                var ksName = "keyspace" + Guid.NewGuid().ToString("N").ToLower();
                const string strategyClass = "SimpleStrategy";
                const bool durableWrites = false;
                const int replicationFactor = 1;
                Session.WaitForSchemaAgreement(
                    Session.Execute(string.Format(@"
                        CREATE KEYSPACE {0}
                        WITH replication = {{ 'class' : '{1}', 'replication_factor' : {2} }}
                        AND durable_writes={3};" , ksName, strategyClass, 1, durableWrites))
                );
                Session.ChangeKeyspace(ksName);

                for (var i = 0; i < 10; i++)
                {
                    CheckPureMetadata("table" + Guid.NewGuid().ToString("N"), ksName);
                }

                var ksmd = Cluster.Metadata.GetKeyspace(ksName);
                Assert.True(ksmd.DurableWrites == durableWrites);
                Assert.True(ksmd.Replication.First(opt => opt.Key == "replication_factor").Value == replicationFactor);
                Assert.True(ksmd.StrategyClass == strategyClass);
            }
            finally
            {
                TestUtils.CcmRemove(clusterInfo);
            }
        }
开发者ID:rasmus-s,项目名称:csharp-driver,代码行数:37,代码来源:MetadataTests.cs

示例2: createMultiDCSchema

 public static void createMultiDCSchema(ISession 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:rasmus-s,项目名称:csharp-driver,代码行数:9,代码来源:PolicyTestTools.cs

示例3: createSchema

 public static void createSchema(ISession 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:rasmus-s,项目名称:csharp-driver,代码行数:8,代码来源:PolicyTestTools.cs

示例4: CompositePartitionKeyMetadata

        public void CompositePartitionKeyMetadata()
        {
            var clusterInfo = TestUtils.CcmSetup(1);
            try
            {
                Session = clusterInfo.Session;
                Cluster = clusterInfo.Cluster;
                string cql = @"
                    CREATE TABLE sample_composite_partition1 (
                    a text,
                    b int,
                    c int,
                    d int,
                    PRIMARY KEY ((a, b), c))";
                Session.CreateKeyspaceIfNotExists(Keyspace);
                Session.ChangeKeyspace(Keyspace);
                Session.WaitForSchemaAgreement(Session.Execute(cql));

                Session.Execute("INSERT INTO sample_composite_partition1 (a, b, c, d) VALUES ('1', 2, 3, 4)");
                var rs = Session.Execute("select * from sample_composite_partition1");
                Assert.True(rs.GetRows().Count() == 1);

                var table = Cluster.Metadata
                    .GetKeyspace(Keyspace)
                    .GetTableMetadata("sample_composite_partition1");
                Assert.True(table.TableColumns.Count() == 4);

                cql = @"
                    CREATE TABLE sample_composite_partition2 (
                    a text,
                    b text,
                    c int,
                    d int,
                    PRIMARY KEY ((a, b, c)))";
                Session.WaitForSchemaAgreement(Session.Execute(cql));

                table = Cluster.Metadata
                    .GetKeyspace(Keyspace)
                    .GetTableMetadata("sample_composite_partition2");
                Assert.True(table.TableColumns.Count() == 4);

                cql = @"
                    CREATE TABLE sample_composite_clusteringkey (
                    a text,
                    b text,
                    c timestamp,
                    d int,
                    PRIMARY KEY (a, b, c))";
                Session.WaitForSchemaAgreement(Session.Execute(cql));

                table = Cluster.Metadata
                    .GetKeyspace(Keyspace)
                    .GetTableMetadata("sample_composite_clusteringkey");
                Assert.True(table.TableColumns.Count() == 4);
            }
            finally
            {
                TestUtils.CcmRemove(clusterInfo);
            }
        }
开发者ID:rasmus-s,项目名称:csharp-driver,代码行数:60,代码来源:MetadataTests.cs


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