use of org.neo4j.graphdb.Transaction in project neo4j by neo4j.
the class TestBasicHaOperations method testBasicPropagationFromMasterToSlave.
@Test
public void testBasicPropagationFromMasterToSlave() throws Throwable {
// given
ManagedCluster cluster = clusterRule.startCluster();
long nodeId = 4;
HighlyAvailableGraphDatabase master = cluster.getMaster();
try (Transaction tx = master.beginTx()) {
Node node = master.createNode();
node.setProperty("Hello", "World");
nodeId = node.getId();
tx.success();
}
cluster.sync();
// No need to wait, the push factor is 2
HighlyAvailableGraphDatabase slave1 = cluster.getAnySlave();
checkNodeOnSlave(nodeId, slave1);
HighlyAvailableGraphDatabase slave2 = cluster.getAnySlave(slave1);
checkNodeOnSlave(nodeId, slave2);
}
use of org.neo4j.graphdb.Transaction in project neo4j by neo4j.
the class TestBasicHaOperations method checkNodeOnSlave.
private void checkNodeOnSlave(long nodeId, HighlyAvailableGraphDatabase slave2) {
try (Transaction tx = slave2.beginTx()) {
String value = slave2.getNodeById(nodeId).getProperty("Hello").toString();
logger.getLogger().info("Hello=" + value);
assertEquals("World", value);
tx.success();
}
}
use of org.neo4j.graphdb.Transaction in project neo4j by neo4j.
the class BiggerThanLogTxIT method nodeCount.
private long nodeCount(GraphDatabaseService db) {
try (Transaction tx = db.beginTx()) {
long count = Iterables.count(db.getAllNodes());
tx.success();
return count;
}
}
use of org.neo4j.graphdb.Transaction in project neo4j by neo4j.
the class ClusterPartitionIT method ensureInstanceIsReadOnlyInPendingState.
/*
* This method must be called on an instance that has had addSomeData() called on it.
*/
private void ensureInstanceIsReadOnlyInPendingState(HighlyAvailableGraphDatabase instance) {
assertEquals(PENDING, instance.getInstanceState());
tx(instance, retryACoupleOfTimesOn(TRANSIENT_ERRORS), db -> assertEquals(testPropValue, instance.getNodeById(testNodeId).getProperty(testPropKey)));
try (Transaction ignored = instance.beginTx()) {
instance.getNodeById(testNodeId).delete();
fail("Should not be able to do write transactions when detached");
} catch (TransientDatabaseFailureException | TransactionFailureException expected) {
// expected
}
}
use of org.neo4j.graphdb.Transaction in project neo4j by neo4j.
the class ClusterTopologyChangesIT method createNodeOn.
private static Node createNodeOn(HighlyAvailableGraphDatabase db) {
try (Transaction tx = db.beginTx()) {
Node node = db.createNode();
node.setProperty("key", String.valueOf(System.currentTimeMillis()));
tx.success();
return node;
}
}
Aggregations