public static String getHost ( TextArrayWritable hosts ) throws IOException { String [ ] hostStrings = hosts . toStrings ( ) ; if ( hostStrings == null || hostStrings . length == 0 ) throw new IOException ( "Number of forests is 0: " + "check forests in database" ) ; int count = hostStrings . length ; int position = ( int ) ( Math . random ( ) * count ) ; return hostStrings [ position ] ; }
Return the host from the host array based on a random fashion