Record Class WanMerkleTree

java.lang.Object
java.lang.Record
com.loomcache.server.wan.WanMerkleTree

public record WanMerkleTree(int bucketCount, @NonNull String rootHash, @NonNull List<String> bucketHashes, @NonNull Map<String, Map<String,String>> entryHashesByMap) extends Record
Deterministic Merkle digest for WAN-replicated map state.

The tree stores per-entry hashes in deterministic map/key order so a source cluster can plan exact PUT/DELETE deltas after comparing bucket and entry hashes from a remote cluster. JCache distributed-mode caches participate through their qualified jcache.<cacheName> backing maps. Values are never stored in the tree.

  • Field Details

  • Constructor Details

    • WanMerkleTree

      public WanMerkleTree(int bucketCount, @NonNull String rootHash, @NonNull List<String> bucketHashes, @NonNull Map<String, Map<String,String>> entryHashesByMap)
      Creates an instance of a WanMerkleTree record class.
      Parameters:
      bucketCount - the value for the bucketCount record component
      rootHash - the value for the rootHash record component
      bucketHashes - the value for the bucketHashes record component
      entryHashesByMap - the value for the entryHashesByMap record component
  • Method Details

    • fromEntries

      public static @NonNull WanMerkleTree fromEntries(@NonNull Map<String, ? extends Map<String,String>> entriesByMap)
    • fromEntries

      public static @NonNull WanMerkleTree fromEntries(@NonNull Map<String, ? extends Map<String,String>> entriesByMap, int bucketCount)
    • diff

      public @NonNull WanMerkleTree.WanMerkleDiff diff(@NonNull WanMerkleTree remote)
    • serialize

      public byte @NonNull [] serialize()
    • deserialize

      public static @NonNull WanMerkleTree deserialize(byte @NonNull [] data)
    • isConsistentWith

      public boolean isConsistentWith(@NonNull WanMerkleTree remote)
    • entryCount

      public int entryCount()
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • bucketCount

      public int bucketCount()
      Returns the value of the bucketCount record component.
      Returns:
      the value of the bucketCount record component
    • rootHash

      public @NonNull String rootHash()
      Returns the value of the rootHash record component.
      Returns:
      the value of the rootHash record component
    • bucketHashes

      public @NonNull List<String> bucketHashes()
      Returns the value of the bucketHashes record component.
      Returns:
      the value of the bucketHashes record component
    • entryHashesByMap

      public @NonNull Map<String, Map<String,String>> entryHashesByMap()
      Returns the value of the entryHashesByMap record component.
      Returns:
      the value of the entryHashesByMap record component