Search in sources :

Example 11 with ClusterManager

use of org.neo4j.kernel.impl.ha.ClusterManager in project neo4j by neo4j.

the class FailoverWithAdditionalSlaveFailuresIT method testFailoverWithAdditionalSlave.

private void testFailoverWithAdditionalSlave(int clusterSize, int[] slaveIndexes) throws Throwable {
    ClusterManager manager = new ClusterManager.Builder().withRootDirectory(dir.cleanDirectory("testcluster")).withCluster(ClusterManager.clusterOfSize(clusterSize)).build();
    try {
        manager.start();
        ClusterManager.ManagedCluster cluster = manager.getCluster();
        cluster.await(allSeesAllAsAvailable());
        cluster.await(masterAvailable());
        Collection<HighlyAvailableGraphDatabase> failed = new ArrayList<>();
        Collection<RepairKit> repairKits = new ArrayList<>();
        for (int slaveIndex : slaveIndexes) {
            HighlyAvailableGraphDatabase nthSlave = getNthSlave(cluster, slaveIndex);
            failed.add(nthSlave);
            RepairKit repairKit = cluster.fail(nthSlave);
            repairKits.add(repairKit);
        }
        HighlyAvailableGraphDatabase oldMaster = cluster.getMaster();
        failed.add(oldMaster);
        repairKits.add(cluster.fail(oldMaster));
        cluster.await(masterAvailable(toArray(failed)));
        for (RepairKit repairKit : repairKits) {
            repairKit.repair();
        }
        // give repaired instances a chance to cleanly rejoin and exit faster
        Thread.sleep(3000);
    } finally {
        manager.safeShutdown();
    }
}
Also used : RepairKit(org.neo4j.kernel.impl.ha.ClusterManager.RepairKit) ArrayList(java.util.ArrayList) ClusterManager(org.neo4j.kernel.impl.ha.ClusterManager)

Example 12 with ClusterManager

use of org.neo4j.kernel.impl.ha.ClusterManager in project neo4j by neo4j.

the class ClusterTest method testClusterWithWildcardIP.

@Test
public void testClusterWithWildcardIP() throws Throwable {
    ClusterManager clusterManager = new ClusterManager.Builder(testDirectory.directory("testClusterWithWildcardIP")).withSharedConfig(stringMap(HaSettings.ha_server.name(), "0.0.0.0:6001-9999", HaSettings.tx_push_factor.name(), "2")).build();
    createClusterWithNode(clusterManager);
}
Also used : ClusterManager(org.neo4j.kernel.impl.ha.ClusterManager) Test(org.junit.Test)

Example 13 with ClusterManager

use of org.neo4j.kernel.impl.ha.ClusterManager in project neo4j by neo4j.

the class ClusterTest method lastTxCommitTimestampShouldGetInitializedOnSlaveIfNotPresent.

@Test
public void lastTxCommitTimestampShouldGetInitializedOnSlaveIfNotPresent() throws Throwable {
    ClusterManager clusterManager = new ClusterManager.Builder(testDirectory.directory("lastTxTimestamp")).withCluster(ClusterManager.clusterOfSize(3)).build();
    try {
        clusterManager.start();
        ClusterManager.ManagedCluster cluster = clusterManager.getCluster();
        cluster.await(allSeesAllAsAvailable());
        runSomeTransactions(cluster.getMaster());
        cluster.sync();
        HighlyAvailableGraphDatabase slave = cluster.getAnySlave();
        File storeDir = new File(slave.getStoreDir());
        ClusterManager.RepairKit slaveRepairKit = cluster.shutdown(slave);
        clearLastTransactionCommitTimestampField(storeDir);
        HighlyAvailableGraphDatabase repairedSlave = slaveRepairKit.repair();
        cluster.await(allSeesAllAsAvailable());
        assertEquals(lastCommittedTxTimestamp(cluster.getMaster()), lastCommittedTxTimestamp(repairedSlave));
    } finally {
        clusterManager.stop();
    }
}
Also used : HighlyAvailableGraphDatabase(org.neo4j.kernel.ha.HighlyAvailableGraphDatabase) ClusterManager(org.neo4j.kernel.impl.ha.ClusterManager) File(java.io.File) Test(org.junit.Test)

Example 14 with ClusterManager

use of org.neo4j.kernel.impl.ha.ClusterManager in project neo4j by neo4j.

the class ClusterTest method testClusterWithHostnames.

@Test
public void testClusterWithHostnames() throws Throwable {
    ClusterManager clusterManager = new ClusterManager.Builder(testDirectory.directory("testCluster")).withCluster(clusterOfSize("localhost", 3)).withSharedConfig(stringMap(HaSettings.ha_server.name(), "localhost:6001-9999", HaSettings.tx_push_factor.name(), "2")).build();
    createClusterWithNode(clusterManager);
}
Also used : ClusterManager(org.neo4j.kernel.impl.ha.ClusterManager) Test(org.junit.Test)

Example 15 with ClusterManager

use of org.neo4j.kernel.impl.ha.ClusterManager in project neo4j by neo4j.

the class ClusterTest method lastTxCommitTimestampShouldBeUnknownAfterStartIfNoFiledOrLogsPresent.

@Test
public void lastTxCommitTimestampShouldBeUnknownAfterStartIfNoFiledOrLogsPresent() throws Throwable {
    ClusterManager clusterManager = new ClusterManager.Builder(testDirectory.directory("lastTxTimestamp")).withCluster(ClusterManager.clusterOfSize(3)).build();
    try {
        clusterManager.start();
        ClusterManager.ManagedCluster cluster = clusterManager.getCluster();
        cluster.await(allSeesAllAsAvailable());
        runSomeTransactions(cluster.getMaster());
        cluster.sync();
        HighlyAvailableGraphDatabase slave = cluster.getAnySlave();
        File storeDir = new File(slave.getStoreDir());
        ClusterManager.RepairKit slaveRepairKit = cluster.shutdown(slave);
        clearLastTransactionCommitTimestampField(storeDir);
        deleteLogs(storeDir);
        HighlyAvailableGraphDatabase repairedSlave = slaveRepairKit.repair();
        cluster.await(allSeesAllAsAvailable());
        assertEquals(TransactionIdStore.UNKNOWN_TX_COMMIT_TIMESTAMP, lastCommittedTxTimestamp(repairedSlave));
    } finally {
        clusterManager.stop();
    }
}
Also used : HighlyAvailableGraphDatabase(org.neo4j.kernel.ha.HighlyAvailableGraphDatabase) ClusterManager(org.neo4j.kernel.impl.ha.ClusterManager) File(java.io.File) Test(org.junit.Test)

Aggregations

ClusterManager (org.neo4j.kernel.impl.ha.ClusterManager)17 Test (org.junit.Test)14 File (java.io.File)5 HighlyAvailableGraphDatabase (org.neo4j.kernel.ha.HighlyAvailableGraphDatabase)5 CountDownLatch (java.util.concurrent.CountDownLatch)4 Transaction (org.neo4j.graphdb.Transaction)3 ManagedCluster (org.neo4j.kernel.impl.ha.ClusterManager.ManagedCluster)3 RepairKit (org.neo4j.kernel.impl.ha.ClusterManager.RepairKit)3 IOException (java.io.IOException)2 GraphDatabaseService (org.neo4j.graphdb.GraphDatabaseService)2 LifeSupport (org.neo4j.kernel.lifecycle.LifeSupport)2 ArrayList (java.util.ArrayList)1 Map (java.util.Map)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 Label (org.neo4j.graphdb.Label)1 TransactionTerminatedException (org.neo4j.graphdb.TransactionTerminatedException)1