use of com.datastax.oss.driver.internal.core.loadbalancing.nodeset.MultiDcNodeSet in project java-driver by datastax.
the class BasicLoadBalancingPolicy method init.
@Override
public void init(@NonNull Map<UUID, Node> nodes, @NonNull DistanceReporter distanceReporter) {
this.distanceReporter = distanceReporter;
localDc = discoverLocalDc(nodes).orElse(null);
nodeDistanceEvaluator = createNodeDistanceEvaluator(localDc, nodes);
liveNodes = localDc == null ? new DcAgnosticNodeSet() : maxNodesPerRemoteDc <= 0 ? new SingleDcNodeSet(localDc) : new MultiDcNodeSet();
for (Node node : nodes.values()) {
NodeDistance distance = computeNodeDistance(node);
distanceReporter.setDistance(node, distance);
if (distance != NodeDistance.IGNORED && node.getState() != NodeState.DOWN) {
// This includes state == UNKNOWN. If the node turns out to be unreachable, this will be
// detected when we try to open a pool to it, it will get marked down and this will be
// signaled back to this policy, which will then remove it from the live set.
liveNodes.add(node);
}
}
}
Aggregations