Class: WhiteListPolicy

policies/loadBalancing~ WhiteListPolicy

A load balancing policy wrapper that ensure that only hosts from a provided white list will ever be returned.

This policy wraps another load balancing policy and will delegate the choice of hosts to the wrapped policy with the exception that only hosts contained in the white list provided when constructing this policy will ever be returned. Any host not in the while list will be considered ignored and thus will not be connected to.

This policy can be useful to ensure that the driver only connects to a predefined set of hosts. Keep in mind however that this policy defeats somewhat the host auto-detection of the driver. As such, this policy is only useful in a few special cases or for testing, but is not optimal in general. If all you want to do is limiting connections to hosts of the local data-center then you should use DCAwareRoundRobinPolicy and *not* this policy in particular.

Constructor

new WhiteListPolicy(childPolicy, whiteList)

Create a new policy that wraps the provided child policy but only "allow" hosts from the provided while list.
Parameters:
Name Type Description
childPolicy LoadBalancingPolicy the wrapped policy.
whiteList Array.<string> the white listed hosts address in the format ipAddress:port. Only hosts from this list may get connected to (whether they will get connected to or not depends on the child policy).

Extends

  • LoadBalancingPolicy

Methods

getDistance(host)

Uses the child policy to return the distance to the host if included in the white list. Any host not in the while list will be considered ignored.
Parameters:
Name Type Description
host

newQueryPlan()

Returns the hosts to use for a new query filtered by the white list.