A load-balancing policy implementation that attempts to fairly distribute the load based on the amount of in-flight request per hosts. The local replicas are initially shuffled and between the first two nodes in the shuffled list, the one with fewer in-flight requests is selected as coordinator.

Additionally, it detects unresponsive replicas and reorders them at the back of the query plan.

For graph analytics queries, it uses the preferred analytics graph server previously obtained by driver as first host in the query plan.




([String or Object options])

Creates a new instance of DseLoadBalancingPolicy.

Name Type Description
options optional String or Object

The local data center name or the optional policy options object.

Note that when providing the local data center name, it overrides localDataCenter option at Client level.

options.localDc optional String

local data center name. This value overrides the ‘localDataCenter’ Client option and is useful for cases where you have multiple execution profiles that you intend on using for routing requests to different data centers.

options.filter optional function

A function to apply to determine if hosts are included in the query plan. The function takes a Host parameter and returns a Boolean.



(Host host)

Returns the distance assigned by this policy to the provided host, relatively to the client instance.

Name Type Description
host Host



Gets an associative array containing the policy options.


(Client client, HostMap hosts, function callback)

Initializes the load balancing policy, called after the driver obtained the information of the cluster.

Name Type Description
client Client
hosts HostMap
callback function


(String keyspace, ExecutionOptions executionOptions, function callback)

Returns a host iterator to be used for a query execution.

Name Type Description
keyspace String
executionOptions ExecutionOptions
callback function


(Array<Host> replicas)

Yields the local replicas followed by the rest of local nodes.

Name Type Description
replicas Array<Host>

The local replicas