コード例 #1
0
ファイル: NodeImpl.java プロジェクト: neo4j-attic/graphdb
 public void delete(NodeManager nodeManager) {
   nodeManager.acquireLock(this, LockType.WRITE);
   boolean success = false;
   try {
     ArrayMap<Integer, PropertyData> skipMap = nodeManager.getCowPropertyRemoveMap(this, true);
     ArrayMap<Integer, PropertyData> removedProps = nodeManager.deleteNode(this);
     if (removedProps.size() > 0) {
       for (int index : removedProps.keySet()) {
         skipMap.put(index, removedProps.get(index));
       }
     }
     success = true;
   } finally {
     nodeManager.releaseLock(this, LockType.WRITE);
     if (!success) {
       nodeManager.setRollbackOnly();
     }
   }
 }
コード例 #2
0
  public void delete(NodeManager nodeManager) {
    NodeImpl startNode = null;
    NodeImpl endNode = null;
    boolean startNodeLocked = false;
    boolean endNodeLocked = false;
    boolean thisLocked = false;
    boolean success = false;
    try {
      startNode = nodeManager.getLightNode(getStartNodeId());
      if (startNode != null) {
        nodeManager.acquireLock(startNode, LockType.WRITE);
        startNodeLocked = true;
      }
      endNode = nodeManager.getLightNode(getEndNodeId());
      if (endNode != null) {
        nodeManager.acquireLock(endNode, LockType.WRITE);
        endNodeLocked = true;
      }
      nodeManager.acquireLock(this, LockType.WRITE);
      thisLocked = true;
      // no need to load full relationship, all properties will be
      // deleted when relationship is deleted

      ArrayMap<Integer, PropertyData> skipMap = nodeManager.getCowPropertyRemoveMap(this, true);
      ArrayMap<Integer, PropertyData> removedProps = nodeManager.deleteRelationship(this);
      if (removedProps.size() > 0) {
        for (int index : removedProps.keySet()) {
          skipMap.put(index, removedProps.get(index));
        }
      }
      success = true;
      RelationshipType type = getType(nodeManager);
      long id = getId();
      if (startNode != null) {
        startNode.removeRelationship(nodeManager, type, id);
      }
      if (endNode != null) {
        endNode.removeRelationship(nodeManager, type, id);
      }
      success = true;
    } finally {
      boolean releaseFailed = false;
      try {
        if (thisLocked) {
          nodeManager.releaseLock(this, LockType.WRITE);
        }
      } catch (Exception e) {
        releaseFailed = true;
        e.printStackTrace();
      }
      try {
        if (startNodeLocked) {
          nodeManager.releaseLock(startNode, LockType.WRITE);
        }
      } catch (Exception e) {
        releaseFailed = true;
        e.printStackTrace();
      }
      try {
        if (endNodeLocked) {
          nodeManager.releaseLock(endNode, LockType.WRITE);
        }
      } catch (Exception e) {
        releaseFailed = true;
        e.printStackTrace();
      }
      if (!success) {
        nodeManager.setRollbackOnly();
      }
      if (releaseFailed) {
        throw new LockException(
            "Unable to release locks ["
                + startNode
                + ","
                + endNode
                + "] in relationship delete->"
                + this);
      }
    }
  }