C# Driver 1.0 for Apache Cassandra

About the C# driver

The C# Driver 1.0 for Apache Cassandra works exclusively with the Cassandra Query Language version 3 (CQL3) and Cassandra's new binary protocol which was introduced in Cassandra version 1.2.

Architectural overview

The driver architecture is a layered one. At the bottom lies the driver core. This core, located in Cassandra.dll Assembly, handles everything related to the connections to a Cassandra cluster (for example, connection pool, discovering new nodes, etc.) and exposes a simple, relatively low-level API on top of which a higher level layer can be built.

The Linq2CQL module is built on top of the driver core and is located in Cassandra.Data.Linq.dll Assembly. It is a LINQ driver for Cassandra.

The driver has the following features:
  • Asynchronous: the driver uses the new CQL binary protocol asynchronous capabilities. Only a relatively low number of connections per nodes needs to be maintained open to achieve good performance.
  • Nodes discovery: the driver automatically discovers and uses all nodes of the Cassandra cluster, including newly bootstrapped ones.
  • Configurable load balancing: the driver allows for custom routing and load balancing of queries to Cassandra nodes. Out of the box, round robin is provided with optional data-center awareness (only nodes from the local data-center are queried (and have connections maintained to)) and optional token awareness (that is, the ability to prefer a replica for the query as coordinator).
  • Transparent failover: if Cassandra nodes fail or become unreachable, the driver automatically and transparently tries other nodes and schedules reconnection to the dead nodes in the background.
  • Cassandra trace handling: tracing can be set on a per-query basis and the driver provides a convenient API to retrieve the trace.
  • Convenient schema access: the driver exposes a Cassandra schema in a usable way.
  • Configurable retry policy: a retry policy can be set to define a precise behavior to adopt on query execution exceptions (for example, timeouts, unavailability). This avoids polluting client code with retry-related code.
  • Tunability: the default behavior of the driver can be changed or fine tuned by using tuning policies and connection options.

Queries can be executed synchronously or asynchronously, prepared statements are supported, and LINQ can be used to embed queries directly into C# code.