Skip to content

Commit

Permalink
Revert "Merge pull request #6592 from neo4j/testwin/2.2-origin-ip"
Browse files Browse the repository at this point in the history
This reverts commit 7a09807, reversing
changes made to 2283d0e.
  • Loading branch information
tinwelint committed Mar 4, 2016
1 parent 7a09807 commit f6305f3
Show file tree
Hide file tree
Showing 17 changed files with 216 additions and 149 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,7 @@ public URI apply( HostnamePort member )
{
try
{
console.log( "Joined cluster:" +
clusterConfig.get( config.getClusterJoinTimeout(), TimeUnit.MILLISECONDS ) );
console.log( "Joined cluster:" + clusterConfig.get(config.getClusterJoinTimeout(), TimeUnit.MILLISECONDS ));
return;
}
catch ( InterruptedException e )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,18 +203,6 @@ private static String localhost()
{
return "127.0.0.1";
}

public String getHostname()
{
if ( host.contains( ":" ) )
{
return host.substring( 0, host.indexOf( ":" ) );
}
else
{
return host;
}
}

public String getHost()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -397,11 +397,7 @@ private Channel openChannel( URI clusterUri )
SocketAddress destination = new InetSocketAddress( clusterUri.getHost(),
clusterUri.getPort() == -1 ? config.defaultPort() : clusterUri.getPort() );
// We must specify the origin address in case the server has multiple IPs per interface
SocketAddress origin = null;
if ( me.getHost() != null && !me.getHost().equals( "0.0.0.0" ) )
{
origin = new InetSocketAddress( me.getHost(), 0 );
}
SocketAddress origin = new InetSocketAddress( me.getHost(), 0 );

msgLog.info( "Attempting to connect from " + origin + " to " + destination );
ChannelFuture channelFuture = clientBootstrap.connect( destination, origin );
Expand Down
6 changes: 1 addition & 5 deletions enterprise/com/src/main/java/org/neo4j/com/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,7 @@ public Client( String destinationHostNameOrIp, int destinationPort, String origi
this.maxUnusedChannels = maxConcurrentChannels;
this.comExceptionHandler = getNoOpComExceptionHandler();
this.destination = new InetSocketAddress( destinationHostNameOrIp, destinationPort );
if (originHostNameOrIp == null || originHostNameOrIp.equals("0.0.0.0")) {
origin = null;
} else {
origin = new InetSocketAddress( originHostNameOrIp, 0);
}
origin = originHostNameOrIp == null ? null : new InetSocketAddress( originHostNameOrIp, 0);
this.protocol = createProtocol( chunkSize, protocolVersion.getApplicationProtocol() );
this.responseUnpacker = responseUnpacker;

Expand Down
14 changes: 8 additions & 6 deletions enterprise/ha/src/test/java/org/neo4j/ha/BackupHaIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@
*/
package org.neo4j.ha;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import org.apache.commons.io.FileUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import org.neo4j.backup.OnlineBackupSettings;
import org.neo4j.cluster.InstanceId;
import org.neo4j.graphdb.factory.GraphDatabaseBuilder;
Expand All @@ -42,6 +42,7 @@
import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;

import static org.neo4j.backup.BackupEmbeddedIT.createSomeData;
import static org.neo4j.backup.BackupEmbeddedIT.runBackupToolFromOtherJvmToGetExitCode;
import static org.neo4j.kernel.impl.ha.ClusterManager.allSeesAllAsAvailable;
Expand Down Expand Up @@ -70,7 +71,8 @@ public void setup() throws Throwable

private void startCluster() throws Throwable
{
clusterManager = new ClusterManager( ClusterManager.clusterOfSize( 3 ),
clusterManager = new ClusterManager( ClusterManager.fromXml( getClass().getResource( "/threeinstances.xml" )
.toURI() ),
PATH, MapUtil.stringMap( OnlineBackupSettings.online_backup_enabled.name(),
Settings.TRUE ) )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
*/
package org.neo4j.ha;

import java.util.concurrent.Callable;
import java.util.concurrent.FutureTask;

import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;

import java.util.concurrent.Callable;
import java.util.concurrent.FutureTask;

import org.neo4j.graphdb.Transaction;
import org.neo4j.helpers.collection.IteratorUtil;
import org.neo4j.kernel.api.exceptions.TransactionFailureException;
Expand All @@ -42,7 +42,7 @@
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import static org.neo4j.helpers.Exceptions.contains;
import static org.neo4j.kernel.impl.ha.ClusterManager.clusterOfSize;
import static org.neo4j.kernel.impl.ha.ClusterManager.fromXml;

public class ClusterTransactionIT
{
Expand All @@ -54,7 +54,8 @@ public class ClusterTransactionIT
@Before
public void setUp() throws Exception
{
cluster = clusterRule.provider( clusterOfSize( 3 ) )
cluster = clusterRule.provider( fromXml( getClass().getResource( "/threeinstances.xml" ).toURI() ) )
.config( HaSettings.ha_server, ":6001-6005" )
.config( HaSettings.tx_push_factor, "2" ).startCluster();

cluster.await( ClusterManager.allSeesAllAsAvailable() );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
*/
package org.neo4j.ha;

import java.io.File;

import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;

import java.io.File;

import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.Transaction;
Expand All @@ -38,6 +38,8 @@

import static org.junit.Assert.assertEquals;

import static org.neo4j.kernel.impl.ha.ClusterManager.fromXml;

/**
* Verify that we can run multiple clusters simultaneously
*/
Expand All @@ -52,8 +54,8 @@ public void runTwoClusters() throws Throwable
{
File root = TargetDirectory.forTest( getClass() ).cleanDirectory( "cluster" );

ClusterManager clusterManager = new ClusterManager( ClusterManager.clustersOfSize( 3, 3 ), root,
MapUtil.stringMap() );
ClusterManager clusterManager = new ClusterManager(
fromXml( getClass().getResource( "/twoclustertest.xml" ).toURI() ), root, MapUtil.stringMap() );

try
{
Expand All @@ -73,14 +75,14 @@ public void runTwoClusters() throws Throwable
tx.finish();
}

ManagedCluster cluster2 = clusterManager.getCluster( "neo4j.ha1" );
ManagedCluster cluster2 = clusterManager.getCluster( "neo4j.ha2" );
long cluster2NodeId;
{
GraphDatabaseService master = cluster2.getMaster();
logging.getLogger().info( "CREATE NODE" );
Transaction tx = master.beginTx();
Node node = master.createNode();
node.setProperty( "cluster", "neo4j.ha1" );
node.setProperty( "cluster", "neo4j.ha2" );
cluster2NodeId = node.getId();
logging.getLogger().info( "CREATED NODE" );
tx.success();
Expand All @@ -103,7 +105,7 @@ public void runTwoClusters() throws Throwable
highlyAvailableGraphDatabase.getDependencyResolver().resolveDependency( UpdatePuller.class ).pullUpdates();

Transaction transaction = highlyAvailableGraphDatabase.beginTx();
assertEquals( "neo4j.ha1", highlyAvailableGraphDatabase.getNodeById( cluster2NodeId ).getProperty(
assertEquals( "neo4j.ha2", highlyAvailableGraphDatabase.getNodeById( cluster2NodeId ).getProperty(
"cluster" ) );
transaction.finish();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,18 @@
import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;

import static org.neo4j.kernel.impl.ha.ClusterManager.fromXml;

public class TestClusterIndexDeletion
{
@Test
public void givenClusterWithCreatedIndexWhenDeleteIndexOnMasterThenIndexIsDeletedOnSlave() throws Throwable
{
ClusterManager clusterManager =
new ClusterManager( ClusterManager.clusterOfSize( 3 ),
new ClusterManager( fromXml( getClass().getResource( "/threeinstances.xml" ).toURI() ),
TargetDirectory.forTest( getClass() ).cleanDirectory( "testCluster" ),
MapUtil.stringMap( HaSettings.tx_push_factor.name(), "2" ));
MapUtil.stringMap( HaSettings.ha_server.name(), ":6001-6005",
HaSettings.tx_push_factor.name(), "2" ));
try
{
// Given
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@

import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;

import static org.neo4j.kernel.impl.ha.ClusterManager.allSeesAllAsAvailable;
import static org.neo4j.kernel.impl.ha.ClusterManager.fromXml;

public class TestSlaveOnlyCluster
{
Expand Down Expand Up @@ -106,7 +108,7 @@ public void testMasterElectionAfterSlaveOnlyInstancesStartFirst() throws Throwab
private ClusterManager createCluster( String dirname, int... slaveIds ) throws URISyntaxException
{
final File dir = directory.cleanDirectory( dirname );
final ClusterManager.Provider provider = ClusterManager.clusterOfSize( 3 );
final ClusterManager.Provider provider = fromXml( getClass().getResource( "/threeinstances.xml" ).toURI() );
final Map<Integer, Map<String, String>> instanceConfig = new HashMap<>( slaveIds.length );
for ( int slaveId : slaveIds )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,16 @@
*/
package org.neo4j.kernel.ha;

import java.util.Map;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;

import org.junit.Assume;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;

import java.util.Map;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;

import org.neo4j.cluster.ClusterSettings;
import org.neo4j.cluster.InstanceId;
import org.neo4j.cluster.client.ClusterClient;
Expand All @@ -43,7 +42,6 @@
import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.Transaction;
import org.neo4j.graphdb.factory.GraphDatabaseSettings;
import org.neo4j.helpers.Settings;
import org.neo4j.helpers.collection.MapUtil;
import org.neo4j.kernel.InternalAbstractGraphDatabase;
import org.neo4j.kernel.configuration.Config;
Expand Down Expand Up @@ -200,9 +198,6 @@ else if ( instanceIdOf( newSlave2 ).equals( unavailableId ) )
@Test
public void failedInstanceShouldReceiveCorrectCoordinatorIdUponRejoiningCluster() throws Throwable
{
// Starting a duplicate clusterClient on Windows can give port conflicts
Assume.assumeFalse( Settings.osIsWindows() );

// Given
HighlyAvailableGraphDatabase initialMaster = cluster.getMaster();

Expand Down Expand Up @@ -263,8 +258,7 @@ private ClusterClient newClusterClient( InstanceId id )
Map<String,String> configMap = MapUtil.stringMap(
ClusterSettings.initial_hosts.name(), cluster.getInitialHostsConfigString(),
ClusterSettings.server_id.name(), String.valueOf( id.toIntegerIndex() ),
ClusterSettings.cluster_server.name(), "0.0.0.0:8888",
ClusterClient.clusterJoinTimeout.name(), "60s");
ClusterSettings.cluster_server.name(), "0.0.0.0:8888" );

Config config = new Config( configMap, InternalAbstractGraphDatabase.Configuration.class,
GraphDatabaseSettings.class );
Expand Down

0 comments on commit f6305f3

Please sign in to comment.