private String findConsumerByPartition(final TreeMap<Long, String> consumerMap, final String partition) {
        final Long hash = this.alg.hash(partition);
        Long target = hash;
        if (!consumerMap.containsKey(hash)) {
            target = consumerMap.ceilingKey(hash);
            // if (hash == null) {
            // target = consumerMap.floorKey(hash);
            // }
            // else {
            // final Long floor = consumerMap.floorKey(hash);
            // if (floor != null) {
            // target = Math.abs(hash - floor) > Math.abs(hash - target) ?
            // target : floor;
            // }
            // }
            if (target == null && !consumerMap.isEmpty()) {
                target = consumerMap.firstKey();
            }
        }
        final String targetConsumer = consumerMap.get(target);
        return targetConsumer;
    }
Get the md5 of the given key.
metamorphosis-client/src/main/java/com/taobao/metamorphosis/client/consumer/ConsisHashStrategy.java