Interface ICluster
Informations and known state of a Cassandra cluster.
This is the main entry point of the driver. A simple example of access to a Cassandra cluster would be:
Cluster cluster = Cluster.Builder.AddContactPoint("192.168.0.1").Build(); Session session = Cluster.Connect("db1"); foreach (var row in session.execute("SELECT * FROM table1")) //do something ...
A cluster object maintains a permanent connection to one of the cluster node that it uses solely to maintain informations on the state and current topology of the cluster. Using the connection, the driver will discover all the nodes composing the cluster as well as new nodes joining the cluster.
Inherited Members
Namespace: Dse
Assembly: Dse.dll
Syntax
public interface ICluster : IDisposable
Properties
Configuration
Cluster client configuration
Declaration
Configuration Configuration { get; }
Property Value
Type | Description |
---|---|
Configuration |
Metadata
Gets read-only metadata on the connected cluster.
This includes the know nodes (with their status as seen by the driver) as well as the schema definitions.
This method may trigger the creation of a connection if none has been established yet.
Declaration
Metadata Metadata { get; }
Property Value
Type | Description |
---|---|
Metadata |
Methods
AllHosts()
Returns all known hosts of this cluster.
Declaration
ICollection<Host> AllHosts()
Returns
Type | Description |
---|---|
System.Collections.Generic.ICollection<Host> |
Connect()
Creates a new session on this cluster.
Declaration
ISession Connect()
Returns
Type | Description |
---|---|
ISession | a new session on this cluster set to no keyspace. |
Connect(String)
Creates a new session on this cluster and sets a keyspace to use.
Declaration
ISession Connect(string keyspace)
Parameters
Type | Name | Description |
---|---|---|
System.String | keyspace | Case-sensitive keyspace name to use. |
Returns
Type | Description |
---|---|
ISession | a new session on this cluster set to keyspace: |
ConnectAsync()
Creates a new session on this cluster.
Declaration
Task<ISession> ConnectAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<ISession> |
ConnectAsync(String)
Creates a new session on this cluster and using a keyspace an existing keyspace.
Declaration
Task<ISession> ConnectAsync(string keyspace)
Parameters
Type | Name | Description |
---|---|---|
System.String | keyspace | Case-sensitive keyspace name to use |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<ISession> |
GetHost(IPEndPoint)
Get the host instance for a given Ip address.
Declaration
Host GetHost(IPEndPoint address)
Parameters
Type | Name | Description |
---|---|---|
System.Net.IPEndPoint | address | Ip address of the host |
Returns
Type | Description |
---|---|
Host | The host or null if not found |
GetReplicas(Byte[])
Gets a collection of replicas for a given partitionKey. Backward-compatibility only, use GetReplicas(keyspace, partitionKey) instead.
Declaration
ICollection<Host> GetReplicas(byte[] partitionKey)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | partitionKey | Byte array representing the partition key |
Returns
Type | Description |
---|---|
System.Collections.Generic.ICollection<Host> |
GetReplicas(String, Byte[])
Gets a collection of replicas for a given partitionKey on a given keyspace
Declaration
ICollection<Host> GetReplicas(string keyspace, byte[] partitionKey)
Parameters
Type | Name | Description |
---|---|---|
System.String | keyspace | Byte array representing the partition key |
System.Byte[] | partitionKey | Byte array representing the partition key |
Returns
Type | Description |
---|---|
System.Collections.Generic.ICollection<Host> |
RefreshSchema(String, String)
Updates keyspace metadata (including token metadata for token aware routing) for a given keyspace or a specific keyspace table. If no keyspace is provided then this method will update the metadata and token map for all the keyspaces of the cluster.
Declaration
bool RefreshSchema(string keyspace = null, string table = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | keyspace | |
System.String | table |
Returns
Type | Description |
---|---|
System.Boolean |
RefreshSchemaAsync(String, String)
Updates keyspace metadata (including token metadata for token aware routing) for a given keyspace or a specific keyspace table. If no keyspace is provided then this method will update the metadata and token map for all the keyspaces of the cluster.
Declaration
Task<bool> RefreshSchemaAsync(string keyspace = null, string table = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | keyspace | |
System.String | table |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Boolean> |
Shutdown(Int32)
Shutdown this cluster instance. This closes all connections from all the
sessions of this * Cluster
instance and reclaim all resources
used by it.
This method has no effect if the cluster was already shutdown.
Declaration
void Shutdown(int timeoutMs = -1)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | timeoutMs |
ShutdownAsync(Int32)
Shutdown this cluster instance asynchronously. This closes all connections from all the
sessions of this * Cluster
instance and reclaim all resources
used by it.
This method has no effect if the cluster was already shutdown.
Declaration
Task ShutdownAsync(int timeoutMs = -1)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | timeoutMs |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
Events
HostAdded
Event that gets triggered when a new host is added to the cluster
Declaration
event Action<Host> HostAdded
Event Type
Type | Description |
---|---|
System.Action<Host> |
HostRemoved
Event that gets triggered when a host has been removed from the cluster
Declaration
event Action<Host> HostRemoved
Event Type
Type | Description |
---|---|
System.Action<Host> |