private List < Integer > computeHashCodes ( String endPointId ) { // Use the libketama approach of using MD5 hashes to generate 32-bit random values. This assigns a set of // randomly generated ranges to each end point. The individual ranges may vary widely in size, but, with // sufficient # of entries per end point, the overall amount of data assigned to each server tends to even out // with minimal variation (256 entries per server yields roughly 5% variation in server load). List < Integer > list = Lists . newArrayListWithCapacity ( _entriesPerEndPoint ) ; for ( int i = 0 ; list . size ( ) < _entriesPerEndPoint ; i ++ ) { Hasher hasher = Hashing . md5 ( ) . newHasher ( ) ; hasher . putInt ( i ) ; putUnencodedChars ( hasher , endPointId ) ; ByteBuffer buf = ByteBuffer . wrap ( hasher . hash ( ) . asBytes ( ) ) ; while ( buf . hasRemaining ( ) && list . size ( ) < _entriesPerEndPoint ) { list . add ( buf . getInt ( ) ) ; } } return list ; }
Returns a list of pseudo - random 32 - bit values derived from the specified end point ID .