Example usage for com.google.common.hash Hashing consistentHash

List of usage examples for com.google.common.hash Hashing consistentHash

Introduction

In this page you can find the example usage for com.google.common.hash Hashing consistentHash.

Prototype

public static int consistentHash(long input, int buckets) 

Source Link

Document

Assigns to input a "bucket" in the range [0, buckets) , in a uniform manner that minimizes the need for remapping as buckets grows.

Usage

From source file:org.hawkular.metrics.tasks.impl.TaskSchedulerImpl.java

int computeShard(String key) {
    HashCode hashCode = hashFunction.hashBytes(key.getBytes());
    return Hashing.consistentHash(hashCode, numShards);
}