use of org.neo4j.causalclustering.discovery.Cluster in project neo4j by neo4j.
the class ClusterDiscoveryIT method shouldNotBeAbleToDiscoverFromReadReplicas.
@Test
public void shouldNotBeAbleToDiscoverFromReadReplicas() throws Exception {
// given
Cluster cluster = clusterRule.withSharedCoreParams(config).withNumberOfReadReplicas(2).startCluster();
try {
// when
getMembers(cluster.getReadReplicaById(0).database());
fail("Should not be able to discover members from read replicas");
} catch (ProcedureException ex) {
// then
assertThat(ex.getMessage(), containsString("There is no procedure with the name"));
}
}
use of org.neo4j.causalclustering.discovery.Cluster in project neo4j by neo4j.
the class ClusterLeaderStepDownIT method leaderShouldStepDownWhenFollowersAreGone.
@Test
public void leaderShouldStepDownWhenFollowersAreGone() throws Throwable {
// when
Cluster cluster = clusterRule.startCluster();
//Do some work to make sure the cluster is operating normally.
CoreClusterMember leader = cluster.coreTx((db, tx) -> {
Node node = db.createNode(Label.label("bam"));
node.setProperty("bam", "bam");
tx.success();
});
List<CoreClusterMember> followers = cluster.coreMembers().stream().filter(m -> m.raft().currentRole() != Role.LEADER).collect(toList());
assertEquals(7, followers.size());
//when
//shutdown 4 servers, leaving 4 remaining and therefore not a quorum.
followers.subList(0, 4).forEach(CoreClusterMember::shutdown);
//then
assertEventually("Leader should have stepped down.", () -> leader.raft().isLeader(), Matchers.is(false), 2, TimeUnit.MINUTES);
}
use of org.neo4j.causalclustering.discovery.Cluster in project neo4j by neo4j.
the class ClusterMembershipChangeIT method newMemberNotInInitialMembersConfig.
@Test
@Ignore("Incomplete, HC will hang waiting for others to join.")
public void newMemberNotInInitialMembersConfig() throws Throwable {
// when
Cluster cluster = clusterRule.withNumberOfReadReplicas(0).startCluster();
List<AdvertisedSocketAddress> onlyServerZero = singletonList(Cluster.socketAddressForServer(0));
// then
cluster.addCoreMemberWithIdAndInitialMembers(3, onlyServerZero).start();
cluster.addCoreMemberWithIdAndInitialMembers(4, onlyServerZero).start();
cluster.addCoreMemberWithIdAndInitialMembers(5, onlyServerZero).start();
cluster.removeCoreMemberWithMemberId(0);
cluster.removeCoreMemberWithMemberId(1);
cluster.removeCoreMemberWithMemberId(2);
cluster.shutdown();
cluster.start();
List<Object[]> currentMembers;
for (CoreClusterMember member : cluster.coreMembers()) {
currentMembers = discoverClusterMembers(member.database());
assertThat(currentMembers, containsInAnyOrder(new Object[] { "127.0.0.1:8003" }, new Object[] { "127.0.0.1:8004" }, new Object[] { "127.0.0.1:8005" }));
}
}
use of org.neo4j.causalclustering.discovery.Cluster in project neo4j by neo4j.
the class ClusterOverviewIT method shouldDiscoverCoreMembers.
@Test
public void shouldDiscoverCoreMembers() throws Exception {
// given
clusterRule.withNumberOfCoreMembers(3);
clusterRule.withNumberOfReadReplicas(0);
// when
Cluster cluster = clusterRule.startCluster();
Matcher<List<MemberInfo>> expected = allOf(containsMemberAddresses(cluster.coreMembers()), containsRole(LEADER, 1), containsRole(FOLLOWER, 2), doesNotContainRole(READ_REPLICA));
for (int coreServerId = 0; coreServerId < 3; coreServerId++) {
// then
assertEventualOverview(cluster, expected, coreServerId);
}
}
use of org.neo4j.causalclustering.discovery.Cluster in project neo4j by neo4j.
the class ClusterOverviewIT method shouldDiscoverCoreMembersAndReadReplicas.
@Test
public void shouldDiscoverCoreMembersAndReadReplicas() throws Exception {
// given
clusterRule.withNumberOfCoreMembers(3);
clusterRule.withNumberOfReadReplicas(3);
// when
Cluster cluster = clusterRule.startCluster();
Matcher<List<MemberInfo>> expected = allOf(containsAllMemberAddresses(cluster.coreMembers(), cluster.readReplicas()), containsRole(LEADER, 1), containsRole(FOLLOWER, 2), containsRole(READ_REPLICA, 3));
for (int coreServerId = 0; coreServerId < 3; coreServerId++) {
// then
assertEventualOverview(cluster, expected, coreServerId);
}
}
Aggregations