forked from neo4j/neo4j-java-driver
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix for initial routers DNS resolution
This update fixes the following issue: neo4j#833 The driver will resolve all initial router domain names to IPs and will try them all until one is successful. Additional items: - a new config option to make the domain name resolution configurable, which is currently used for testing - the testkit backend has been updated to support the domain name resolution configuration (a new test has been added to testkit to cover the issue described above) - the testkit backend has been updated to support connection timeout driver configuration - several tests have been updated
- Loading branch information
1 parent
47db433
commit 371e202
Showing
29 changed files
with
467 additions
and
177 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
driver/src/main/java/org/neo4j/driver/internal/DefaultDomainNameResolver.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright (c) "Neo4j" | ||
* Neo4j Sweden AB [http://neo4j.com] | ||
* | ||
* This file is part of Neo4j. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.neo4j.driver.internal; | ||
|
||
import java.net.InetAddress; | ||
import java.net.UnknownHostException; | ||
|
||
import org.neo4j.driver.net.DomainNameResolver; | ||
|
||
public class DefaultDomainNameResolver implements DomainNameResolver | ||
{ | ||
@Override | ||
public InetAddress[] resolve( String name ) throws UnknownHostException | ||
{ | ||
return InetAddress.getAllByName( name ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
driver/src/main/java/org/neo4j/driver/internal/async/connection/NettyDomainNameResolver.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* Copyright (c) "Neo4j" | ||
* Neo4j Sweden AB [http://neo4j.com] | ||
* | ||
* This file is part of Neo4j. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.neo4j.driver.internal.async.connection; | ||
|
||
import io.netty.resolver.InetNameResolver; | ||
import io.netty.util.concurrent.EventExecutor; | ||
import io.netty.util.concurrent.Promise; | ||
|
||
import java.net.InetAddress; | ||
import java.net.UnknownHostException; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
import org.neo4j.driver.net.DomainNameResolver; | ||
|
||
public class NettyDomainNameResolver extends InetNameResolver | ||
{ | ||
private final DomainNameResolver domainNameResolver; | ||
|
||
public NettyDomainNameResolver( EventExecutor executor, DomainNameResolver domainNameResolver ) | ||
{ | ||
super( executor ); | ||
this.domainNameResolver = domainNameResolver; | ||
} | ||
|
||
@Override | ||
protected void doResolve( String inetHost, Promise<InetAddress> promise ) | ||
{ | ||
try | ||
{ | ||
promise.setSuccess( domainNameResolver.resolve( inetHost )[0] ); | ||
} | ||
catch ( UnknownHostException e ) | ||
{ | ||
promise.setFailure( e ); | ||
} | ||
} | ||
|
||
@Override | ||
protected void doResolveAll( String inetHost, Promise<List<InetAddress>> promise ) | ||
{ | ||
try | ||
{ | ||
promise.setSuccess( Arrays.asList( domainNameResolver.resolve( inetHost ) ) ); | ||
} | ||
catch ( UnknownHostException e ) | ||
{ | ||
promise.setFailure( e ); | ||
} | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
...rc/main/java/org/neo4j/driver/internal/async/connection/NettyDomainNameResolverGroup.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright (c) "Neo4j" | ||
* Neo4j Sweden AB [http://neo4j.com] | ||
* | ||
* This file is part of Neo4j. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.neo4j.driver.internal.async.connection; | ||
|
||
import io.netty.resolver.AddressResolver; | ||
import io.netty.resolver.AddressResolverGroup; | ||
import io.netty.util.concurrent.EventExecutor; | ||
|
||
import java.net.InetSocketAddress; | ||
|
||
import org.neo4j.driver.net.DomainNameResolver; | ||
|
||
public class NettyDomainNameResolverGroup extends AddressResolverGroup<InetSocketAddress> | ||
{ | ||
private final DomainNameResolver domainNameResolver; | ||
|
||
public NettyDomainNameResolverGroup( DomainNameResolver domainNameResolver ) | ||
{ | ||
this.domainNameResolver = domainNameResolver; | ||
} | ||
|
||
@Override | ||
protected AddressResolver<InetSocketAddress> newResolver( EventExecutor executor ) throws Exception | ||
{ | ||
return new NettyDomainNameResolver( executor, domainNameResolver ).asAddressResolver(); | ||
} | ||
} |
Oops, something went wrong.