use of org.neo4j.causalclustering.discovery.CoreClusterMember 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.CoreClusterMember 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.CoreClusterMember in project neo4j by neo4j.
the class CausalClusteringProceduresIT method coreProceduresShouldBeAvailable.
@Test
public void coreProceduresShouldBeAvailable() throws Throwable {
String[] coreProcs = new String[] { // Server role
"dbms.cluster.role", // Discover the cluster topology
"dbms.cluster.routing.getServers", // Discover appropriate discovery service
"dbms.cluster.overview", // Kernel built procedures
"dbms.procedures", // Built in procedure from enterprise
"dbms.listQueries" };
for (String procedure : coreProcs) {
Optional<CoreClusterMember> firstCore = cluster.coreMembers().stream().findFirst();
assert firstCore.isPresent();
CoreGraphDatabase database = firstCore.get().database();
InternalTransaction tx = database.beginTransaction(KernelTransaction.Type.explicit, AUTH_DISABLED);
Result coreResult = database.execute("CALL " + procedure + "()");
assertTrue("core with procedure " + procedure, coreResult.hasNext());
coreResult.close();
tx.close();
}
}
use of org.neo4j.causalclustering.discovery.CoreClusterMember in project neo4j by neo4j.
the class ClusterBindingIT method badFollowerShouldNotJoinCluster.
@Test
public void badFollowerShouldNotJoinCluster() throws Exception {
// GIVEN
cluster.coreTx((db, tx) -> {
Node node = db.createNode(label("boo"));
node.setProperty("foobar", "baz_bat");
tx.success();
});
CoreClusterMember coreMember = cluster.getCoreMemberById(0);
cluster.removeCoreMemberWithMemberId(0);
changeClusterId(coreMember);
SampleData.createSomeData(100, cluster);
for (CoreClusterMember db : cluster.coreMembers()) {
db.coreState().prune();
}
// WHEN
try {
cluster.addCoreMemberWithId(0).start();
fail("Should not have joined the cluster");
} catch (RuntimeException e) {
assertThat(e.getCause(), instanceOf(LifecycleException.class));
}
}
use of org.neo4j.causalclustering.discovery.CoreClusterMember in project neo4j by neo4j.
the class ClusterBindingIT method laggingFollowerShouldDownloadSnapshot.
@Test
public void laggingFollowerShouldDownloadSnapshot() throws Exception {
// GIVEN
cluster.coreTx((db, tx) -> {
Node node = db.createNode(label("boo"));
node.setProperty("foobar", "baz_bat");
tx.success();
});
cluster.removeCoreMemberWithMemberId(0);
SampleData.createSomeData(100, cluster);
for (CoreClusterMember db : cluster.coreMembers()) {
db.coreState().prune();
}
// WHEN
cluster.addCoreMemberWithId(0).start();
cluster.awaitLeader();
// THEN
assertEquals(3, cluster.healthyCoreMembers().size());
List<File> coreStoreDirs = storeDirs(cluster.coreMembers());
cluster.shutdown();
assertAllStoresHaveTheSameStoreId(coreStoreDirs, fs);
}
Aggregations