Class RoundRobinPolicy
A Round-robin load balancing policy.
This policy queries nodes in a round-robin fashion. For a given query, if an host fail, the next one (following the round-robin order) is tried, until all hosts have been tried.
This policy is not datacenter aware and will include every known Cassandra host in its round robin algorithm. If you use multiple datacenter this will be inefficient and you will want to use the DCAwareRoundRobinPolicy load balancing policy instead.
Implements
Inherited Members
Namespace: Cassandra
Assembly: Cassandra.dll
Syntax
public class RoundRobinPolicy : ILoadBalancingPolicy
Methods
Distance(Host)
Return the HostDistance for the provided host.
This policy consider all nodes as local. This is generally the right thing to do in a single datacenter deployment. If you use multiple datacenter, see
DCAwareRoundRobinPolicy instead.Declaration
public HostDistance Distance(Host host)
Parameters
Type | Name | Description |
---|---|---|
Host | host | the host of which to return the distance of. |
Returns
Type | Description |
---|---|
HostDistance | the HostDistance to |
Initialize(ICluster)
Initialize this load balancing policy.
Note that the driver guarantees that it will call this method exactly once per policy object and will do so before any call to another of the methods of the policy.
Declaration
public void Initialize(ICluster cluster)
Parameters
Type | Name | Description |
---|---|---|
ICluster | cluster | The information about the session instance for which the policy is created. |
NewQueryPlan(string, IStatement)
Returns the hosts to use for a new query.
The returned plan will try each known host of the cluster. Upon each call to this method, the ith host of the plans returned will cycle over all the host of the cluster in a round-robin fashion.
Declaration
public IEnumerable<Host> NewQueryPlan(string keyspace, IStatement query)
Parameters
Type | Name | Description |
---|---|---|
string | keyspace | Keyspace on which the query is going to be executed |
IStatement | query | the query for which to build the plan. |
Returns
Type | Description |
---|---|
IEnumerable<Host> | a new query plan, i.e. an iterator indicating which host to try first for querying, which one to use as failover, etc... |