Skip to content
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

Fix cluster uri resolution #5869

Merged
merged 3 commits into from
Nov 16, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import org.neo4j.cluster.member.ClusterMemberAvailability;
import org.neo4j.cluster.member.ClusterMemberEvents;
import org.neo4j.cluster.member.ClusterMemberListener;
import org.neo4j.com.ServerUtil;
import org.neo4j.com.monitor.RequestMonitor;
import org.neo4j.com.storecopy.StoreCopyServer;
import org.neo4j.function.Supplier;
Expand Down Expand Up @@ -245,7 +244,7 @@ private ClusterMemberAvailability getClusterMemberAvailability() {
}

private URI createBackupURI() {
String hostString = ServerUtil.getHostString( server.getSocketAddress() );
String hostString = server.getSocketAddress().getHostString();
String host = hostString.contains( INADDR_ANY ) ? me.getHost() : hostString;
int port = server.getSocketAddress().getPort();
return URI.create("backup://" + host + ":" + port);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,19 +240,14 @@ public void receive( Message message )

private URI getURI( InetSocketAddress address ) throws URISyntaxException
{
String uri;
// Socket.toString() already prepends a '/'
String uri = CLUSTER_SCHEME + "://" + address.getHostString() + ":" + address.getPort();

if ( address.getAddress().getHostAddress().startsWith( "0" ) )
uri = CLUSTER_SCHEME + "://0.0.0.0:" + address.getPort(); // Socket.toString() already prepends a /
else
// Add name if given
if ( config.name() != null )
{
uri = CLUSTER_SCHEME + "://" + address.getAddress().getHostName() + ":" + address.getPort(); // Socket
uri += "/?name=" + config.name();
}
// .toString() already prepends a /

// Add name if given
if (config.name() != null)
uri += "/?name="+config.name();

return URI.create( uri );
}
Expand Down
46 changes: 0 additions & 46 deletions enterprise/com/src/main/java/org/neo4j/com/ServerUtil.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import org.neo4j.cluster.ClusterSettings;
import org.neo4j.cluster.InstanceId;
import org.neo4j.cluster.member.ClusterMemberAvailability;
import org.neo4j.com.ServerUtil;
import org.neo4j.function.BiFunction;
import org.neo4j.function.Factory;
import org.neo4j.function.Supplier;
Expand Down Expand Up @@ -125,9 +124,9 @@ public URI switchToMaster( LifeSupport haCommunicationLife, URI me )

private URI getMasterUri( URI me, MasterServer masterServer )
{
String hostname = config.get( HaSettings.ha_server ).getHost( ServerUtil.getHostString( masterServer.getSocketAddress() ).contains( "0.0.0.0" ) ?
me.getHost() :
ServerUtil.getHostString( masterServer.getSocketAddress() ));
String hostname = config.get( HaSettings.ha_server ).getHost(
masterServer.getSocketAddress().getHostString().contains( "0.0.0.0" ) ? me.getHost()
: masterServer.getSocketAddress().getHostString() );

int port = masterServer.getSocketAddress().getPort();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import org.neo4j.com.RequestContext;
import org.neo4j.com.Response;
import org.neo4j.com.Server;
import org.neo4j.com.ServerUtil;
import org.neo4j.com.storecopy.StoreCopyClient;
import org.neo4j.com.storecopy.StoreWriter;
import org.neo4j.com.storecopy.TransactionCommittingResponseUnpacker;
Expand Down Expand Up @@ -506,7 +505,7 @@ private boolean catchUpWithMaster( UpdatePuller updatePuller ) throws IllegalArg

private URI createHaURI( URI me, Server<?,?> server )
{
String hostString = ServerUtil.getHostString( server.getSocketAddress() );
String hostString = server.getSocketAddress().getHostString();
int port = server.getSocketAddress().getPort();
InstanceId serverId = config.get( ClusterSettings.server_id );
String host = hostString.contains( HighAvailabilityModeSwitcher.INADDR_ANY ) ? me.getHost() : hostString;
Expand Down