UniformAcrossAllShards

public final class UniformAcrossAllShards extends DeliveryStrategy implements Serializable

The strategy of splitting the entities into a number of shards uniformly.

Uses a hash code of the entity identifier and the remainder of its division by the total number of shards to determine the index of a shard, at which the modification is allowed. To reach the consistency of the hash code values across JVMs, the MurmurHash3, x86 variant is used.

While Guava's Hashing is marked @Beta, it is still the best option for hashing functions — not to involve any heavy-weight third-party hashing solutions.

Functions

Link copied to clipboard
public static DeliveryStrategy forNumber(int totalShards)
Creates a strategy of uniform target distribution across shards, for a given shard number.
Link copied to clipboard
public ShardIndex indexFor(Object entityId, TypeUrl entityStateType)
Determines the shard index for the messages heading to the entity with the specified target identifier.
Link copied to clipboard
public int shardCount()
Tells how many shards there are according to this strategy.
Link copied to clipboard
public static DeliveryStrategy singleShard()
Returns a pre-defined strategy instance, which defines a single shard and puts all the targets into it.

Inherited functions

Link copied to clipboard
public final ShardIndex determineIndex(Object entityId, TypeUrl entityStateType)
Link copied to clipboard
public static ShardIndex newIndex(int indexValue, int ofTotal)
Creates a new ShardIndex according to the passed shard index The passed shard index value must be less than the total number of shards specified.