Class ConsistentHashRing
java.lang.Object
org.apache.hadoop.hdfs.server.federation.utils.ConsistentHashRing
Consistent hash ring to distribute items across nodes (locations). If we add
or remove nodes, it minimizes the item migration.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddLocation(String location) Add entry to consistent hash ring.voidaddLocation(String location, int numVirtualNodes) Add entry to consistent hash ring.getLocation(String item) Return location (owner) of specified item.Get the locations in the ring.voidremoveLocation(String location) Remove specified entry from hash ring.
-
Constructor Details
-
ConsistentHashRing
-
-
Method Details
-
addLocation
Add entry to consistent hash ring.- Parameters:
location- Node to add to the ring.
-
addLocation
Add entry to consistent hash ring.- Parameters:
location- Node to add to the ring.numVirtualNodes- Number of virtual nodes to add.
-
removeLocation
Remove specified entry from hash ring.- Parameters:
location- Node to remove from the ring.
-
getLocation
Return location (owner) of specified item. Owner is the next entry on the hash ring (with a hash value > hash value of item).- Parameters:
item- Item to look for.- Returns:
- The location of the item.
-
getHash
-
getLocations
Get the locations in the ring.- Returns:
- Set of locations in the ring.
-