use of org.neo4j.kernel.impl.ha.ClusterManager in project neo4j by neo4j.
the class FailoverWithAdditionalSlaveFailuresIT method testFailoverWithAdditionalSlave.
private void testFailoverWithAdditionalSlave(int clusterSize, int[] slaveIndexes) throws Throwable {
ClusterManager manager = new ClusterManager.Builder().withRootDirectory(dir.cleanDirectory("testcluster")).withCluster(ClusterManager.clusterOfSize(clusterSize)).build();
try {
manager.start();
ClusterManager.ManagedCluster cluster = manager.getCluster();
cluster.await(allSeesAllAsAvailable());
cluster.await(masterAvailable());
Collection<HighlyAvailableGraphDatabase> failed = new ArrayList<>();
Collection<RepairKit> repairKits = new ArrayList<>();
for (int slaveIndex : slaveIndexes) {
HighlyAvailableGraphDatabase nthSlave = getNthSlave(cluster, slaveIndex);
failed.add(nthSlave);
RepairKit repairKit = cluster.fail(nthSlave);
repairKits.add(repairKit);
}
HighlyAvailableGraphDatabase oldMaster = cluster.getMaster();
failed.add(oldMaster);
repairKits.add(cluster.fail(oldMaster));
cluster.await(masterAvailable(toArray(failed)));
for (RepairKit repairKit : repairKits) {
repairKit.repair();
}
// give repaired instances a chance to cleanly rejoin and exit faster
Thread.sleep(3000);
} finally {
manager.safeShutdown();
}
}
use of org.neo4j.kernel.impl.ha.ClusterManager in project neo4j by neo4j.
the class ClusterTest method testClusterWithWildcardIP.
@Test
public void testClusterWithWildcardIP() throws Throwable {
ClusterManager clusterManager = new ClusterManager.Builder(testDirectory.directory("testClusterWithWildcardIP")).withSharedConfig(stringMap(HaSettings.ha_server.name(), "0.0.0.0:6001-9999", HaSettings.tx_push_factor.name(), "2")).build();
createClusterWithNode(clusterManager);
}
use of org.neo4j.kernel.impl.ha.ClusterManager in project neo4j by neo4j.
the class ClusterTest method lastTxCommitTimestampShouldGetInitializedOnSlaveIfNotPresent.
@Test
public void lastTxCommitTimestampShouldGetInitializedOnSlaveIfNotPresent() throws Throwable {
ClusterManager clusterManager = new ClusterManager.Builder(testDirectory.directory("lastTxTimestamp")).withCluster(ClusterManager.clusterOfSize(3)).build();
try {
clusterManager.start();
ClusterManager.ManagedCluster cluster = clusterManager.getCluster();
cluster.await(allSeesAllAsAvailable());
runSomeTransactions(cluster.getMaster());
cluster.sync();
HighlyAvailableGraphDatabase slave = cluster.getAnySlave();
File storeDir = new File(slave.getStoreDir());
ClusterManager.RepairKit slaveRepairKit = cluster.shutdown(slave);
clearLastTransactionCommitTimestampField(storeDir);
HighlyAvailableGraphDatabase repairedSlave = slaveRepairKit.repair();
cluster.await(allSeesAllAsAvailable());
assertEquals(lastCommittedTxTimestamp(cluster.getMaster()), lastCommittedTxTimestamp(repairedSlave));
} finally {
clusterManager.stop();
}
}
use of org.neo4j.kernel.impl.ha.ClusterManager in project neo4j by neo4j.
the class ClusterTest method testClusterWithHostnames.
@Test
public void testClusterWithHostnames() throws Throwable {
ClusterManager clusterManager = new ClusterManager.Builder(testDirectory.directory("testCluster")).withCluster(clusterOfSize("localhost", 3)).withSharedConfig(stringMap(HaSettings.ha_server.name(), "localhost:6001-9999", HaSettings.tx_push_factor.name(), "2")).build();
createClusterWithNode(clusterManager);
}
use of org.neo4j.kernel.impl.ha.ClusterManager in project neo4j by neo4j.
the class ClusterTest method lastTxCommitTimestampShouldBeUnknownAfterStartIfNoFiledOrLogsPresent.
@Test
public void lastTxCommitTimestampShouldBeUnknownAfterStartIfNoFiledOrLogsPresent() throws Throwable {
ClusterManager clusterManager = new ClusterManager.Builder(testDirectory.directory("lastTxTimestamp")).withCluster(ClusterManager.clusterOfSize(3)).build();
try {
clusterManager.start();
ClusterManager.ManagedCluster cluster = clusterManager.getCluster();
cluster.await(allSeesAllAsAvailable());
runSomeTransactions(cluster.getMaster());
cluster.sync();
HighlyAvailableGraphDatabase slave = cluster.getAnySlave();
File storeDir = new File(slave.getStoreDir());
ClusterManager.RepairKit slaveRepairKit = cluster.shutdown(slave);
clearLastTransactionCommitTimestampField(storeDir);
deleteLogs(storeDir);
HighlyAvailableGraphDatabase repairedSlave = slaveRepairKit.repair();
cluster.await(allSeesAllAsAvailable());
assertEquals(TransactionIdStore.UNKNOWN_TX_COMMIT_TIMESTAMP, lastCommittedTxTimestamp(repairedSlave));
} finally {
clusterManager.stop();
}
}
Aggregations