public ServiceInformation get ( String key ) { ServiceInformation info = null ; long hash = algorithm . hash ( key ) ; //Find the first server with a hash key after this one final SortedMap < Long , ServiceInformation > tailMap = ring . tailMap ( hash ) ; //Wrap around to the beginning of the ring, if we went past the last one hash = tailMap . isEmpty ( ) ? ring . firstKey ( ) : tailMap . firstKey ( ) ; info = ring . get ( hash ) ; return info ; }
Returns the appropriate server for the given key .