use of org.neo4j.causalclustering.discovery.Cluster in project neo4j by neo4j.
the class RestartIT method restartSecondServer.
@Test
public void restartSecondServer() throws Exception {
// given
Cluster cluster = clusterRule.startCluster();
// when
cluster.removeCoreMemberWithMemberId(1);
cluster.addCoreMemberWithId(1).start();
// then
cluster.shutdown();
}
use of org.neo4j.causalclustering.discovery.Cluster in project neo4j by neo4j.
the class RestartIT method restartFirstServer.
@Test
public void restartFirstServer() throws Exception {
// given
Cluster cluster = clusterRule.startCluster();
// when
cluster.removeCoreMemberWithMemberId(0);
cluster.addCoreMemberWithId(0).start();
// then
cluster.shutdown();
}
use of org.neo4j.causalclustering.discovery.Cluster in project neo4j by neo4j.
the class ServerGroupsIT method shouldUpdateGroupsOnStart.
@Test
public void shouldUpdateGroupsOnStart() throws Exception {
AtomicReference<String> suffix = new AtomicReference<>("before");
List<List<String>> expected;
Map<String, IntFunction<String>> instanceCoreParams = new HashMap<>();
instanceCoreParams.put(CausalClusteringSettings.server_groups.name(), (id) -> String.join(", ", makeCoreGroups(suffix.get(), id)));
Map<String, IntFunction<String>> instanceReplicaParams = new HashMap<>();
instanceReplicaParams.put(CausalClusteringSettings.server_groups.name(), (id) -> String.join(", ", makeReplicaGroups(suffix.get(), id)));
int nServers = 3;
cluster = new Cluster(testDir.directory("cluster"), nServers, nServers, new HazelcastDiscoveryServiceFactory(), emptyMap(), instanceCoreParams, emptyMap(), instanceReplicaParams, Standard.LATEST_NAME);
// when
cluster.start();
// then
expected = new ArrayList<>();
for (CoreClusterMember core : cluster.coreMembers()) {
expected.add(makeCoreGroups(suffix.get(), core.serverId()));
expected.add(makeReplicaGroups(suffix.get(), core.serverId()));
}
for (CoreClusterMember core : cluster.coreMembers()) {
assertEventually(core + " should have groups", () -> getServerGroups(core.database()), new GroupsMatcher(expected), 30, SECONDS);
}
// when
expected.remove(makeCoreGroups(suffix.get(), 1));
expected.remove(makeReplicaGroups(suffix.get(), 2));
cluster.getCoreMemberById(1).shutdown();
cluster.getReadReplicaById(2).shutdown();
// should update groups of restarted servers
suffix.set("after");
cluster.addCoreMemberWithId(1).start();
cluster.addReadReplicaWithId(2).start();
expected.add(makeCoreGroups(suffix.get(), 1));
expected.add(makeReplicaGroups(suffix.get(), 2));
// then
for (CoreClusterMember core : cluster.coreMembers()) {
assertEventually(core + " should have groups", () -> getServerGroups(core.database()), new GroupsMatcher(expected), 30, SECONDS);
}
}
use of org.neo4j.causalclustering.discovery.Cluster in project neo4j by neo4j.
the class ServerPoliciesLoadBalancingIT method defaultBehaviour.
@Test
public void defaultBehaviour() throws Exception {
cluster = new Cluster(testDir.directory("cluster"), 3, 3, new HazelcastDiscoveryServiceFactory(), emptyMap(), emptyMap(), emptyMap(), emptyMap(), Standard.LATEST_NAME);
cluster.start();
assertGetServersEventuallyMatchesOnAllCores(new CountsMatcher(3, 1, 2, 3));
}
use of org.neo4j.causalclustering.discovery.Cluster in project neo4j by neo4j.
the class WillNotBecomeLeaderIT method clusterShouldNotElectNewLeader.
@Test
public void clusterShouldNotElectNewLeader() throws Exception {
// given
int leaderId = 0;
clusterRule.withInstanceCoreParam(CausalClusteringSettings.refuse_to_be_leader, (x) -> {
if (x == leaderId) {
return "false";
} else {
return "true";
}
});
Cluster cluster = clusterRule.createCluster();
cluster.start();
assertEquals(leaderId, cluster.awaitLeader().serverId());
cluster.coreTx((db, tx) -> {
Node node = db.createNode(label("boo"));
node.setProperty("foobar", "baz_bat");
tx.success();
});
// When
cluster.removeCoreMemberWithMemberId(leaderId);
// Then
try {
cluster.awaitLeader(10, SECONDS);
fail("Should not have elected a leader");
} catch (TimeoutException ex) {
// Successful
}
}
Aggregations