use of org.neo4j.causalclustering.discovery.CoreClusterMember in project neo4j by neo4j.
the class ClusterSeedingIT method shouldSeedNewMemberFromNonEmptyIdleCluster.
@Test
public void shouldSeedNewMemberFromNonEmptyIdleCluster() throws Throwable {
// given
cluster = new Cluster(testDir.directory("cluster-b"), 3, 0, new SharedDiscoveryService(), emptyMap(), backupParams(), emptyMap(), emptyMap(), Standard.LATEST_NAME);
cluster.start();
createEmptyNodes(cluster, 100);
// when: creating a backup
File backupDir = createBackup(cluster.getCoreMemberById(0).database(), "the-backup");
// and: seeding new member with said backup
CoreClusterMember newMember = cluster.addCoreMemberWithId(3);
fsa.copyRecursively(backupDir, newMember.storeDir());
newMember.start();
// then
dataMatchesEventually(DbRepresentation.of(newMember.database()), cluster.coreMembers());
}
use of org.neo4j.causalclustering.discovery.CoreClusterMember in project neo4j by neo4j.
the class CoreReplicationIT method shouldReplicateTransactionAfterLeaderWasRemovedFromCluster.
@Test
public void shouldReplicateTransactionAfterLeaderWasRemovedFromCluster() throws Exception {
// given
cluster.coreTx((db, tx) -> {
Node node = db.createNode();
node.setProperty("foobar", "baz_bat");
tx.success();
});
// when
cluster.removeCoreMember(cluster.awaitLeader());
// <- let's give a bit more time for the leader to show up
cluster.awaitLeader(1, TimeUnit.MINUTES);
CoreClusterMember last = cluster.coreTx((db, tx) -> {
Node node = db.createNode();
node.setProperty("foobar", "baz_bat");
tx.success();
});
// then
assertEquals(2, countNodes(last));
dataMatchesEventually(last, cluster.coreMembers());
}
use of org.neo4j.causalclustering.discovery.CoreClusterMember in project neo4j by neo4j.
the class CoreReplicationIT method shouldReplicateTransactionsToReplacementCoreMembers.
@Test
public void shouldReplicateTransactionsToReplacementCoreMembers() throws Exception {
// when
cluster.coreTx((db, tx) -> {
Node node = db.createNode(label("boo"));
node.setProperty("foobar", "baz_bat");
tx.success();
});
cluster.removeCoreMemberWithMemberId(0);
CoreClusterMember replacement = cluster.addCoreMemberWithId(0);
replacement.start();
CoreClusterMember leader = cluster.coreTx((db, tx) -> {
db.schema().indexFor(label("boo")).on("foobar").create();
tx.success();
});
// then
assertEquals(1, countNodes(leader));
dataMatchesEventually(leader, cluster.coreMembers());
}
use of org.neo4j.causalclustering.discovery.CoreClusterMember in project neo4j by neo4j.
the class CoreToCoreCopySnapshotIT method shouldBeAbleToDownloadToRejoinedInstanceAfterPruning.
@Test
public void shouldBeAbleToDownloadToRejoinedInstanceAfterPruning() throws Exception {
// given
Map<String, String> coreParams = stringMap();
coreParams.put(raft_log_rotation_size.name(), "1K");
coreParams.put(raft_log_pruning_strategy.name(), "keep_none");
coreParams.put(raft_log_pruning_frequency.name(), "100ms");
coreParams.put(state_machine_flush_window_size.name(), "64");
int numberOfTransactions = 100;
Timeout timeout = new Timeout(Clocks.systemClock(), 60, SECONDS);
// start the cluster
Cluster cluster = clusterRule.withSharedCoreParams(coreParams).startCluster();
// accumulate some log files
int firstServerLogFileCount;
CoreClusterMember firstServer;
do {
timeout.assertNotTimedOut();
firstServer = doSomeTransactions(cluster, numberOfTransactions);
firstServerLogFileCount = getMostRecentLogIdOn(firstServer);
} while (firstServerLogFileCount < 5);
firstServer.shutdown();
/* After shutdown we wait until we accumulate enough logs, and so that enough of the old ones
* have been pruned, so that the rejoined instance won't be able to catch up to without a snapshot. */
int oldestLogOnSecondServer;
CoreClusterMember secondServer;
do {
timeout.assertNotTimedOut();
secondServer = doSomeTransactions(cluster, numberOfTransactions);
oldestLogOnSecondServer = getOldestLogIdOn(secondServer);
} while (oldestLogOnSecondServer < firstServerLogFileCount + 5);
// when
firstServer.start();
// then
dataOnMemberEventuallyLooksLike(firstServer, secondServer);
}
use of org.neo4j.causalclustering.discovery.CoreClusterMember in project neo4j by neo4j.
the class ReadReplicaReplicationIT method shouldBeAbleToDownloadANewStoreAfterPruning.
@Test
public void shouldBeAbleToDownloadANewStoreAfterPruning() 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();
// when
readReplica.shutdown();
CoreClusterMember core;
do {
core = cluster.coreTx((db, tx) -> {
createData(db, 1_000);
tx.success();
});
} while (physicalLogFiles(core).getLowestLogVersion() <= highestReadReplicaLogVersion);
readReplica.start();
// then
awaitEx(() -> readReplicasUpToDateAsTheLeader(cluster.awaitLeader(), cluster.readReplicas()), 1, TimeUnit.MINUTES);
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);
}
Aggregations