@VisibleForTesting public static int determineLocation( List<String> locations, String path, long start, String desc) { byte[] bytes = getHashInputForSplit(path, start); long hash1 = hash1(bytes); int index = Hashing.consistentHash(hash1, locations.size()); String location = locations.get(index); if (LOG.isDebugEnabled()) { LOG.debug(desc + " mapped to index=" + index + ", location=" + location); } int iter = 1; long hash2 = 0; // Since our probing method is totally bogus, give up after some time. while (location == null && iter < locations.size() * 2) { if (iter == 1) { hash2 = hash2(bytes); } // Note that this is not real double hashing since we have consistent hash on top. index = Hashing.consistentHash(hash1 + iter * hash2, locations.size()); location = locations.get(index); if (LOG.isDebugEnabled()) { LOG.debug(desc + " remapped to index=" + index + ", location=" + location); } ++iter; } return index; }
@VisibleForTesting public static int determineLocation( List<String> locations, String path, long start, String desc) { byte[] bytes = getHashInputForSplit(path, start); long hash1 = hash1(bytes); int index = Hashing.consistentHash(hash1, locations.size()); String location = locations.get(index); if (LOG.isDebugEnabled()) { LOG.debug(desc + " mapped to index=" + index + ", location=" + location); } int iter = 1; long hash2 = 0; // Since our probing method is totally bogus, give up after some time. while (location == null && iter < locations.size() * 2) { if (iter == 1) { hash2 = hash2(bytes); } // Note that this is not real double hashing since we have consistent hash on top. index = Hashing.consistentHash(hash1 + iter * hash2, locations.size()); location = locations.get(index); if (LOG.isDebugEnabled()) { LOG.debug(desc + " remapped to index=" + index + ", location=" + location); } ++iter; } return index; }