synchronized void checkLeases ( ) { int numPathsChecked = 0 ; for ( ; sortedLeases . size ( ) > 0 ; ) { final Lease oldest = sortedLeases . first ( ) ; if ( ! oldest . expiredHardLimit ( ) ) { return ; } // internalReleaseLease() removes paths corresponding to empty files, // i.e. it needs to modify the collection being iterated over // causing ConcurrentModificationException String [ ] leasePaths = new String [ oldest . getPaths ( ) . size ( ) ] ; oldest . getPaths ( ) . toArray ( leasePaths ) ; LOG . info ( "Lease " + oldest + " has expired hard limit. Recovering lease for paths: " + Arrays . toString ( leasePaths ) ) ; for ( String p : leasePaths ) { if ( ++ numPathsChecked > this . maxPathsPerCheck ) { return ; } try { fsnamesystem . getFSNamesystemMetrics ( ) . numLeaseRecoveries . inc ( ) ; fsnamesystem . internalReleaseLeaseOne ( oldest , p , this . discardLastBlockIfNoSync ) ; } catch ( IOException e ) { LOG . error ( "Cannot release the path " + p + " in the lease " + oldest , e ) ; removeLease ( oldest , p ) ; fsnamesystem . getFSNamesystemMetrics ( ) . numLeaseManagerMonitorExceptions . inc ( ) ; } } } }
Check the leases beginning from the oldest .