Search in sources :

Example 51 with Cluster

use of org.neo4j.causalclustering.discovery.Cluster in project neo4j by neo4j.

the class ClusterOverviewIT method shouldDiscoverRemovalOfReadReplicas.

@Test
public void shouldDiscoverRemovalOfReadReplicas() throws Exception {
    // given
    clusterRule.withNumberOfCoreMembers(3);
    clusterRule.withNumberOfReadReplicas(3);
    Cluster cluster = clusterRule.startCluster();
    for (int coreServerId = 0; coreServerId < 3; coreServerId++) {
        assertEventualOverview(cluster, containsRole(READ_REPLICA, 3), coreServerId);
    }
    // when
    cluster.removeReadReplicaWithMemberId(0);
    cluster.removeReadReplicaWithMemberId(1);
    for (int coreServerId = 0; coreServerId < 3; coreServerId++) {
        // then
        assertEventualOverview(cluster, containsRole(READ_REPLICA, 1), coreServerId);
    }
}
Also used : Cluster(org.neo4j.causalclustering.discovery.Cluster) Test(org.junit.Test)

Example 52 with Cluster

use of org.neo4j.causalclustering.discovery.Cluster in project neo4j by neo4j.

the class ClusterOverviewIT method shouldDiscoverRemovalOfCoreMembers.

@Test
public void shouldDiscoverRemovalOfCoreMembers() throws Exception {
    // given
    clusterRule.withNumberOfCoreMembers(5);
    clusterRule.withNumberOfReadReplicas(0);
    Cluster cluster = clusterRule.startCluster();
    for (int coreServerId = 0; coreServerId < 5; coreServerId++) {
        assertEventualOverview(cluster, allOf(containsRole(LEADER, 1), containsRole(FOLLOWER, 4)), coreServerId);
    }
    // when
    cluster.removeCoreMemberWithMemberId(0);
    cluster.removeCoreMemberWithMemberId(1);
    for (int coreServerId = 2; coreServerId < 5; coreServerId++) {
        // then
        assertEventualOverview(cluster, allOf(containsRole(LEADER, 1), containsRole(FOLLOWER, 2)), coreServerId);
    }
}
Also used : Cluster(org.neo4j.causalclustering.discovery.Cluster) Test(org.junit.Test)

Aggregations

Cluster (org.neo4j.causalclustering.discovery.Cluster)52 Test (org.junit.Test)51 CoreClusterMember (org.neo4j.causalclustering.discovery.CoreClusterMember)21 File (java.io.File)14 HazelcastDiscoveryServiceFactory (org.neo4j.causalclustering.discovery.HazelcastDiscoveryServiceFactory)13 ReadReplica (org.neo4j.causalclustering.discovery.ReadReplica)13 Node (org.neo4j.graphdb.Node)12 Rule (org.junit.Rule)11 WriteOperationsNotAllowedException (org.neo4j.graphdb.security.WriteOperationsNotAllowedException)11 IOException (java.io.IOException)10 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)10 Transaction (org.neo4j.graphdb.Transaction)10 TransactionFailureException (org.neo4j.kernel.api.exceptions.TransactionFailureException)10 ClusterRule (org.neo4j.test.causalclustering.ClusterRule)10 CoreGraphDatabase (org.neo4j.causalclustering.core.CoreGraphDatabase)9 Map (java.util.Map)8 TimeUnit (java.util.concurrent.TimeUnit)8 ReadReplicaGraphDatabase (org.neo4j.causalclustering.readreplica.ReadReplicaGraphDatabase)8 GraphDatabaseService (org.neo4j.graphdb.GraphDatabaseService)8 UnsatisfiedDependencyException (org.neo4j.kernel.impl.util.UnsatisfiedDependencyException)8