use of org.neo4j.graphdb.NotFoundException in project neo4j by neo4j.
the class NeoStoresIT method shouldWriteOutThePropertyRecordBeforeReferencingItFromARelationshipRecord.
@Test
public void shouldWriteOutThePropertyRecordBeforeReferencingItFromARelationshipRecord() throws Throwable {
final long node1Id;
final long node2Id;
try (Transaction tx = db.beginTx()) {
Node node1 = db.createNode();
node1Id = node1.getId();
Node node2 = db.createNode();
node2Id = node2.getId();
tx.success();
}
Race race = new Race();
final long[] latestRelationshipId = new long[1];
AtomicLong writes = new AtomicLong();
AtomicLong reads = new AtomicLong();
long endTime = currentTimeMillis() + SECONDS.toMillis(2);
race.withEndCondition(() -> (writes.get() > 100 && reads.get() > 10_000) || currentTimeMillis() > endTime);
race.addContestant(() -> {
try (Transaction tx = db.beginTx()) {
Node node1 = db.getGraphDatabaseAPI().getNodeById(node1Id);
Node node2 = db.getGraphDatabaseAPI().getNodeById(node2Id);
Relationship rel = node1.createRelationshipTo(node2, FRIEND);
latestRelationshipId[0] = rel.getId();
rel.setProperty("largeProperty", LONG_STRING_VALUE);
tx.success();
}
writes.incrementAndGet();
});
race.addContestant(() -> {
try (Transaction tx = db.getGraphDatabaseAPI().beginTx()) {
Relationship rel = db.getGraphDatabaseAPI().getRelationshipById(latestRelationshipId[0]);
for (String propertyKey : rel.getPropertyKeys()) {
rel.getProperty(propertyKey);
}
tx.success();
} catch (NotFoundException e) {
if (Exceptions.contains(e, InvalidRecordException.class)) {
throw e;
}
}
reads.incrementAndGet();
});
race.go();
}
use of org.neo4j.graphdb.NotFoundException in project neo4j by neo4j.
the class NeoStoresIT method shouldWriteOutTheDynamicChainBeforeUpdatingThePropertyRecord.
@Test
public void shouldWriteOutTheDynamicChainBeforeUpdatingThePropertyRecord() throws Throwable {
Race race = new Race();
long[] latestNodeId = new long[1];
AtomicLong writes = new AtomicLong();
AtomicLong reads = new AtomicLong();
long endTime = currentTimeMillis() + SECONDS.toMillis(2);
race.withEndCondition(() -> (writes.get() > 100 && reads.get() > 10_000) || currentTimeMillis() > endTime);
race.addContestant(() -> {
try (Transaction tx = db.beginTx()) {
Node node = db.createNode();
latestNodeId[0] = node.getId();
node.setProperty("largeProperty", LONG_STRING_VALUE);
tx.success();
}
writes.incrementAndGet();
});
race.addContestant(() -> {
try (Transaction tx = db.getGraphDatabaseAPI().beginTx()) {
Node node = db.getGraphDatabaseAPI().getNodeById(latestNodeId[0]);
for (String propertyKey : node.getPropertyKeys()) {
node.getProperty(propertyKey);
}
tx.success();
} catch (NotFoundException e) {
// This will catch nodes not found (expected) and also PropertyRecords not found (shouldn't happen
// but handled in shouldWriteOutThePropertyRecordBeforeReferencingItFromANodeRecord)
}
reads.incrementAndGet();
});
race.go();
}
Aggregations