public InodePathPair lockInodePathPair ( AlluxioURI path1 , LockPattern lockPattern1 , AlluxioURI path2 , LockPattern lockPattern2 ) throws InvalidPathException { LockedInodePath lockedPath1 = null ; LockedInodePath lockedPath2 = null ; boolean valid = false ; try { // Lock paths in a deterministic order. if ( path1 . getPath ( ) . compareTo ( path2 . getPath ( ) ) > 0 ) { lockedPath2 = lockInodePath ( path2 , lockPattern2 ) ; lockedPath1 = lockInodePath ( path1 , lockPattern1 ) ; } else { lockedPath1 = lockInodePath ( path1 , lockPattern1 ) ; lockedPath2 = lockInodePath ( path2 , lockPattern2 ) ; } valid = true ; return new InodePathPair ( lockedPath1 , lockedPath2 ) ; } finally { if ( ! valid ) { if ( lockedPath1 != null ) { lockedPath1 . close ( ) ; } if ( lockedPath2 != null ) { lockedPath2 . close ( ) ; } } } }
Locks existing inodes on the two specified paths . The two paths will be locked in the correct order . The target inodes are not required to exist .