void reloadWhitelist ( ) throws IOException { // read the entire whitelist into memory outside the // FSNamessytem lock. // LinkedList < String > paths = new LinkedList < String > ( ) ; FileInputStream fstream = new FileInputStream ( whitelistFile ) ; DataInputStream in = new DataInputStream ( fstream ) ; BufferedReader br = new BufferedReader ( new InputStreamReader ( in ) ) ; int count = 0 ; while ( true ) { String str = br . readLine ( ) ; if ( str == null ) { break ; // end of file } str = str . trim ( ) ; // remove all whitespace from start and end if ( str . startsWith ( "#" ) ) { continue ; // ignore lines with starting with # } paths . add ( str ) ; LOG . info ( "Whitelisted directory [" + count + "] " + str ) ; count ++ ; } in . close ( ) ; // acquire the writelock and insert newly read entries into // the Namenode's configuration. namesys . writeLock ( ) ; try { namesys . neverDeletePaths . clear ( ) ; for ( String s : paths ) { namesys . neverDeletePaths . add ( s ) ; } } finally { namesys . writeUnlock ( ) ; } }
Removes all the entries currently in neverDeletePaths and add the new ones specified