use of org.neo4j.kernel.ha.HighlyAvailableGraphDatabase in project neo4j by neo4j.
the class TransactionConstraintsIT method slaveShouldNotBeAbleToProduceAnInvalidTransaction.
@Test
public void slaveShouldNotBeAbleToProduceAnInvalidTransaction() throws Exception {
// GIVEN
HighlyAvailableGraphDatabase aSlave = cluster.getAnySlave();
Node node = createMiniTree(aSlave);
Transaction tx = aSlave.beginTx();
// Deleting this node isn't allowed since it still has relationships
node.delete();
tx.success();
// EXPECT
exception.expect(ConstraintViolationException.class);
// WHEN
tx.close();
}
use of org.neo4j.kernel.ha.HighlyAvailableGraphDatabase in project neo4j by neo4j.
the class TestClusterClientPadding method additionalClusterClientCanHelpBreakTiesWhenMasterFails.
@Test
public void additionalClusterClientCanHelpBreakTiesWhenMasterFails() throws Throwable {
HighlyAvailableGraphDatabase sittingMaster = cluster.getMaster();
cluster.fail(sittingMaster);
cluster.await(masterAvailable(sittingMaster));
}
use of org.neo4j.kernel.ha.HighlyAvailableGraphDatabase in project neo4j by neo4j.
the class HACountsPropagationTest method shouldPropagateRelationshipCountsInHA.
@Test
public void shouldPropagateRelationshipCountsInHA() throws Throwable {
ManagedCluster cluster = clusterRule.startCluster();
HighlyAvailableGraphDatabase master = cluster.getMaster();
try (Transaction tx = master.beginTx()) {
Node left = master.createNode();
Node right = master.createNode(Label.label("A"));
left.createRelationshipTo(right, RelationshipType.withName("Type"));
tx.success();
}
cluster.sync();
for (HighlyAvailableGraphDatabase db : cluster.getAllMembers()) {
CountsTracker counts = counts(db);
assertEquals(1, counts.relationshipCount(-1, -1, -1, newDoubleLongRegister()).readSecond());
assertEquals(1, counts.relationshipCount(-1, -1, 0, newDoubleLongRegister()).readSecond());
assertEquals(1, counts.relationshipCount(-1, 0, -1, newDoubleLongRegister()).readSecond());
assertEquals(1, counts.relationshipCount(-1, 0, 0, newDoubleLongRegister()).readSecond());
}
}
use of org.neo4j.kernel.ha.HighlyAvailableGraphDatabase in project neo4j by neo4j.
the class HACountsPropagationTest method shouldPropagateNodeCountsInHA.
@Test
public void shouldPropagateNodeCountsInHA() throws Throwable {
ManagedCluster cluster = clusterRule.startCluster();
HighlyAvailableGraphDatabase master = cluster.getMaster();
try (Transaction tx = master.beginTx()) {
master.createNode();
master.createNode(Label.label("A"));
tx.success();
}
cluster.sync();
for (HighlyAvailableGraphDatabase db : cluster.getAllMembers()) {
CountsTracker counts = counts(db);
assertEquals(2, counts.nodeCount(-1, newDoubleLongRegister()).readSecond());
assertEquals(1, counts.nodeCount(0, /* A */
newDoubleLongRegister()).readSecond());
}
}
use of org.neo4j.kernel.ha.HighlyAvailableGraphDatabase in project neo4j by neo4j.
the class TerminationOfSlavesDuringPullUpdatesTest method slavesTerminateOrReadConsistentDataWhenApplyingBatchLargerThanSafeZone.
@Test
public void slavesTerminateOrReadConsistentDataWhenApplyingBatchLargerThanSafeZone() throws Throwable {
long safeZone = TimeUnit.MILLISECONDS.toMillis(0);
clusterRule.withSharedSetting(HaSettings.id_reuse_safe_zone_time, String.valueOf(safeZone));
// given
final ClusterManager.ManagedCluster cluster = clusterRule.startCluster();
HighlyAvailableGraphDatabase master = cluster.getMaster();
// when
// ... slaves and master has node with long string property
long entityId = action.createInitialEntity(master);
cluster.sync();
// ... and property is removed on master
action.removeProperties(master, entityId);
Thread.sleep(100);
// ... and maintenance is called to make sure "safe" ids are freed to be reused
forceMaintenance(master);
// ... and a new property is created on master that
action.setNewProperties(master, entityId);
final HighlyAvailableGraphDatabase slave = cluster.getAnySlave();
Race race = new Race();
final AtomicBoolean end = new AtomicBoolean(false);
for (int i = 0; i < READER_CONTESTANTS; i++) {
race.addContestant(readContestant(action, entityId, slave, end));
}
race.addContestant(pullUpdatesContestant(slave, end));
race.go();
}
Aggregations