public void removeVolumes ( Configuration conf , List < File > directories ) throws Exception { if ( directories == null || directories . isEmpty ( ) ) { DataNode . LOG . warn ( "There were no directories to remove. Exiting " ) ; return ; } List < FSVolume > volArray = null ; lock . readLock ( ) . lock ( ) ; try { volArray = volumes . removeBVolumes ( directories ) ; } finally { lock . readLock ( ) . unlock ( ) ; } // remove related blocks long mlsec = System . currentTimeMillis ( ) ; lock . writeLock ( ) . lock ( ) ; try { volumeMap . removeUnhealthyVolumes ( volArray ) ; } finally { lock . writeLock ( ) . unlock ( ) ; } mlsec = System . currentTimeMillis ( ) - mlsec ; DataNode . LOG . warn ( ">>>>>>>>>Removing these blocks took " + mlsec + " millisecs in refresh<<<<<<<<<<<<<<< " ) ; StringBuilder sb = new StringBuilder ( ) ; for ( FSVolume fv : volArray ) { sb . append ( fv . toString ( ) + ";" ) ; } throw new DiskErrorException ( "These volumes were removed: " + sb ) ; }
remove directories that are given from the list of volumes to use . This function also makes sure to remove all the blocks that belong to these volumes .