Search in sources :

Example 21 with ManagedCluster

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

the class TxPushStrategyConfigIT method startCluster.

private ManagedCluster startCluster(int memberCount, final int pushFactor, final HaSettings.TxPushStrategy pushStrategy) throws Exception {
    ManagedCluster cluster = clusterRule.withCluster(clusterOfSize(memberCount)).withSharedSetting(HaSettings.tx_push_factor, "" + pushFactor).withSharedSetting(HaSettings.tx_push_strategy, pushStrategy.name()).startCluster();
    mapMachineIds(cluster);
    return cluster;
}
Also used : ManagedCluster(org.neo4j.kernel.impl.ha.ClusterManager.ManagedCluster)

Example 22 with ManagedCluster

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

the class TxPushStrategyConfigIT method slavesListGetsUpdatedWhenSlaveLeavesNicely.

@Test
public void slavesListGetsUpdatedWhenSlaveLeavesNicely() throws Exception {
    ManagedCluster cluster = startCluster(3, 1, HaSettings.TxPushStrategy.fixed_ascending);
    cluster.shutdown(cluster.getAnySlave());
    cluster.await(masterSeesSlavesAsAvailable(1));
}
Also used : ManagedCluster(org.neo4j.kernel.impl.ha.ClusterManager.ManagedCluster) Test(org.junit.Test)

Example 23 with ManagedCluster

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

the class TxPushStrategyConfigIT method shouldPushToSlavesInDescendingOrder.

@Test
public void shouldPushToSlavesInDescendingOrder() throws Exception {
    ManagedCluster cluster = startCluster(4, 2, HaSettings.TxPushStrategy.fixed_descending);
    for (int i = 0; i < 5; i++) {
        int missed = createTransactionOnMaster(cluster);
        assertLastTransactions(cluster, lastTx(THIRD_SLAVE, BASE_TX_ID + 1 + i, missed));
        assertLastTransactions(cluster, lastTx(SECOND_SLAVE, BASE_TX_ID + 1 + i, missed));
        assertLastTransactions(cluster, lastTx(FIRST_SLAVE, BASE_TX_ID, missed));
    }
}
Also used : ManagedCluster(org.neo4j.kernel.impl.ha.ClusterManager.ManagedCluster) Test(org.junit.Test)

Example 24 with ManagedCluster

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

the class TxPushStrategyConfigIT method slavesListGetsUpdatedWhenSlaveRageQuits.

@Test
public void slavesListGetsUpdatedWhenSlaveRageQuits() throws Throwable {
    ManagedCluster cluster = startCluster(3, 1, HaSettings.TxPushStrategy.fixed_ascending);
    cluster.fail(cluster.getAnySlave());
    cluster.await(masterSeesSlavesAsAvailable(1));
}
Also used : ManagedCluster(org.neo4j.kernel.impl.ha.ClusterManager.ManagedCluster) Test(org.junit.Test)

Example 25 with ManagedCluster

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

the class IdBufferingRoleSwitchIT method shouldNotSeeFreedIdsCrossRoleSwitch.

@Test
public void shouldNotSeeFreedIdsCrossRoleSwitch() throws Throwable {
    // GIVEN
    ManagedCluster cluster = clusterRule.startCluster();
    HighlyAvailableGraphDatabase firstMaster = cluster.getMaster();
    // WHEN
    // a node with a property
    Node node = createNodeWithProperties(firstMaster, 1);
    // sync cluster
    cluster.sync();
    // a transaction on master which deletes the property
    deleteNode(node, firstMaster);
    triggerIdMaintenance(firstMaster);
    // <-- this one reuses the same property id 0
    createNodeWithProperties(firstMaster, 1);
    // a transaction T on slave which will be kept open using a barrier
    GraphDatabaseAPI slave = cluster.getAnySlave();
    Barrier.Control barrier = new Barrier.Control();
    Future<Void> t = t2.execute(barrierControlledReadTransaction(slave, barrier));
    // pull updates on slave
    barrier.await();
    slave.getDependencyResolver().resolveDependency(UpdatePuller.class).pullUpdates();
    // a role switch
    cluster.shutdown(firstMaster);
    cluster.await(masterAvailable(firstMaster));
    // close T
    barrier.release();
    t.get();
    triggerIdMaintenance(slave);
    // THEN the deleted property record should now not be in freelist on new master
    // <-- this transaction should introduce inconsistencies
    createNodeWithProperties(slave, 10);
    // <-- CC will be run here since that's configured above ^^^
    cluster.stop();
}
Also used : GraphDatabaseAPI(org.neo4j.kernel.internal.GraphDatabaseAPI) ManagedCluster(org.neo4j.kernel.impl.ha.ClusterManager.ManagedCluster) Node(org.neo4j.graphdb.Node) Barrier(org.neo4j.test.Barrier) Test(org.junit.Test)

Aggregations

ManagedCluster (org.neo4j.kernel.impl.ha.ClusterManager.ManagedCluster)34 Test (org.junit.Test)32 HighlyAvailableGraphDatabase (org.neo4j.kernel.ha.HighlyAvailableGraphDatabase)16 Transaction (org.neo4j.graphdb.Transaction)15 Node (org.neo4j.graphdb.Node)13 InstanceId (org.neo4j.cluster.InstanceId)6 File (java.io.File)4 IndexDefinition (org.neo4j.graphdb.schema.IndexDefinition)4 WriteOperationsNotAllowedException (org.neo4j.graphdb.security.WriteOperationsNotAllowedException)4 ClusterManager (org.neo4j.kernel.impl.ha.ClusterManager)4 RepairKit (org.neo4j.kernel.impl.ha.ClusterManager.RepairKit)4 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)3 GraphDatabaseAPI (org.neo4j.kernel.internal.GraphDatabaseAPI)3 CountDownLatch (java.util.concurrent.CountDownLatch)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 CountsTracker (org.neo4j.kernel.impl.store.counts.CountsTracker)2 DbRepresentation (org.neo4j.test.DbRepresentation)2 Random (java.util.Random)1 ThreadLocalRandom (java.util.concurrent.ThreadLocalRandom)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1