Search in sources :

Example 11 with TestHighlyAvailableGraphDatabaseFactory

use of org.neo4j.graphdb.factory.TestHighlyAvailableGraphDatabaseFactory in project neo4j by neo4j.

the class ClusterTest method testInstancesWithConflictingHaPorts.

@Test
public void testInstancesWithConflictingHaPorts() throws Throwable {
    HighlyAvailableGraphDatabase first = null;
    try {
        File storeDir = testDirectory.directory("testConflictingHaPorts");
        first = (HighlyAvailableGraphDatabase) new TestHighlyAvailableGraphDatabaseFactory().newEmbeddedDatabaseBuilder(storeDir).setConfig(ClusterSettings.initial_hosts, "127.0.0.1:5001").setConfig(ClusterSettings.cluster_server, "127.0.0.1:5001").setConfig(ClusterSettings.server_id, "1").setConfig(HaSettings.ha_server, "127.0.0.1:6666").newGraphDatabase();
        try {
            HighlyAvailableGraphDatabase failed = (HighlyAvailableGraphDatabase) new TestHighlyAvailableGraphDatabaseFactory().newEmbeddedDatabaseBuilder(storeDir).setConfig(ClusterSettings.initial_hosts, "127.0.0.1:5001").setConfig(ClusterSettings.cluster_server, "127.0.0.1:5002").setConfig(ClusterSettings.server_id, "2").setConfig(HaSettings.ha_server, "127.0.0.1:6666").newGraphDatabase();
            failed.shutdown();
            fail("Should not start when ports conflict");
        } catch (Exception e) {
        // good
        }
    } finally {
        if (first != null) {
            first.shutdown();
        }
    }
}
Also used : HighlyAvailableGraphDatabase(org.neo4j.kernel.ha.HighlyAvailableGraphDatabase) TestHighlyAvailableGraphDatabaseFactory(org.neo4j.graphdb.factory.TestHighlyAvailableGraphDatabaseFactory) File(java.io.File) TransientTransactionFailureException(org.neo4j.graphdb.TransientTransactionFailureException) IOException(java.io.IOException) TransactionTerminatedException(org.neo4j.graphdb.TransactionTerminatedException) Test(org.junit.Test)

Example 12 with TestHighlyAvailableGraphDatabaseFactory

use of org.neo4j.graphdb.factory.TestHighlyAvailableGraphDatabaseFactory in project neo4j by neo4j.

the class TestInstanceJoin method start.

private static HighlyAvailableGraphDatabase start(File storeDir, int i, Map<String, String> additionalConfig) {
    HighlyAvailableGraphDatabase db = (HighlyAvailableGraphDatabase) new TestHighlyAvailableGraphDatabaseFactory().newEmbeddedDatabaseBuilder(storeDir).setConfig(ClusterSettings.cluster_server, "127.0.0.1:" + (5001 + i)).setConfig(ClusterSettings.server_id, i + "").setConfig(HaSettings.ha_server, "127.0.0.1:" + (6666 + i)).setConfig(HaSettings.pull_interval, "0ms").setConfig(additionalConfig).newGraphDatabase();
    awaitStart(db);
    return db;
}
Also used : HighlyAvailableGraphDatabase(org.neo4j.kernel.ha.HighlyAvailableGraphDatabase) TestHighlyAvailableGraphDatabaseFactory(org.neo4j.graphdb.factory.TestHighlyAvailableGraphDatabaseFactory)

Example 13 with TestHighlyAvailableGraphDatabaseFactory

use of org.neo4j.graphdb.factory.TestHighlyAvailableGraphDatabaseFactory in project neo4j by neo4j.

the class ClusterTest method testInstancesWithConflictingClusterPorts.

@Test
public void testInstancesWithConflictingClusterPorts() throws Throwable {
    HighlyAvailableGraphDatabase first = null;
    try {
        File masterStoreDir = testDirectory.directory("testConflictingClusterPortsMaster");
        first = (HighlyAvailableGraphDatabase) new TestHighlyAvailableGraphDatabaseFactory().newEmbeddedDatabaseBuilder(masterStoreDir).setConfig(ClusterSettings.initial_hosts, "127.0.0.1:5001").setConfig(ClusterSettings.cluster_server, "127.0.0.1:5001").setConfig(ClusterSettings.server_id, "1").setConfig(HaSettings.ha_server, "127.0.0.1:6666").newGraphDatabase();
        try {
            File slaveStoreDir = testDirectory.directory("testConflictingClusterPortsSlave");
            HighlyAvailableGraphDatabase failed = (HighlyAvailableGraphDatabase) new TestHighlyAvailableGraphDatabaseFactory().newEmbeddedDatabaseBuilder(slaveStoreDir).setConfig(ClusterSettings.initial_hosts, "127.0.0.1:5001").setConfig(ClusterSettings.cluster_server, "127.0.0.1:5001").setConfig(ClusterSettings.server_id, "2").setConfig(HaSettings.ha_server, "127.0.0.1:6667").newGraphDatabase();
            failed.shutdown();
            fail("Should not start when ports conflict");
        } catch (Exception e) {
        // good
        }
    } finally {
        if (first != null) {
            first.shutdown();
        }
    }
}
Also used : HighlyAvailableGraphDatabase(org.neo4j.kernel.ha.HighlyAvailableGraphDatabase) TestHighlyAvailableGraphDatabaseFactory(org.neo4j.graphdb.factory.TestHighlyAvailableGraphDatabaseFactory) File(java.io.File) TransientTransactionFailureException(org.neo4j.graphdb.TransientTransactionFailureException) IOException(java.io.IOException) TransactionTerminatedException(org.neo4j.graphdb.TransactionTerminatedException) Test(org.junit.Test)

Aggregations

TestHighlyAvailableGraphDatabaseFactory (org.neo4j.graphdb.factory.TestHighlyAvailableGraphDatabaseFactory)13 File (java.io.File)10 Test (org.junit.Test)9 HighlyAvailableGraphDatabase (org.neo4j.kernel.ha.HighlyAvailableGraphDatabase)4 Transaction (org.neo4j.graphdb.Transaction)3 IOException (java.io.IOException)2 TransactionTerminatedException (org.neo4j.graphdb.TransactionTerminatedException)2 TransientTransactionFailureException (org.neo4j.graphdb.TransientTransactionFailureException)2 GraphDatabaseAPI (org.neo4j.kernel.internal.GraphDatabaseAPI)2 URI (java.net.URI)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 After (org.junit.After)1 Assert.assertEquals (org.junit.Assert.assertEquals)1 Assert.assertTrue (org.junit.Assert.assertTrue)1 Before (org.junit.Before)1 Rule (org.junit.Rule)1 InstanceId (org.neo4j.cluster.InstanceId)1 ClusterClient (org.neo4j.cluster.client.ClusterClient)1 ClusterListener (org.neo4j.cluster.protocol.cluster.ClusterListener)1 GraphDatabaseService (org.neo4j.graphdb.GraphDatabaseService)1