本文整理汇总了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);
}
}
示例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)));
}
示例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)));
}
示例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);
}
}