MemcachedNode getNodeForKey(long hash) {
    final MemcachedNode rv;
    if (!ketamaNodes.containsKey(hash)) {
      // Java 1.6 adds a ceilingKey method, but I'm still stuck in 1.5
      // in a lot of places, so I'm doing this myself.
      SortedMap<Long, MemcachedNode> tailMap = getKetamaNodes().tailMap(hash);
      if (tailMap.isEmpty()) {
        hash = getKetamaNodes().firstKey();
      } else {
        hash = tailMap.firstKey();
      }
    }
    rv = getKetamaNodes().get(hash);
    return rv;
  }
Create a new KetamaNodeLocator with specific nodes, hash, node key format,
and weight

@param nodes The List of nodes to use in the Ketama consistent hash
         continuum
@param alg The hash algorithm to use when choosing a node in the Ketama
         consistent hash continuum
@param weights node weights for ketama, a map from InetSocketAddress to
         weight as Integer
@param configuration node locator configuration
src/main/java/net/spy/memcached/KetamaNodeLocator.java