use of org.neo4j.causalclustering.discovery.Cluster in project neo4j by neo4j.
the class ClusterOverviewIT method shouldDiscoverNewCoreMembers.
@Test
public void shouldDiscoverNewCoreMembers() throws Exception {
// given
clusterRule.withNumberOfCoreMembers(3);
clusterRule.withNumberOfReadReplicas(0);
Cluster cluster = clusterRule.startCluster();
// when
cluster.addCoreMemberWithId(3).start();
cluster.addCoreMemberWithId(4).start();
Matcher<List<MemberInfo>> expected = allOf(containsMemberAddresses(cluster.coreMembers()), containsRole(LEADER, 1), containsRole(FOLLOWER, 4));
for (int coreServerId = 0; coreServerId < 5; coreServerId++) {
// then
assertEventualOverview(cluster, expected, coreServerId);
}
}
use of org.neo4j.causalclustering.discovery.Cluster in project neo4j by neo4j.
the class ClusterOverviewIT method shouldDiscoverReadReplicasAfterRestartingCores.
@Test
public void shouldDiscoverReadReplicasAfterRestartingCores() throws Exception {
// given
clusterRule.withNumberOfCoreMembers(3);
clusterRule.withNumberOfReadReplicas(3);
// when
Cluster cluster = clusterRule.startCluster();
cluster.shutdownCoreMembers();
cluster.startCoreMembers();
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);
}
}
use of org.neo4j.causalclustering.discovery.Cluster in project neo4j by neo4j.
the class CausalClusteringRolesIT method readReplicasShouldRefuseWrites.
@Test
public void readReplicasShouldRefuseWrites() throws Exception {
// given
Cluster cluster = clusterRule.startCluster();
GraphDatabaseService db = cluster.findAnyReadReplica().database();
Transaction tx = db.beginTx();
// then
exceptionMatcher.expect(WriteOperationsNotAllowedException.class);
// when
db.createNode();
tx.success();
tx.close();
}
use of org.neo4j.causalclustering.discovery.Cluster in project neo4j by neo4j.
the class ClusterShutdownIT method shouldShutdownEvenThoughWaitingForLock.
@Test
public void shouldShutdownEvenThoughWaitingForLock() throws Exception {
Cluster cluster = clusterRule.startCluster();
try {
for (int victimId = 0; victimId < cluster.numberOfCoreMembersReportedByTopology(); victimId++) {
assertTrue(cluster.getCoreMemberById(victimId).database().isAvailable(1000));
shouldShutdownEvenThoughWaitingForLock0(cluster, victimId, shutdownOrder);
cluster.start();
}
} catch (WriteOperationsNotAllowedException e) {
// expected
}
}
use of org.neo4j.causalclustering.discovery.Cluster in project neo4j by neo4j.
the class CorePruningIT method actuallyDeletesTheFiles.
@Test
public void actuallyDeletesTheFiles() throws Exception {
// given
Cluster cluster = clusterRule.startCluster();
CoreClusterMember coreGraphDatabase = null;
int txs = 10;
for (int i = 0; i < txs; i++) {
coreGraphDatabase = cluster.coreTx((db, tx) -> {
createData(db, 1);
tx.success();
});
}
// when pruning kicks in then some files are actually deleted
File raftLogDir = coreGraphDatabase.raftLogDirectory();
int expectedNumberOfLogFilesAfterPruning = 2;
assertEventually("raft logs eventually pruned", () -> numberOfFiles(raftLogDir), equalTo(expectedNumberOfLogFilesAfterPruning), 5, TimeUnit.SECONDS);
}
Aggregations