public class ShardStrategy<T extends Endpoint> extends XorShiftRandomStrategy<T>
| Modifier and Type | Class and Description |
|---|---|
protected static class |
ShardStrategy.Ring |
| Modifier and Type | Field and Description |
|---|---|
protected int |
cacheSize
Size of the memory cache (0 = disabled)
|
protected java.util.function.Function<java.lang.String,java.lang.Long> |
hash
Hasher function (generated hash is 32 bits long, default method is MD5)
|
protected java.util.concurrent.atomic.AtomicReference<ShardStrategy.Ring> |
ringRef
The "hash ring" (https://www.toptal.com/big-data/consistent-hashing)
|
protected java.lang.Integer |
ringSize
Ring size (optional)
|
protected java.lang.String |
shardKey
Shard key's path (eg.
|
protected boolean |
useMeta
Size of the memory cache (0 = disabled)
|
protected int |
vnodes
Number of virtual nodes
|
rndendpointCache, endpoints, nodeID, preferLocal| Constructor and Description |
|---|
ShardStrategy(ServiceBroker broker,
boolean preferLocal,
java.lang.String shardKey,
int vnodes,
java.lang.Integer ringSize,
int cacheSize,
java.util.function.Function<java.lang.String,java.lang.Long> hash) |
| Modifier and Type | Method and Description |
|---|---|
void |
addEndpoint(T endpoint) |
protected java.lang.String |
getKeyFromContext(Context ctx) |
Endpoint |
next(Context ctx,
Endpoint[] array) |
protected void |
rebuild() |
boolean |
remove(java.lang.String nodeID) |
getAllEndpoints, getEndpoint, getEndpointsByNodeID, isEmptyprotected final java.lang.String shardKey
protected final int vnodes
protected final java.lang.Integer ringSize
protected final boolean useMeta
protected final int cacheSize
protected final java.util.concurrent.atomic.AtomicReference<ShardStrategy.Ring> ringRef
protected final java.util.function.Function<java.lang.String,java.lang.Long> hash
public ShardStrategy(ServiceBroker broker, boolean preferLocal, java.lang.String shardKey, int vnodes, java.lang.Integer ringSize, int cacheSize, java.util.function.Function<java.lang.String,java.lang.Long> hash)
public void addEndpoint(T endpoint)
addEndpoint in class ArrayBasedStrategy<T extends Endpoint>public boolean remove(java.lang.String nodeID)
remove in class ArrayBasedStrategy<T extends Endpoint>public Endpoint next(Context ctx, Endpoint[] array)
next in class XorShiftRandomStrategy<T extends Endpoint>protected java.lang.String getKeyFromContext(Context ctx)
protected void rebuild()