As more options are added to create CassandraContext, it is now recommended to use CassandraConnectionConfig and CassandraConnectionConfigBuilder to create CassandraContext.
			var builder = new CassandraConnectionConfigBuilder
				Hosts = new [] { "localhost" }
				Port = 9160,
				ConsistencyLevel = ConsistencyLevel.QUORUM,
				Timeout = TimeSpan.FromSeconds(100),
			var config = new CassandraConnectionConfig(builder);
			using (var ctx = new CassandraContext(config)) { ... }


Name Description Default Value
Hosts Hosts to connect string[] { "localhost" }
Port Thrift Port 9160
Keyspace Keyspace to use "system"
ConsistencyLevel Default ConsistencyLevel ( you can change it if you want ) ConsistencyLevel.One
RetryCount Retry count for connection fail -1 ( this mean nodecount * 2 )
IsFramed Use Framed Transport true
Timeout Time of wait for Connection Success 10 seconds
MinPoolCountPerHost Min count of pooled connection 2
MaxPoolCountPerHost Max count of pooled connection int.MaxValue
Node Rule of Getting Node empty string


When creating CassandraContext or CassandraConnectionConfig, all unspecified parameters are taken from CassandraConnectionConfig.Default. You can create your own CassandraConnectionConfig and set to CassandraConnectionConfig.Default to change the default behavior.

Hosts and Node Properties

The Hosts property specifies the hosts that are used to find the first host to connect to. Afterwards, CassandraContext maintains its internal node list using the rule specified by the Node property. There are two built-in rules for Node property as follows.
Value Description
empty string The default rule. On the first connection and also on network failure, Cassandraemon automatically retrieves node list from the ring and use all the hosts that belong to the list automatically.
"Manual" Cassandraemon uses hosts specified by the Hosts property.

You can also supply your own class that implements Cassandraemon.Connection.ICassandraNodeEnumerator and set its type name to the Node property.

Connection Pooling

Connections are pooled automatically in Cassandraemon.Connection.ConnectionPool, which is created automatically when you create CassandraContext. Connections are returned to ConnectionPool when you call CassandraContext.Dispose() and will be re-used.


CassandraConnectionConfig.ConsistencyLevel gives the default value for CassandraContext.ConsistencyLevel, but CassandraContext.ConsistencyLevel is mutable and therefore its current value is used on SubmitChanges.

Tracing and Diagnosing

Cassandraemon has TraceSource named "Cassandraemon". Add appropriate TraceListeners to the TraceSource to diagnose connections and other events.

To listen to the TraceSource in code, here is an example snippets.
	var listener = new ConsoleTraceListener();

Here is an example to output to EventLog using .config.
      <source name="Cassandraemon" switchValue="Information">
          <add name="eventlog" />

Last edited Dec 18, 2011 at 8:46 AM by sabro, version 1


No comments yet.