public void checkKSMetadata() { CCMCluster = CCMBridge.CCMCluster.Create(2, Cluster.Builder()); try { Session = CCMCluster.Session; Cluster = CCMCluster.Cluster; Session.CreateKeyspaceIfNotExists(Keyspace); Session.ChangeKeyspace(Keyspace); string keyspacename = "keyspace" + Guid.NewGuid().ToString("N").ToLower(); bool durableWrites = false; string strgyClass = "SimpleStrategy"; short rplctnFactor = 1; Session.Cluster.WaitForSchemaAgreement( Session.Execute( string.Format(@"CREATE KEYSPACE {0} WITH replication = {{ 'class' : '{1}', 'replication_factor' : {2} }} AND durable_writes={3};" , keyspacename, strgyClass, rplctnFactor.ToString(), durableWrites.ToString())).QueriedHost ); Session.ChangeKeyspace(keyspacename); for (int i = 0; i < 10; i++) checkPureMetadata("table" + Guid.NewGuid().ToString("N"), keyspacename); KeyspaceMetadata ksmd = Cluster.Metadata.GetKeyspace(keyspacename); Assert.True(ksmd.DurableWrites == durableWrites); Assert.True(ksmd.Replication.Where(opt => opt.Key == "replication_factor").First().Value == rplctnFactor); Assert.True(ksmd.StrategyClass == strgyClass); } finally { CCMCluster.Discard(); } }
public void ExecuteSyncNonQuery(Session session, string query, string messageInstead = null, ConsistencyLevel consistency= ConsistencyLevel.Default) { if (messageInstead != null) Console.WriteLine("CQL<\t" + messageInstead); else Console.WriteLine("CQL< Query:\t" + query); var ret = session.Execute(query, consistency); Console.WriteLine("CQL> (OK)."); }
public void ExecuteSyncQuery(Session session, string query, List<object[]> expectedValues = null, ConsistencyLevel consistency = ConsistencyLevel.Default, string messageInstead = null) { if (messageInstead != null) Console.WriteLine("CQL<\t" + messageInstead); else Console.WriteLine("CQL< Query:\t" + query); if (expectedValues != null) using (var ret = session.Execute(query, consistency)) valueComparator(ret, expectedValues); using (var ret = session.Execute(query, consistency)) ret.PrintTo(stream: Console.Out, cellEncoder: CellEncoder); Console.WriteLine("CQL> Done."); }
public void ExecutePreparedQuery(Session session, PreparedStatement prepared, object[] values, ConsistencyLevel consistency = ConsistencyLevel.Default, string messageInstead = null) { if (messageInstead != null) Console.WriteLine("CQL<\t" + messageInstead); else Console.WriteLine("CQL< Executing Prepared Query:\t"); session.Execute(prepared.Bind(values).SetConsistencyLevel(consistency)); Console.WriteLine("CQL> (OK)."); }