public static boolean saveStaticResolutions ( Configuration conf ) { List < String [ ] > staticResolutions = NetUtils . getAllStaticResolutions ( ) ; if ( staticResolutions != null && staticResolutions . size ( ) > 0 ) { StringBuffer str = new StringBuffer ( ) ; for ( int i = 0 ; i < staticResolutions . size ( ) ; i ++ ) { String [ ] hostToResolved = staticResolutions . get ( i ) ; str . append ( hostToResolved [ 0 ] + "=" + hostToResolved [ 1 ] ) ; if ( i != staticResolutions . size ( ) - 1 ) { str . append ( ' ' ) ; } } conf . set ( "hadoop.net.static.resolutions" , str . toString ( ) ) ; return true ; } return false ; }
Save the static resolutions to configuration . This is required for junit to work on testcases that simulate multiple nodes on a single physical node .