@ThreadSafe public class ConsistentHashProvider extends Object
Constructor and Description |
---|
ConsistentHashProvider(int maxAttempts,
long workerListTtlMs)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
List<BlockWorkerInfo> |
getMultiple(String key,
int count)
Finds multiple workers from the hash ring.
|
void |
refresh(List<BlockWorkerInfo> workerInfos,
int numVirtualNodes)
Initializes or refreshes the worker list using the given list of workers and number of
virtual nodes.
|
public ConsistentHashProvider(int maxAttempts, long workerListTtlMs)
maxAttempts
- max attempts to rehashworkerListTtlMs
- interval between retriespublic List<BlockWorkerInfo> getMultiple(String key, int count)
key
- the key to hash oncount
- the expected number of workerspublic void refresh(List<BlockWorkerInfo> workerInfos, int numVirtualNodes)
workerInfos
- the up-to-date worker listnumVirtualNodes
- the number of virtual nodes used by consistent hashingCopyright © 2023. All Rights Reserved.