use of org.neo4j.kernel.ha.HighlyAvailableGraphDatabase in project neo4j by neo4j.
the class TransactionConstraintsIT method getSlaveOnlySlave.
private HighlyAvailableGraphDatabase getSlaveOnlySlave() {
HighlyAvailableGraphDatabase db = cluster.getMemberByServerId(new InstanceId(SLAVE_ONLY_ID));
assertEquals(SLAVE_ONLY_ID, cluster.getServerId(db).toIntegerIndex());
assertFalse(db.isMaster());
return db;
}
use of org.neo4j.kernel.ha.HighlyAvailableGraphDatabase in project neo4j by neo4j.
the class TransactionConstraintsIT method masterShouldNotBeAbleToProduceAnInvalidTransaction.
@Test
public void masterShouldNotBeAbleToProduceAnInvalidTransaction() throws Exception {
// GIVEN
HighlyAvailableGraphDatabase master = cluster.getMaster();
Node node = createMiniTree(master);
Transaction tx = master.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 UniquenessConstraintValidationHAIT method shouldAllowOtherHostToCompleteIfFirstHostRollsBackTransaction.
@Test
public void shouldAllowOtherHostToCompleteIfFirstHostRollsBackTransaction() throws Exception {
// given
ClusterManager.ManagedCluster cluster = clusterRule.startCluster();
HighlyAvailableGraphDatabase slave1 = cluster.getAnySlave();
HighlyAvailableGraphDatabase slave2 = cluster.getAnySlave(/*except:*/
slave1);
// when
Future<Boolean> created;
try (Transaction tx = slave1.beginTx()) {
slave1.createNode(LABEL).setProperty(PROPERTY_KEY, "value4");
created = otherThread.execute(createNode(slave2, LABEL.name(), PROPERTY_KEY, "value4"));
assertThat(otherThread, isWaiting());
tx.failure();
}
// then
assertTrue("creating data that conflicts only with rolled back data should pass", created.get());
}
use of org.neo4j.kernel.ha.HighlyAvailableGraphDatabase in project neo4j by neo4j.
the class UniquenessConstraintValidationHAIT method shouldAllowCreationOfNonConflictingDataOnSeparateHosts.
@Test
public void shouldAllowCreationOfNonConflictingDataOnSeparateHosts() throws Exception {
// given
ClusterManager.ManagedCluster cluster = clusterRule.startCluster();
HighlyAvailableGraphDatabase slave1 = cluster.getAnySlave();
HighlyAvailableGraphDatabase slave2 = cluster.getAnySlave(/*except:*/
slave1);
// when
Future<Boolean> created;
try (Transaction tx = slave1.beginTx()) {
slave1.createNode(LABEL).setProperty(PROPERTY_KEY, "value1");
created = otherThread.execute(createNode(slave2, LABEL.name(), PROPERTY_KEY, "value2"));
tx.success();
}
// then
assertTrue("creating non-conflicting data should pass", created.get());
}
use of org.neo4j.kernel.ha.HighlyAvailableGraphDatabase in project neo4j by neo4j.
the class UpdatePullerSwitchIT method checkLabeledNodeExistanceOnSlave.
private void checkLabeledNodeExistanceOnSlave(ClusterManager.ManagedCluster cluster, Label label) {
HighlyAvailableGraphDatabase slave = cluster.getAnySlave();
try (Transaction transaction = slave.beginTx()) {
ResourceIterator<Node> slaveNodes = slave.findNodes(label);
assertEquals(1, Iterators.asList(slaveNodes).size());
transaction.success();
}
}
Aggregations