use of org.neo4j.graphdb.Node in project neo4j by neo4j.
the class BigStoreIT method createReferenceNode.
private Node createReferenceNode(GraphDatabaseService db) {
try (Transaction tx = db.beginTx()) {
Node node = db.createNode(REFERENCE);
tx.success();
return node;
}
}
use of org.neo4j.graphdb.Node in project neo4j by neo4j.
the class BigStoreIT method testHighIds.
private void testHighIds(long highMark, int minus, int requiredHeapMb) throws IOException {
if (!machineIsOkToRunThisTest(requiredHeapMb)) {
return;
}
long idBelow = highMark - minus;
setHighIds(idBelow);
String propertyKey = "name";
int intPropertyValue = 123;
String stringPropertyValue = "Long string, longer than would fit in shortstring";
long[] arrayPropertyValue = new long[] { 1021L, 321L, 343212L };
Transaction tx = db.beginTx();
Node nodeBelowTheLine = db.createNode();
nodeBelowTheLine.setProperty(propertyKey, intPropertyValue);
assertEquals(idBelow, nodeBelowTheLine.getId());
Node nodeAboveTheLine = db.createNode();
nodeAboveTheLine.setProperty(propertyKey, stringPropertyValue);
Relationship relBelowTheLine = nodeBelowTheLine.createRelationshipTo(nodeAboveTheLine, this);
relBelowTheLine.setProperty(propertyKey, arrayPropertyValue);
assertEquals(idBelow, relBelowTheLine.getId());
Relationship relAboveTheLine = nodeAboveTheLine.createRelationshipTo(nodeBelowTheLine, this);
assertEquals(highMark, relAboveTheLine.getId());
assertEquals(highMark, nodeAboveTheLine.getId());
assertEquals(intPropertyValue, nodeBelowTheLine.getProperty(propertyKey));
assertEquals(stringPropertyValue, nodeAboveTheLine.getProperty(propertyKey));
assertTrue(Arrays.equals(arrayPropertyValue, (long[]) relBelowTheLine.getProperty(propertyKey)));
tx.success();
tx.close();
for (int i = 0; i < 2; i++) {
try (Transaction transaction = db.beginTx()) {
assertEquals(nodeAboveTheLine, db.getNodeById(highMark));
assertEquals(idBelow, nodeBelowTheLine.getId());
assertEquals(highMark, nodeAboveTheLine.getId());
assertEquals(idBelow, relBelowTheLine.getId());
assertEquals(highMark, relAboveTheLine.getId());
assertEquals(relBelowTheLine, db.getNodeById(idBelow).getSingleRelationship(this, Direction.OUTGOING));
assertEquals(relAboveTheLine, db.getNodeById(idBelow).getSingleRelationship(this, Direction.INCOMING));
assertEquals(idBelow, relBelowTheLine.getId());
assertEquals(highMark, relAboveTheLine.getId());
assertEquals(asSet(asList(relBelowTheLine, relAboveTheLine)), asSet(Iterables.asCollection(db.getNodeById(idBelow).getRelationships())));
transaction.success();
}
if (i == 0) {
db = dbRule.restartDatabase();
}
}
}
use of org.neo4j.graphdb.Node in project neo4j by neo4j.
the class ConcurrentCreateAndGetRelationshipsIT method createNode.
private Node createNode(GraphDatabaseService db) {
try (Transaction tx = db.beginTx()) {
Node node = db.createNode();
tx.success();
return node;
}
}
use of org.neo4j.graphdb.Node in project neo4j by neo4j.
the class ConcurrentCreateAndGetRelationshipsIT method tryToReproduceTheIssue.
@Test
public void tryToReproduceTheIssue() throws Exception {
// GIVEN
GraphDatabaseService db = dbRule.getGraphDatabaseAPI();
CountDownLatch startSignal = new CountDownLatch(1);
AtomicBoolean stopSignal = new AtomicBoolean();
AtomicReference<Exception> failure = new AtomicReference<Exception>();
Node parentNode = createNode(db);
Collection<Worker> workers = createWorkers(db, startSignal, stopSignal, failure, parentNode);
// WHEN
startSignal.countDown();
sleep(500);
stopSignal.set(true);
awaitWorkersToEnd(workers);
// THEN
if (failure.get() != null) {
throw new Exception("A worker failed", failure.get());
}
}
use of org.neo4j.graphdb.Node in project neo4j by neo4j.
the class NestedTransactionLocksIT method createNode.
private Node createNode() {
try (Transaction tx = db.beginTx()) {
Node n = db.createNode();
tx.success();
return n;
}
}
Aggregations