Object PartitionHasher

  • All Implemented Interfaces:

    
    public class PartitionHasher
    
                        

    Utility for calculating partition assignments using consistent hashing.

    This class provides deterministic partition assignment for aggregate IDs, ensuring that the same aggregate ID always maps to the same partition.

    Since:

    0.2.0

    Author:

    Roland Beisel

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      final Integer getPartitionForAggregate(String aggregateId) Calculates the partition number for a given aggregate ID.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

    • Method Detail

      • getPartitionForAggregate

         final Integer getPartitionForAggregate(String aggregateId)

        Calculates the partition number for a given aggregate ID.

        Uses consistent hashing to ensure the same aggregate ID always maps to the same partition, regardless of the number of instances.

        Parameters:
        aggregateId - The aggregate ID to calculate partition for
        Returns:

        Partition number between 0 and TOTAL_PARTITIONS-1