use of com.datastax.oss.driver.api.core.loadbalancing.NodeDistanceEvaluator in project java-driver by datastax.
the class DefaultNodeDistanceEvaluatorHelper method nodeDistanceEvaluatorFromConfig.
@NonNull
protected NodeDistanceEvaluator nodeDistanceEvaluatorFromConfig() {
NodeDistanceEvaluator evaluator = context.getNodeDistanceEvaluator(profile.getName());
if (evaluator != null) {
LOG.debug("[{}] Node distance evaluator set programmatically", logPrefix);
} else {
evaluator = Reflection.buildFromConfig(context, profile.getName(), DefaultDriverOption.LOAD_BALANCING_DISTANCE_EVALUATOR_CLASS, NodeDistanceEvaluator.class).orElse(null);
if (evaluator != null) {
LOG.debug("[{}] Node distance evaluator set from configuration", logPrefix);
} else {
@SuppressWarnings({ "unchecked", "deprecation" }) Predicate<Node> nodeFilterFromConfig = Reflection.buildFromConfig(context, profile.getName(), DefaultDriverOption.LOAD_BALANCING_FILTER_CLASS, Predicate.class).orElse(null);
if (nodeFilterFromConfig != null) {
evaluator = new NodeFilterToDistanceEvaluatorAdapter(nodeFilterFromConfig);
LOG.debug("[{}] Node distance evaluator set from deprecated node filter configuration", logPrefix);
}
}
}
if (evaluator == null) {
evaluator = PASS_THROUGH_DISTANCE_EVALUATOR;
}
return evaluator;
}
Aggregations