Skip to content

Commit 7233016

Browse files
authored
JAVA-2945: Reinstate InternalDriverContext.getNodeFilter method (#1553)
1 parent 0861f11 commit 7233016

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

changelog/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
### 4.11.2 (in progress)
66

7+
- [bug] JAVA-2945: Reinstate InternalDriverContext.getNodeFilter method
78
- [bug] JAVA-2946: Make MapperResultProducerService instances be located with user-provided class loader
89
- [bug] JAVA-2942: GraphStatement.setConsistencyLevel() is not effective
910
- [bug] JAVA-2941: Cannot add a single static column with the alter table API

core/src/main/java/com/datastax/oss/driver/internal/core/context/DefaultDriverContext.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ public class DefaultDriverContext implements InternalDriverContext {
225225
private final SchemaChangeListener schemaChangeListenerFromBuilder;
226226
private final RequestTracker requestTrackerFromBuilder;
227227
private final Map<String, String> localDatacentersFromBuilder;
228+
private final Map<String, Predicate<Node>> nodeFiltersFromBuilder;
228229
private final Map<String, NodeDistanceEvaluator> nodeDistanceEvaluatorsFromBuilder;
229230
private final ClassLoader classLoader;
230231
private final InetSocketAddress cloudProxyAddress;
@@ -277,6 +278,9 @@ public DefaultDriverContext(
277278
"sslEngineFactory",
278279
() -> buildSslEngineFactory(programmaticArguments.getSslEngineFactory()),
279280
cycleDetector);
281+
@SuppressWarnings("deprecation")
282+
Map<String, Predicate<Node>> nodeFilters = programmaticArguments.getNodeFilters();
283+
this.nodeFiltersFromBuilder = nodeFilters;
280284
this.nodeDistanceEvaluatorsFromBuilder = programmaticArguments.getNodeDistanceEvaluators();
281285
this.classLoader = programmaticArguments.getClassLoader();
282286
this.cloudProxyAddress = programmaticArguments.getCloudProxyAddress();
@@ -909,6 +913,13 @@ public String getLocalDatacenter(@NonNull String profileName) {
909913
return localDatacentersFromBuilder.get(profileName);
910914
}
911915

916+
@Nullable
917+
@Override
918+
@Deprecated
919+
public Predicate<Node> getNodeFilter(@NonNull String profileName) {
920+
return nodeFiltersFromBuilder.get(profileName);
921+
}
922+
912923
@Nullable
913924
@Override
914925
public NodeDistanceEvaluator getNodeDistanceEvaluator(@NonNull String profileName) {

core/src/main/java/com/datastax/oss/driver/internal/core/context/InternalDriverContext.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import com.datastax.oss.driver.api.core.context.DriverContext;
1919
import com.datastax.oss.driver.api.core.loadbalancing.NodeDistanceEvaluator;
20+
import com.datastax.oss.driver.api.core.metadata.Node;
2021
import com.datastax.oss.driver.api.core.session.SessionBuilder;
2122
import com.datastax.oss.driver.internal.core.ConsistencyLevelRegistry;
2223
import com.datastax.oss.driver.internal.core.ProtocolVersionRegistry;
@@ -49,6 +50,7 @@
4950
import java.util.List;
5051
import java.util.Map;
5152
import java.util.Optional;
53+
import java.util.function.Predicate;
5254

5355
/** Extends the driver context with additional components that are not exposed by our public API. */
5456
public interface InternalDriverContext extends DriverContext {
@@ -136,6 +138,17 @@ public interface InternalDriverContext extends DriverContext {
136138
@Nullable
137139
String getLocalDatacenter(@NonNull String profileName);
138140

141+
/**
142+
* This is the filter from {@link SessionBuilder#withNodeFilter(String, Predicate)}. If the filter
143+
* for this profile was specified through the configuration instead, this method will return
144+
* {@code null}.
145+
*
146+
* @deprecated Use {@link #getNodeDistanceEvaluator(String)} instead.
147+
*/
148+
@Nullable
149+
@Deprecated
150+
Predicate<Node> getNodeFilter(@NonNull String profileName);
151+
139152
/**
140153
* This is the node distance evaluator from {@link
141154
* SessionBuilder#withNodeDistanceEvaluator(String, NodeDistanceEvaluator)}. If the evaluator for

0 commit comments

Comments
 (0)