-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Resolver interface and implementations #332
Add Resolver interface and implementations #332
Conversation
I think this might be a little overzealous in replacing all found calls to InetAddress in core module, I'll probably revert codecs, clients etc. to direct calls. For our use case it's probably most important to plug it in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's hook into ChannelFactory
:
ChannelFuture connectFuture = bootstrap.connect(RESOLVER.resolve(endPoint.resolve()));
core/src/main/java/com/datastax/dse/driver/internal/core/insights/InsightsClient.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/datastax/oss/driver/internal/core/resolver/MockResolver.java
Outdated
Show resolved
Hide resolved
62904d3
to
a4118a3
Compare
integration-tests/src/test/java/com/datastax/oss/driver/core/cql/SecondTraceIT.java
Outdated
Show resolved
Hide resolved
integration-tests/src/test/java/com/datastax/oss/driver/core/cql/SecondTraceIT.java
Outdated
Show resolved
Hide resolved
integration-tests/src/test/java/com/datastax/oss/driver/core/cql/SecondTraceIT.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/datastax/oss/driver/internal/core/resolver/MockResolver.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/datastax/oss/driver/internal/core/resolver/MockResolverFactory.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/datastax/oss/driver/internal/core/resolver/MockResolverResultSource.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/datastax/oss/driver/internal/core/resolver/UnknownHostResponse.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/datastax/oss/driver/internal/core/resolver/ValidResponse.java
Outdated
Show resolved
Hide resolved
core/src/test/java/com/datastax/oss/driver/internal/core/channel/ChannelFactoryTestBase.java
Outdated
Show resolved
Hide resolved
...rc/test/java/com/datastax/oss/driver/internal/core/resolver/MockResolverTestImplFactory.java
Outdated
Show resolved
Hide resolved
Adds tiny utility method to CcmBridge.
a7f8918
to
8fc4afa
Compare
"node-1.cluster.fake", | ||
new ValidResponse(new InetAddress[] {getNodeInetAddress(ccmBridge, 1)})); | ||
MockResolverFactory resolverFactory = new MockResolverFactory(); | ||
resolverFactory.addResponses(map); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use addResponse
here
...in/java/com/datastax/oss/driver/internal/core/resolver/mockResolver/MockResolverFactory.java
Outdated
Show resolved
Hide resolved
...in/java/com/datastax/oss/driver/internal/core/resolver/mockResolver/MockResolverFactory.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/datastax/oss/driver/internal/core/resolver/Resolver.java
Show resolved
Hide resolved
core/src/main/java/com/datastax/oss/driver/internal/core/resolver/AbstractResolverFactory.java
Outdated
Show resolved
Hide resolved
.../src/main/java/com/datastax/oss/driver/internal/core/resolver/mockResolver/MockResolver.java
Outdated
Show resolved
Hide resolved
.../src/main/java/com/datastax/oss/driver/internal/core/resolver/mockResolver/MockResolver.java
Outdated
Show resolved
Hide resolved
integration-tests/src/test/java/com/datastax/oss/driver/core/resolver/MockResolverIT.java
Show resolved
Hide resolved
.../src/main/java/com/datastax/oss/driver/internal/core/resolver/mockResolver/MockResolver.java
Outdated
Show resolved
Hide resolved
...in/java/com/datastax/oss/driver/internal/core/resolver/mockResolver/MockResolverFactory.java
Outdated
Show resolved
Hide resolved
8fc4afa
to
a2eb2cb
Compare
Applied all suggestions with minor fixes. |
a2eb2cb
to
ae252e0
Compare
Changed logic of checking for "unresolvedness". Turns out Java 8 has different toString implementation than the version I used. |
Adds a middleman between driver and all direct calls to InetAddress. This is meant to help with testing in case there is a need to substitute name resolution with resolution by specific ip address without modifying system environment or providing custom DNS server. Default implementation redirects all calls to InetAddress class which should not introduce change in behaviour. One introduced downside is that if the methods are to be customizable then the interface cannot have them `static`. Adds also implementation of MockResolver that has its own mapping of hostnames to addresses. Adds MockResolverIT.
ae252e0
to
ee82cf3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Bouncheck , thanks, great job, it looks amazing and we going to get a lot out of it.
Requested modification to allow for more control over hostname resolution when testing.
Adds a set of Resolver classes and factories and hooks them into necessary places.
See commit messages and javadoc for more details.