Search in sources :

Example 66 with NotFoundException

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
    }
}
Also used : Transaction(org.neo4j.graphdb.Transaction) HighlyAvailableGraphDatabase(org.neo4j.kernel.ha.HighlyAvailableGraphDatabase) Node(org.neo4j.graphdb.Node) NotFoundException(org.neo4j.graphdb.NotFoundException) Test(org.junit.Test)

Example 67 with NotFoundException

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;
}
Also used : NotFoundException(org.neo4j.graphdb.NotFoundException) InvalidRecordException(org.neo4j.kernel.impl.nioneo.store.InvalidRecordException)

Example 68 with NotFoundException

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;
}
Also used : NotFoundException(org.neo4j.graphdb.NotFoundException) InvalidRecordException(org.neo4j.kernel.impl.nioneo.store.InvalidRecordException)

Example 69 with NotFoundException

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
    }
}
Also used : Transaction(org.neo4j.graphdb.Transaction) InputNode(org.neo4j.unsafe.impl.batchimport.input.InputNode) Node(org.neo4j.graphdb.Node) NotFoundException(org.neo4j.graphdb.NotFoundException)

Example 70 with NotFoundException

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());
    }
}
Also used : NotFoundException(org.neo4j.graphdb.NotFoundException)

Aggregations

NotFoundException (org.neo4j.graphdb.NotFoundException)87 Node (org.neo4j.graphdb.Node)43 Test (org.junit.Test)36 Relationship (org.neo4j.graphdb.Relationship)24 Transaction (org.neo4j.graphdb.Transaction)24 Statement (org.neo4j.kernel.api.Statement)18 EntityNotFoundException (org.neo4j.kernel.api.exceptions.EntityNotFoundException)14 PropertyNotFoundException (org.neo4j.kernel.api.exceptions.PropertyNotFoundException)13 ReentrantLock (java.util.concurrent.locks.ReentrantLock)8 EndNodeNotFoundException (org.neo4j.server.rest.domain.EndNodeNotFoundException)7 StartNodeNotFoundException (org.neo4j.server.rest.domain.StartNodeNotFoundException)7 RelationshipType (org.neo4j.graphdb.RelationshipType)5 ReadOperations (org.neo4j.kernel.api.ReadOperations)4 SchemaRuleNotFoundException (org.neo4j.kernel.api.exceptions.schema.SchemaRuleNotFoundException)4 KeyReadOperations (org.neo4j.kernel.impl.api.operations.KeyReadOperations)4 InvalidRecordException (org.neo4j.kernel.impl.nioneo.store.InvalidRecordException)4 Race (org.neo4j.test.Race)4 ArrayList (java.util.ArrayList)3 ConstraintViolationException (org.neo4j.graphdb.ConstraintViolationException)3 StatementTokenNameLookup (org.neo4j.kernel.api.StatementTokenNameLookup)3