protected void init(CcmClusterInfo clusterInfo, int n, bool batch, ConsistencyLevel cl) { // We don't use insert for our test because the resultSet don't ship the queriedHost // Also note that we don't use tracing because this would trigger requests that screw up the test' for (int i = 0; i < n; ++i) { if (batch) // BUG: WriteType == SIMPLE { var bth = new StringBuilder(); bth.AppendLine("BEGIN BATCH"); bth.AppendLine(String.Format("INSERT INTO {0}(k, i) VALUES (0, 0)", TestUtils.SIMPLE_TABLE)); bth.AppendLine("APPLY BATCH"); RowSet qh = clusterInfo.Session.Execute(new SimpleStatement(bth.ToString()).SetConsistencyLevel(cl)); } else { RowSet qh = clusterInfo.Session.Execute( new SimpleStatement(String.Format("INSERT INTO {0}(k, i) VALUES (0, 0)", TestUtils.SIMPLE_TABLE)).SetConsistencyLevel(cl)); } } prepared = clusterInfo.Session.Prepare("SELECT * FROM " + TestUtils.SIMPLE_TABLE + " WHERE k = ?").SetConsistencyLevel(cl); }
private void SetupDefaultCluster(int nodeLength = 2) { if (ClusterInfo != null) { TestUtils.CcmRemove(ClusterInfo); } ClusterInfo = TestUtils.CcmSetup(nodeLength); Session = ClusterInfo.Session; Cluster = ClusterInfo.Cluster; Session.CreateKeyspaceIfNotExists(ksname); Session.ChangeKeyspace(ksname); }
public override void TestFixtureSetUp() { Diagnostics.CassandraTraceSwitch.Level = System.Diagnostics.TraceLevel.Info; var ccmConfigDir = TestUtils.CreateTempDirectory(); TestUtils.ExecuteLocalCcm("list", ccmConfigDir, 2000, true); var ccmCommand = String.Format("create test -v {0}", Options.Default.CASSANDRA_VERSION); TestUtils.ExecuteLocalCcm(ccmCommand, ccmConfigDir, 180000, true); TestUtils.ExecuteLocalCcm("updateconf \"authenticator: PasswordAuthenticator\"", ccmConfigDir, 3000, true); TestUtils.ExecuteLocalCcm("populate -n 2", ccmConfigDir, 20000, true); TestUtils.ExecuteLocalCcm("start", ccmConfigDir, 60000, true); //Cassandra takes at least 10 secs to add the default user cassandra Thread.Sleep(25000); CcmClusterInfo = new CcmClusterInfo { ConfigDir = ccmConfigDir }; }
protected void query(CcmClusterInfo clusterInfo, int n, bool usePrepared, ConsistencyLevel cl) { if (usePrepared) { BoundStatement bs = prepared.Bind(0); for (int i = 0; i < n; ++i) { IPEndPoint ccord; ConsistencyLevel cac; var rs = clusterInfo.Session.Execute(bs); { ccord = rs.Info.QueriedHost; cac = rs.Info.AchievedConsistency; } addCoordinator(ccord, cac); } } else { var routingKey = new RoutingKey(); routingKey.RawRoutingKey = Enumerable.Repeat((byte)0x00, 4).ToArray(); for (int i = 0; i < n; ++i) { IPEndPoint ccord; ConsistencyLevel cac; var rs = clusterInfo.Session.Execute( new SimpleStatement(String.Format("SELECT * FROM {0} WHERE k = 0", TABLE)).SetRoutingKey(routingKey) .SetConsistencyLevel(cl)); { ccord = rs.Info.QueriedHost; cac = rs.Info.AchievedConsistency; Trace.TraceInformation("Query {0} executed by {1} with consistency {2}", i, ccord, cac); } addCoordinator(ccord, cac); } } }
protected void query(CcmClusterInfo clusterInfo, int n, ConsistencyLevel cl) { query(clusterInfo, n, false, cl); }
/// <summary> /// Query methods that handle reads based on PreparedStatements and/or /// ConsistencyLevels. /// </summary> protected void query(CcmClusterInfo clusterInfo, int n) { query(clusterInfo, n, false, ConsistencyLevel.One); }
protected void query(CcmClusterInfo clusterInfo, int n, bool usePrepared) { query(clusterInfo, n, usePrepared, ConsistencyLevel.One); }
protected void init(CcmClusterInfo clusterInfo, int n, ConsistencyLevel cl) { init(clusterInfo, n, false, cl); }
protected void init(CcmClusterInfo clusterInfo, int n, bool batch) { init(clusterInfo, n, batch, ConsistencyLevel.One); }
/// <summary> /// Init methods that handle writes using batch and consistency options. /// </summary> protected void init(CcmClusterInfo clusterInfo, int n) { init(clusterInfo, n, false, ConsistencyLevel.One); }
protected void query(CcmClusterInfo clusterInfo, int n, bool usePrepared, ConsistencyLevel cl) { if (usePrepared) { BoundStatement bs = prepared.Bind(0); for (int i = 0; i < n; ++i) { IPAddress ccord; ConsistencyLevel cac; var rs = clusterInfo.Session.Execute(bs); { ccord = rs.Info.QueriedHost; cac = rs.Info.AchievedConsistency; } addCoordinator(ccord, cac); } } else { var routingKey = new RoutingKey(); routingKey.RawRoutingKey = Enumerable.Repeat((byte) 0x00, 4).ToArray(); for (int i = 0; i < n; ++i) { IPAddress ccord; ConsistencyLevel cac; var rs = clusterInfo.Session.Execute( new SimpleStatement(String.Format("SELECT * FROM {0} WHERE k = 0", TABLE)).SetRoutingKey(routingKey) .SetConsistencyLevel(cl)); { ccord = rs.Info.QueriedHost; cac = rs.Info.AchievedConsistency; Trace.TraceInformation("Query {0} executed by {1} with consistency {2}", i, ccord, cac); } addCoordinator(ccord, cac); } } }
protected void init(CcmClusterInfo clusterInfo, int n, bool batch, ConsistencyLevel cl) { // We don't use insert for our test because the resultSet don't ship the queriedHost // Also note that we don't use tracing because this would trigger requests that screw up the test' for (int i = 0; i < n; ++i) if (batch) // BUG: WriteType == SIMPLE { var bth = new StringBuilder(); bth.AppendLine("BEGIN BATCH"); bth.AppendLine(String.Format("INSERT INTO {0}(k, i) VALUES (0, 0)", TestUtils.SIMPLE_TABLE)); bth.AppendLine("APPLY BATCH"); RowSet qh = clusterInfo.Session.Execute(new SimpleStatement(bth.ToString()).SetConsistencyLevel(cl)); } else { RowSet qh = clusterInfo.Session.Execute( new SimpleStatement(String.Format("INSERT INTO {0}(k, i) VALUES (0, 0)", TestUtils.SIMPLE_TABLE)).SetConsistencyLevel(cl)); } prepared = clusterInfo.Session.Prepare("SELECT * FROM " + TestUtils.SIMPLE_TABLE + " WHERE k = ?").SetConsistencyLevel(cl); }