@Test public void lockEdgeAfterEdge() { mLockList.lockEdge(mDirA, mDirB.getName(), LockMode.READ); mThrown.expect(IllegalStateException.class); mLockList.lockEdge(mDirB, mFileC.getName(), LockMode.READ); }
@Override public void lockEdge(Inode lastInode, String childName, LockMode mode) { mode = nextLockMode(mode); long edgeParentId = lastInode.getId(); Edge edge = new Edge(lastInode.getId(), childName); if (!mLocks.isEmpty()) { Preconditions.checkState(endsInInode(), "Cannot lock edge %s when lock list %s already ends in an edge", edge, this); Preconditions.checkState(lastInode().getId() == edgeParentId, "Cannot lock edge %s when the last inode id in %s is %s", edge, this, lastInode.getId()); } lockAndAddEdge(edge, mode); }
SimpleInodeLockList implements InodeLockList { @Override public void lockEdge(Inode lastInode, String childName, LockMode mode) { mode = nextLockMode(mode); long edgeParentId = lastInode.getId(); Edge edge = new Edge(lastInode.getId(), childName); if (!mLocks.isEmpty()) { Preconditions.checkState(endsInInode(), "Cannot lock edge %s when lock list %s already ends in an edge", edge, this); Preconditions.checkState(lastInode().getId() == edgeParentId, "Cannot lock edge %s when the last inode id in %s is %s", edge, this, lastInode.getId()); } lockAndAddEdge(edge, mode); } }
SimpleInodeLockList implements InodeLockList { @Override public void lockEdge(Inode lastInode, String childName, LockMode mode) { mode = nextLockMode(mode); long edgeParentId = lastInode.getId(); Edge edge = new Edge(lastInode.getId(), childName); if (!mLocks.isEmpty()) { Preconditions.checkState(endsInInode(), "Cannot lock edge %s when lock list %s already ends in an edge", edge, this); Preconditions.checkState(lastInode().getId() == edgeParentId, "Cannot lock edge %s when the last inode id in %s is %s", edge, this, lastInode.getId()); } lockAndAddEdge(edge, mode); } SimpleInodeLockList(InodeLockManager inodeLockManager, boolean useTryLock); }
SimpleInodeLockList implements InodeLockList { @Override public void lockEdge(Inode lastInode, String childName, LockMode mode) { mode = nextLockMode(mode); long edgeParentId = lastInode.getId(); Edge edge = new Edge(lastInode.getId(), childName); if (!mLocks.isEmpty()) { Preconditions.checkState(endsInInode(), "Cannot lock edge %s when lock list %s already ends in an edge", edge, this); Preconditions.checkState(lastInode().getId() == edgeParentId, "Cannot lock edge %s when the last inode id in %s is %s", edge, this, lastInode.getId()); } lockAndAddEdge(edge, mode); } SimpleInodeLockList(InodeLockManager inodeLockManager, boolean useTryLock); @Override void lockInode(Inode inode, LockMode mode); @Override void lockEdge(Inode lastInode, String childName, LockMode mode); @Override void lockRootEdge(LockMode mode); @Override void pushWriteLockedEdge(Inode inode, String childName); @Override void unlockLastInode(); @Override void unlockLastEdge(); @Override void downgradeToReadLocks(); @Override void downgradeLastEdge(); @Override LockMode getLockMode(); @Override List<Inode> getLockedInodes(); @Override Inode get(int index); @Override int numInodes(); @Override boolean isEmpty(); @Override InodeLockManager getInodeLockManager(); @Override boolean endsInInode(); @Override String toString(); @Override void close(); }
SimpleInodeLockList implements InodeLockList { @Override public void lockEdge(Inode lastInode, String childName, LockMode mode) { mode = nextLockMode(mode); long edgeParentId = lastInode.getId(); Edge edge = new Edge(lastInode.getId(), childName); if (!mLocks.isEmpty()) { Preconditions.checkState(endsInInode(), "Cannot lock edge %s when lock list %s already ends in an edge", edge, this); Preconditions.checkState(lastInode().getId() == edgeParentId, "Cannot lock edge %s when the last inode id in %s is %s", edge, this, lastInode.getId()); } lockAndAddEdge(edge, mode); } SimpleInodeLockList(InodeLockManager inodeLockManager, boolean useTryLock); @Override void lockInode(Inode inode, LockMode mode); @Override void lockEdge(Inode lastInode, String childName, LockMode mode); @Override void lockRootEdge(LockMode mode); @Override void pushWriteLockedEdge(Inode inode, String childName); @Override void unlockLastInode(); @Override void unlockLastEdge(); @Override void downgradeToReadLocks(); @Override void downgradeLastEdge(); @Override LockMode getLockMode(); @Override List<Inode> getLockedInodes(); @Override Inode get(int index); @Override int numInodes(); @Override boolean isEmpty(); @Override InodeLockManager getInodeLockManager(); @Override boolean endsInInode(); @Override String toString(); @Override void close();  }