Skip to content

Resolve DNS to IP & IPv6 address support #332

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

Merged
merged 3 commits into from
Mar 22, 2017

Conversation

zhenlineo
Copy link
Contributor

No description provided.

Copy link
Contributor

@lutovich lutovich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zhenlineo review round completed. Do you think it is possible to add a boltkit test with some fake resolver to verify this feature end to end?

// Don't remove it from the set of routers, since that might mean we lose our ability to re-discover,
// just remove it from the set of readers and writers, so that we don't use it for actual work without
// performing discovery first.
routers.remove( address );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This #forget() method is also called on connection errors. Do we really want to drop routers here? I'd vote for not changing this and keeping #removeRouter().

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the point to keep in routing table? they were there to protect from running out of routers. Now we no longer have the problem with dns

import org.neo4j.driver.internal.net.BoltServerAddress;
import org.neo4j.driver.v1.exceptions.ServiceUnavailableException;

public interface DnsResolver
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we maybe have HostNameResolver interface and then DnsResolver as it's implementation?

try
{
InetAddress[] ipAddresses = InetAddress.getAllByName( initialRouter.host() );
Set<BoltServerAddress> addresses = new HashSet<>( ipAddresses.length );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Specified like this initial capacity might still cause HashSet to resize because of default load factor or 0.75. Maybe not bother with initial size at all? :)

}
catch ( UnknownHostException e )
{
throw new ServiceUnavailableException(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What will happen if seed uri is already an IP address? Will UnknownHostException be thrown?
What do you think about just logging failure here and returning Collections.singleton(initialRouter)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IP to IP is not a problem, the test include using 127.0.0.1

int size = routingTable.routerSize();
Set<BoltServerAddress> triedServers = new HashSet<>( size );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HashSet's initial capacity might be tricky here as well.

return rediscovery.lookupClusterComposition( connections, routingTable );
}

private static DnsResolver directMapProvider = new DnsResolver()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe introduce a private static class for this or move it to the top of the class? It is just a bit strange to see field in the middle of the class.

@Override
public Set<BoltServerAddress> resolve( BoltServerAddress initialRouter )
{
Set<BoltServerAddress> directMap = new HashSet<>( 1 );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could probably use Collections.singleton( initialRouter ) here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I cannot return any singlention set as it does not support removeAll method

@zhenlineo
Copy link
Contributor Author

zhenlineo commented Mar 17, 2017

@lutovich All boltkit tests that creates a real driver already go via DnsResolver

@zhenlineo zhenlineo merged commit bec13b3 into neo4j:1.2 Mar 22, 2017
@zhenlineo zhenlineo deleted the 1.2-dns-to-ips branch March 22, 2017 09:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants