private static boolean waitUntilLeaseIsRevoked ( final FileSystem fs , final Path path ) throws IOException { Preconditions . checkState ( fs instanceof DistributedFileSystem ) ; final DistributedFileSystem dfs = ( DistributedFileSystem ) fs ; dfs . recoverLease ( path ) ; final Deadline deadline = Deadline . now ( ) . plus ( Duration . ofMillis ( LEASE_TIMEOUT ) ) ; final StopWatch sw = new StopWatch ( ) ; sw . start ( ) ; boolean isClosed = dfs . isFileClosed ( path ) ; while ( ! isClosed && deadline . hasTimeLeft ( ) ) { try { Thread . sleep ( 500L ) ; } catch ( InterruptedException e1 ) { throw new IOException ( "Recovering the lease failed: " , e1 ) ; } isClosed = dfs . isFileClosed ( path ) ; } return isClosed ; }
Called when resuming execution after a failure and waits until the lease of the file we are resuming is free .