C# Class CqlSharp.Network.BalancedConnectionStrategy

This implementation attempts to balance the connections over the cluster based on load. First it will try to reuse an existing connection. If no connections exist, or if all connection loads are larger than the newConnectionTreshold, a new connection is created at a node with an as low as possible load. If that fails (e.g. because the max amount of connections per node is reached), an attempt is made to select the least used connection from the least used node.
Inheritance: IConnectionStrategy
Show file Open project: reuzel/CqlSharp Class Usage Examples

Public Methods

Method Description
BalancedConnectionStrategy ( Ring nodes, CqlConnectionStringBuilder config ) : System.Linq

Initializes the strategy with the specified nodes and cluster configuration

GetOrCreateConnection ( ConnectionScope scope, PartitionKey partitionKey ) : Connection

Gets or creates connection to the cluster.

ReturnConnection ( Connection connection, ConnectionScope scope ) : void

Invoked when a connection is no longer in use by the application

Method Details

BalancedConnectionStrategy() public method

Initializes the strategy with the specified nodes and cluster configuration
public BalancedConnectionStrategy ( Ring nodes, CqlConnectionStringBuilder config ) : System.Linq
nodes Ring The nodes.
config CqlConnectionStringBuilder The config.
return System.Linq

GetOrCreateConnection() public method

Gets or creates connection to the cluster.
public GetOrCreateConnection ( ConnectionScope scope, PartitionKey partitionKey ) : Connection
scope ConnectionScope
partitionKey PartitionKey
return Connection

ReturnConnection() public method

Invoked when a connection is no longer in use by the application
public ReturnConnection ( Connection connection, ConnectionScope scope ) : void
connection Connection The connection no longer used.
scope ConnectionScope
return void