use of org.neo4j.kernel.impl.ha.ClusterManager.ManagedCluster in project neo4j by neo4j.
the class HaBeanIT method shouldAccessHaBeans.
@Test
public void shouldAccessHaBeans() throws Throwable {
ManagedCluster cluster = clusterRule.startCluster();
// High Availability bean
HighAvailability ha = ha(cluster.getMaster());
assertNotNull("could not get ha bean", ha);
assertMasterInformation(ha);
assertMasterAndSlaveInformation(ha.getInstancesInCluster());
for (ClusterMemberInfo info : ha.getInstancesInCluster()) {
assertTrue(info.isAlive());
assertTrue(info.isAvailable());
}
// Branched data bean
BranchedStore bs = beans(cluster.getMaster()).getBranchedStoreBean();
assertNotNull("could not get branched store bean", bs);
}
use of org.neo4j.kernel.impl.ha.ClusterManager.ManagedCluster in project neo4j by neo4j.
the class BackupHaIT method makeSureBackupCanBePerformed.
@Test
public void makeSureBackupCanBePerformed() throws Throwable {
// Run backup
ManagedCluster cluster = clusterRule.startCluster();
DbRepresentation beforeChange = DbRepresentation.of(cluster.getMaster());
assertEquals(0, runBackupToolFromOtherJvmToGetExitCode(backupPath, backupArguments("localhost:4445", backupPath, "basic")));
// Add some new data
DbRepresentation afterChange = createSomeData(cluster.getMaster());
cluster.sync();
// Verify that backed up database can be started and compare representation
DbRepresentation backupRepresentation = DbRepresentation.of(new File(backupPath, "basic"));
assertEquals(beforeChange, backupRepresentation);
assertNotEquals(backupRepresentation, afterChange);
}
use of org.neo4j.kernel.impl.ha.ClusterManager.ManagedCluster in project neo4j by neo4j.
the class BackupHaIT method makeSureBackupCanBePerformedFromAnyInstance.
@Test
public void makeSureBackupCanBePerformedFromAnyInstance() throws Throwable {
ManagedCluster cluster = clusterRule.startCluster();
Integer[] backupPorts = { 4445, 4446, 4447 };
for (Integer port : backupPorts) {
// Run backup
DbRepresentation beforeChange = DbRepresentation.of(cluster.getMaster());
assertEquals(0, runBackupToolFromOtherJvmToGetExitCode(backupPath, backupArguments("localhost:" + port, backupPath, "anyinstance")));
// Add some new data
DbRepresentation afterChange = createSomeData(cluster.getMaster());
cluster.sync();
// Verify that old data is back
DbRepresentation backupRepresentation = DbRepresentation.of(new File(backupPath, "anyinstance"));
assertEquals(beforeChange, backupRepresentation);
assertNotEquals(backupRepresentation, afterChange);
}
}
use of org.neo4j.kernel.impl.ha.ClusterManager.ManagedCluster in project neo4j by neo4j.
the class ReadOnlySlaveTest method givenClusterWithReadOnlySlaveWhenChangePropertyOnSlaveThenThrowException.
@Test
public void givenClusterWithReadOnlySlaveWhenChangePropertyOnSlaveThenThrowException() throws Throwable {
// Given
ManagedCluster cluster = clusterRule.startCluster();
Node node;
HighlyAvailableGraphDatabase master = cluster.getMaster();
try (Transaction tx = master.beginTx()) {
node = master.createNode();
tx.success();
}
// When
HighlyAvailableGraphDatabase readOnlySlave = cluster.getMemberByServerId(new InstanceId(2));
try (Transaction tx = readOnlySlave.beginTx()) {
Node slaveNode = readOnlySlave.getNodeById(node.getId());
// Then
slaveNode.setProperty("foo", "bar");
tx.success();
fail("Should have thrown exception");
} catch (WriteOperationsNotAllowedException ex) {
// Ok!
}
}
Aggregations