use of org.neo4j.causalclustering.discovery.CoreClusterMember in project neo4j by neo4j.
the class ReadReplicaHierarchicalCatchupIT method shouldCatchupThroughHierarchy.
@Test
public void shouldCatchupThroughHierarchy() throws Throwable {
clusterRule = clusterRule.withInstanceReadReplicaParam(CausalClusteringSettings.server_groups, id -> serverGroups.get(id)).withInstanceCoreParam(CausalClusteringSettings.server_groups, id -> serverGroups.get(id));
// given
Cluster cluster = clusterRule.startCluster();
int numberOfNodesToCreate = 100;
cluster.coreTx((db, tx) -> {
db.schema().constraintFor(label("Foo")).assertPropertyIsUnique("foobar").create();
tx.success();
});
// 0, 1, 2 are core instances
createLabelledNodesWithProperty(cluster, numberOfNodesToCreate, label("Foo"), () -> Pair.of("foobar", String.format("baz_bat%s", UUID.randomUUID())));
// 3, 4 are other DCs
ReadReplica east3 = cluster.addReadReplicaWithId(3);
east3.start();
ReadReplica west4 = cluster.addReadReplicaWithId(4);
west4.start();
checkDataHasReplicatedToReadReplicas(cluster, numberOfNodesToCreate);
for (CoreClusterMember coreClusterMember : cluster.coreMembers()) {
coreClusterMember.stopCatchupServer();
}
// 5, 6 are other DCs
ReadReplica east5 = cluster.addReadReplicaWithId(5);
east5.setUpstreamDatabaseSelectionStrategy("connect-within-data-center");
east5.start();
ReadReplica west6 = cluster.addReadReplicaWithId(6);
west6.setUpstreamDatabaseSelectionStrategy("connect-within-data-center");
west6.start();
checkDataHasReplicatedToReadReplicas(cluster, numberOfNodesToCreate);
}
use of org.neo4j.causalclustering.discovery.CoreClusterMember in project neo4j by neo4j.
the class ReadReplicaReplicationIT method shouldBeAbleToPullTxAfterHavingDownloadedANewStoreAfterPruning.
@Test
public void shouldBeAbleToPullTxAfterHavingDownloadedANewStoreAfterPruning() throws Exception {
// given
Map<String, String> params = stringMap(GraphDatabaseSettings.keep_logical_logs.name(), "keep_none", GraphDatabaseSettings.logical_log_rotation_threshold.name(), "1M", GraphDatabaseSettings.check_point_interval_time.name(), "100ms");
Cluster cluster = clusterRule.withSharedCoreParams(params).startCluster();
cluster.coreTx((db, tx) -> {
createData(db, 10);
tx.success();
});
awaitEx(() -> readReplicasUpToDateAsTheLeader(cluster.awaitLeader(), cluster.readReplicas()), 1, TimeUnit.MINUTES);
ReadReplica readReplica = cluster.getReadReplicaById(0);
long highestReadReplicaLogVersion = physicalLogFiles(readReplica).getHighestLogVersion();
readReplica.shutdown();
CoreClusterMember core;
do {
core = cluster.coreTx((db, tx) -> {
createData(db, 1_000);
tx.success();
});
} while (physicalLogFiles(core).getLowestLogVersion() <= highestReadReplicaLogVersion);
readReplica.start();
awaitEx(() -> readReplicasUpToDateAsTheLeader(cluster.awaitLeader(), cluster.readReplicas()), 1, TimeUnit.MINUTES);
// when
cluster.coreTx((db, tx) -> {
createData(db, 10);
tx.success();
});
// then
assertEventually("The read replica has the same data as the core members", () -> DbRepresentation.of(readReplica.database()), equalTo(DbRepresentation.of(cluster.awaitLeader().database())), 10, TimeUnit.SECONDS);
}
use of org.neo4j.causalclustering.discovery.CoreClusterMember 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.CoreClusterMember in project neo4j by neo4j.
the class TransactionLogRecoveryIT method coreShouldStartWithSeedHavingPartialTransactionWriteCrash.
@Test
public void coreShouldStartWithSeedHavingPartialTransactionWriteCrash() throws Exception {
// given: a fully synced cluster with some data
dataMatchesEventually(createEmptyNodes(cluster, 10), cluster.coreMembers());
// when: shutting down a core
CoreClusterMember core = cluster.getCoreMemberById(0);
core.shutdown();
// and making sure there will be something new to pull
CoreClusterMember lastWrites = createEmptyNodes(cluster, 10);
// and writing a partial tx
writePartialTx(core.storeDir());
// and deleting the cluster state, making sure a snapshot is required during startup
// effectively a seeding scenario -- representing the use of the unbind command on a crashed store
fs.deleteRecursively(core.clusterStateDirectory());
// then: we should still be able to start
core.start();
// and become fully synced again
dataMatchesEventually(lastWrites, singletonList(core));
}
use of org.neo4j.causalclustering.discovery.CoreClusterMember in project neo4j by neo4j.
the class ClusterFormationIT method shouldSupportBuiltInProcedures.
@Test
public void shouldSupportBuiltInProcedures() throws Exception {
cluster.addReadReplicaWithId(0).start();
Stream.concat(cluster.readReplicas().stream().map(ReadReplica::database), cluster.coreMembers().stream().map(CoreClusterMember::database)).forEach(gdb -> {
{
Result result = gdb.execute("CALL dbms.procedures()");
assertTrue(result.hasNext());
result.close();
}
try (InternalTransaction tx = gdb.beginTransaction(KernelTransaction.Type.explicit, EnterpriseSecurityContext.AUTH_DISABLED)) {
Result result = gdb.execute(tx, "CALL dbms.listQueries()", Collections.emptyMap());
assertTrue(result.hasNext());
result.close();
tx.success();
}
});
}
Aggregations