use of org.neo4j.causalclustering.discovery.CoreClusterMember in project neo4j by neo4j.
the class ClusterBindingIT method aNewServerShouldJoinTheClusterByDownloadingASnapshot.
@Test
public void aNewServerShouldJoinTheClusterByDownloadingASnapshot() throws Exception {
// GIVEN
cluster.coreTx((db, tx) -> {
Node node = db.createNode(label("boo"));
node.setProperty("foobar", "baz_bat");
tx.success();
});
SampleData.createSomeData(100, cluster);
for (CoreClusterMember db : cluster.coreMembers()) {
db.coreState().prune();
}
// WHEN
cluster.addCoreMemberWithId(4).start();
cluster.awaitLeader();
// THEN
assertEquals(4, cluster.healthyCoreMembers().size());
List<File> coreStoreDirs = storeDirs(cluster.coreMembers());
cluster.shutdown();
assertAllStoresHaveTheSameStoreId(coreStoreDirs, fs);
}
use of org.neo4j.causalclustering.discovery.CoreClusterMember 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);
}
use of org.neo4j.causalclustering.discovery.CoreClusterMember in project neo4j by neo4j.
the class CorePruningIT method shouldNotPruneUncommittedEntries.
@Test
public void shouldNotPruneUncommittedEntries() throws Exception {
// given
Cluster cluster = clusterRule.startCluster();
CoreClusterMember coreGraphDatabase = null;
int txs = 1000;
for (int i = 0; i < txs; i++) {
coreGraphDatabase = cluster.coreTx((db, tx) -> createData(db, 1));
}
// when pruning kicks in then some files are actually deleted
int expectedNumberOfLogFilesAfterPruning = 2;
File raftLogDir = coreGraphDatabase.raftLogDirectory();
assertEventually("raft logs eventually pruned", () -> numberOfFiles(raftLogDir), equalTo(expectedNumberOfLogFilesAfterPruning), 5, TimeUnit.SECONDS);
}
use of org.neo4j.causalclustering.discovery.CoreClusterMember in project neo4j by neo4j.
the class ClusterSeedingIT method shouldSeedNewMemberFromEmptyIdleCluster.
@Test
public void shouldSeedNewMemberFromEmptyIdleCluster() throws Throwable {
// given
cluster = new Cluster(testDir.directory("cluster-b"), 3, 0, new SharedDiscoveryService(), emptyMap(), backupParams(), emptyMap(), emptyMap(), Standard.LATEST_NAME);
cluster.start();
// 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 BackupCoreIT method makeSureBackupCanBePerformedFromAnyInstance.
@Test
public void makeSureBackupCanBePerformedFromAnyInstance() throws Throwable {
for (CoreClusterMember db : cluster.coreMembers()) {
// Run backup
DbRepresentation beforeChange = DbRepresentation.of(createSomeData(cluster));
String[] args = backupArguments(backupAddress(db.database()), backupsDir, "" + db.serverId());
assertEquals(0, runBackupToolFromOtherJvmToGetExitCode(clusterRule.clusterDirectory(), args));
// Add some new data
DbRepresentation afterChange = DbRepresentation.of(createSomeData(cluster));
// Verify that old data is back
DbRepresentation backupRepresentation = DbRepresentation.of(new File(backupsDir, "" + db.serverId()), getConfig());
assertEquals(beforeChange, backupRepresentation);
assertNotEquals(backupRepresentation, afterChange);
}
}
Aggregations