lib/policies/load-balancing.js
function WhiteListPolicy (childPolicy, whiteList) {
  if (!childPolicy) {
    throw new Error("You must specify a child load balancing policy");
  }
  if (!util.isArray(whiteList)) {
    throw new Error("You must provide the white list of host addresses");
  }
  this.childPolicy = childPolicy;
  const map = {};
  whiteList.forEach(function (address) {
    map[address] = true;
  });
  this.whiteList = map;
}
function WhiteListPolicy (childPolicy, whiteList) {
  if (!childPolicy) {
    throw new Error("You must specify a child load balancing policy");
  }
  if (!util.isArray(whiteList)) {
    throw new Error("You must provide the white list of host addresses");
  }
  this.childPolicy = childPolicy;
  const map = {};
  whiteList.forEach(function (address) {
    map[address] = true;
  });
  this.whiteList = map;
}
Create a new policy that wraps the provided child policy but only "allow" hosts
from the provided while list.
@class
@classdesc
A load balancing policy wrapper that ensure that only hosts from a provided
white list will ever be returned.
<p>
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.
<p>
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.
@param {LoadBalancingPolicy} childPolicy the wrapped policy.
@param {Array.<string>}  whiteList 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
@constructor