Class ShardStrategy<T extends Endpoint>
java.lang.Object
services.moleculer.strategy.Strategy<T>
services.moleculer.strategy.ArrayBasedStrategy<T>
services.moleculer.strategy.XorShiftRandomStrategy<T>
services.moleculer.strategy.ShardStrategy<T>
Sharding invocation strategy. Using consistent-hashing.
More info: https://www.toptal.com/big-data/consistent-hashing
More info: https://www.toptal.com/big-data/consistent-hashing
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final intSize of the memory cache (0 = disabled)Hasher function (generated hash is 32 bits long, default method is MD5)protected final AtomicReference<ShardStrategy.Ring> The "hash ring" (https://www.toptal.com/big-data/consistent-hashing)protected final IntegerRing size (optional)protected final StringShard key's path (eg.protected final booleanSize of the memory cache (0 = disabled)protected final intNumber of virtual nodesFields inherited from class XorShiftRandomStrategy
rndFields inherited from class ArrayBasedStrategy
endpointCache, endpoints, nodeID, preferLocal -
Constructor Summary
ConstructorsConstructorDescriptionShardStrategy(ServiceBroker broker, boolean preferLocal, String shardKey, int vnodes, Integer ringSize, int cacheSize, Function<String, Long> hash) -
Method Summary
Methods inherited from class ArrayBasedStrategy
getAllEndpoints, getEndpoint, getEndpointsByNodeID, isEmpty
-
Field Details
-
shardKey
Shard key's path (eg. "userID", "user.email", etc.) -
vnodes
protected final int vnodesNumber of virtual nodes -
ringSize
Ring size (optional) -
useMeta
protected final boolean useMetaSize of the memory cache (0 = disabled) -
cacheSize
protected final int cacheSizeSize of the memory cache (0 = disabled) -
ringRef
The "hash ring" (https://www.toptal.com/big-data/consistent-hashing) -
hash
-
-
Constructor Details
-
ShardStrategy
-
-
Method Details
-
addEndpoint
- Overrides:
addEndpointin classArrayBasedStrategy<T extends Endpoint>
-
remove
- Overrides:
removein classArrayBasedStrategy<T extends Endpoint>
-
next
-
getKeyFromContext
-
rebuild
protected void rebuild()
-