Augments

  • LoadBalancingPolicy

Members

Array

localHostsArray

Array

remoteHostsArray

Constructor

new

DCAwareRoundRobinPolicy

([?String localDc], [Number usedHostsPerRemoteDc])

A data-center aware Round-robin load balancing policy. This policy provides round-robin queries over the node of the local data center. It also includes in the query plans returned a configurable number of hosts in the remote data centers, but those are always tried after the local nodes. In other words, this policy guarantees that no host in a remote data center will be queried unless no host in the local data center can be reached.

Parameters:
Name Type Description
localDc optional nullable String

local datacenter name.

usedHostsPerRemoteDc optional Number

the number of host per remote datacenter that the policy will yield \ in a newQueryPlan after the local nodes.

Methods

getDistance

(Host host)

Returns the distance depending on the datacenter.

Parameters:
Name Type Description
host Host

init

(Client client, HostMap hosts, function callback)

Initializes the load balancing policy.

Parameters:
Name Type Description
client Client
hosts HostMap
callback function

newQueryPlan

(String keyspace, QueryOptions queryOptions, function callback)

It returns an iterator that yields local nodes first and remotes nodes afterwards. The amount of remote nodes returned will depend on the usedHostsPerRemoteDc

Parameters:
Name Type Description
keyspace String

Name of currently logged keyspace at Client level.

queryOptions QueryOptions

Options related to this query execution.

callback function

The function to be invoked with the error as first parameter and the host iterator as second parameter.