Search in sources :

Example 16 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 17 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