use of org.neo4j.graphdb.Transaction in project neo4j by neo4j.
the class AbstractShellIT method assertRelationshipDoesntExist.
protected void assertRelationshipDoesntExist(long id) {
try (Transaction ignore = db.beginTx()) {
db.getRelationshipById(id);
fail("Relationship " + id + " shouldn't exist");
} catch (NotFoundException e) {
// Good
}
}
use of org.neo4j.graphdb.Transaction in project neo4j by neo4j.
the class AbstractShellIT method setProperty.
protected void setProperty(Node node, String key, Object value) {
try (Transaction tx = db.beginTx()) {
node.setProperty(key, value);
tx.success();
}
}
use of org.neo4j.graphdb.Transaction in project neo4j by neo4j.
the class AbstractShellIT method createRelationshipChain.
protected Relationship[] createRelationshipChain(RelationshipType type, int length) {
try (Transaction transaction = db.beginTx()) {
Relationship[] relationshipChain = createRelationshipChain(db.createNode(), type, length);
transaction.success();
return relationshipChain;
}
}
use of org.neo4j.graphdb.Transaction in project neo4j by neo4j.
the class AbstractShellIT method deleteRelationship.
protected void deleteRelationship(Relationship relationship) {
try (Transaction tx = db.beginTx()) {
relationship.delete();
tx.success();
}
}
use of org.neo4j.graphdb.Transaction in project neo4j by neo4j.
the class Cluster method leaderTx.
/**
* Perform a transaction against the leader of the core cluster, retrying as necessary.
*/
private CoreClusterMember leaderTx(BiConsumer<CoreGraphDatabase, Transaction> op, int timeout, TimeUnit timeUnit) throws Exception {
ThrowingSupplier<CoreClusterMember, Exception> supplier = () -> {
CoreClusterMember member = awaitLeader(timeout, timeUnit);
CoreGraphDatabase db = member.database();
if (db == null) {
throw new DatabaseShutdownException();
}
try (Transaction tx = db.beginTx()) {
op.accept(db, tx);
return member;
} catch (Throwable e) {
if (isTransientFailure(e)) {
// this is not the best, but it helps in debugging
System.err.println("Transient failure in leader transaction, trying again.");
e.printStackTrace();
return null;
} else {
throw e;
}
}
};
return awaitEx(supplier, notNull()::test, timeout, timeUnit);
}
Aggregations