use of org.neo4j.graphdb.NotFoundException in project neo4j by neo4j.
the class TransactionConstraintsIT method slaveShouldNotBeAbleToModifyNodeDeletedOnMaster.
@Test
public void slaveShouldNotBeAbleToModifyNodeDeletedOnMaster() throws Exception {
// GIVEN
// -- node created on slave
HighlyAvailableGraphDatabase aSlave = cluster.getAnySlave();
Node node = createNode(aSlave, PROPERTY_VALUE);
// -- that node delete on master, but the slave doesn't see it yet
deleteNode(cluster.getMaster(), node.getId());
// WHEN
try (Transaction slaveTransaction = aSlave.beginTx()) {
node.setProperty("name", "test");
fail("Shouldn't be able to modify a node deleted on master");
} catch (NotFoundException e) {
// THEN
// -- the transactions gotten back in the response should delete that node
}
}
use of org.neo4j.graphdb.NotFoundException in project graphdb by neo4j-attic.
the class BatchGraphDatabaseImpl method getNodeById.
public Node getNodeById(long id) {
NodeBatchImpl node = nodes.get(id);
if (node == null) {
try {
node = new NodeBatchImpl(id, this, batchInserter.getNodeProperties(id));
nodes.put(id, node);
} catch (InvalidRecordException e) {
throw new NotFoundException(e);
}
}
return node;
}
use of org.neo4j.graphdb.NotFoundException in project graphdb by neo4j-attic.
the class BatchGraphDatabaseImpl method getRelationshipById.
public Relationship getRelationshipById(long id) {
RelationshipBatchImpl rel = rels.get(id);
if (rel == null) {
try {
SimpleRelationship simpleRel = batchInserter.getRelationshipById(id);
Map<String, Object> props = batchInserter.getRelationshipProperties(id);
rel = new RelationshipBatchImpl(simpleRel, this, props);
rels.put(id, rel);
} catch (InvalidRecordException e) {
throw new NotFoundException(e);
}
}
return rel;
}
use of org.neo4j.graphdb.NotFoundException in project neo4j by neo4j.
the class MultipleIndexPopulationStressIT method changeRandomNode.
private void changeRandomNode(GraphDatabaseService db, int nodeCount, Randoms random) {
try (Transaction tx = db.beginTx()) {
long nodeId = random.random().nextInt(nodeCount);
Node node = db.getNodeById(nodeId);
Object[] keys = Iterables.asCollection(node.getPropertyKeys()).toArray();
String key = (String) random.among(keys);
if (random.random().nextFloat() < 0.1) {
// REMOVE
node.removeProperty(key);
} else {
// CHANGE
node.setProperty(key, randomPropertyValue(random.random()));
}
tx.success();
} catch (NotFoundException e) {
// It's OK, it happens if some other thread deleted that property in between us reading it and
// removing or setting it
}
}
use of org.neo4j.graphdb.NotFoundException in project neo4j by neo4j.
the class DatabaseContentVerifier method verifyProperties.
public void verifyProperties(PropertyContainer node) {
try {
assertEquals(Integer.MAX_VALUE, node.getProperty(PropertyType.INT.name()));
assertEquals(longString, node.getProperty(PropertyType.STRING.name()));
assertEquals(true, node.getProperty(PropertyType.BOOL.name()));
assertEquals(Double.MAX_VALUE, node.getProperty(PropertyType.DOUBLE.name()));
assertEquals(Float.MAX_VALUE, node.getProperty(PropertyType.FLOAT.name()));
assertEquals(Long.MAX_VALUE, node.getProperty(PropertyType.LONG.name()));
assertEquals(Byte.MAX_VALUE, node.getProperty(PropertyType.BYTE.name()));
assertEquals(Character.MAX_VALUE, node.getProperty(PropertyType.CHAR.name()));
assertArrayEquals(longArray, (int[]) node.getProperty(PropertyType.ARRAY.name()));
assertEquals(Short.MAX_VALUE, node.getProperty(PropertyType.SHORT.name()));
assertEquals("short", node.getProperty(PropertyType.SHORT_STRING.name()));
} catch (NotFoundException e) {
throw new NotFoundException(e.getMessage() + " for " + node, e.getCause());
}
}
Aggregations