@Override
  public void pushWriteLockedEdge(Inode inode, String childName) {
    Edge edge = new Edge(inode.getId(), childName);
    Preconditions.checkState(!endsInInode(),
        "Cannot push edge write lock to edge %s; lock list %s ends in an inode", edge, this);
    Preconditions.checkState(endsInWriteLock(),
        "Cannot push write lock; lock list %s ends in a read lock");

    if (endsInMultipleWriteLocks()) {
      // If the lock before the edge lock is already WRITE, we can just acquire more WRITE locks.
      lockInode(inode, LockMode.WRITE);
      lockEdge(inode, childName, LockMode.WRITE);
    } else {
      Edge lastEdge = lastEdge();
      RWLockResource lastEdgeReadLock = mInodeLockManager.lockEdge(lastEdge, LockMode.READ,
          mUseTryLock);
      RWLockResource inodeLock = mInodeLockManager.lockInode(inode, LockMode.READ, mUseTryLock);
      RWLockResource nextEdgeLock = mInodeLockManager.lockEdge(edge, LockMode.WRITE, mUseTryLock);
      removeLastLock(); // Remove edge write lock
      addEdgeLock(lastEdge, LockMode.READ, lastEdgeReadLock);
      addInodeLock(inode, LockMode.READ, inodeLock);
      addEdgeLock(edge, LockMode.WRITE, nextEdgeLock);
    }
  }
@Test
  public void pushWriteLockedEdge() {
    mLockList.lockRootEdge(LockMode.WRITE);
    assertEquals(LockMode.WRITE, mLockList.getLockMode());
    assertTrue(mLockList.getLockedInodes().isEmpty());

    mLockList.pushWriteLockedEdge(mRootDir, mDirA.getName());
    assertEquals(LockMode.WRITE, mLockList.getLockMode());
    assertEquals(Arrays.asList(mRootDir), mLockList.getLockedInodes());

    mLockList.pushWriteLockedEdge(mDirA, mDirB.getName());
    assertEquals(LockMode.WRITE, mLockList.getLockMode());
    assertEquals(Arrays.asList(mRootDir, mDirA), mLockList.getLockedInodes());

    checkOnlyNodesReadLocked(mRootDir, mDirA);
    checkOnlyNodesWriteLocked();
    checkOnlyIncomingEdgesReadLocked(mRootDir, mDirA);
    checkOnlyIncomingEdgesWriteLocked(mDirB);
  }