Record Class MemberCapabilities

java.lang.Object
java.lang.Record
io.axoniq.framework.springcloud.routing.MemberCapabilities
Record Components:
loadFactor - the relative share of command load this member asks for. A member with twice the load factor of another claims twice as many positions on the ConsistentHash ring, and so receives roughly twice as many commands. Must not be negative; a load factor of 0 keeps the member off the ring entirely.
commands - the names of the commands this member subscribed to
queries - the names of the queries this member subscribed to

public record MemberCapabilities(int loadFactor, Set<QualifiedName> commands, Set<QualifiedName> queries) extends Record
The messages a Member is able to handle, and the relative share of command load it asks for.

Capabilities are published by each member and collected by every other member when it joins and on every refresh after, so that the ConsistentHash ring can route a command only to members that actually subscribed to its name.

The loadFactor applies to commands only. Query subscriptions carry no load factor, as a query name is served by whichever member advertises it rather than being hashed onto a ring position.

Since:
5.4.0
Author:
Allard Buijze, Steven van Beelen
  • Field Details

    • INCAPABLE

      public static final MemberCapabilities INCAPABLE
      Capabilities of a member that handles nothing at all.

      Used both as the starting point for this application's own capabilities before any handler subscribed, and as the stand-in for a member whose capabilities could not be retrieved. In either case the member stays in the ring but is never selected, so a member that is briefly unreachable does not shift the routing of commands it would never have handled.

  • Constructor Details

    • MemberCapabilities

      public MemberCapabilities(int loadFactor, Set<QualifiedName> commands, Set<QualifiedName> queries)
      Compact constructor validating that the loadFactor is not negative and that neither name set is null, and defensively copying both sets.
      Parameters:
      loadFactor - the relative share of command load this member asks for
      commands - the names of the commands this member subscribed to
      queries - the names of the queries this member subscribed to
  • Method Details

    • handlesCommand

      public boolean handlesCommand(QualifiedName commandName)
      Indicates whether the member holding these capabilities subscribed to a command with the given commandName.
      Parameters:
      commandName - the QualifiedName of the command to check for
      Returns:
      true when this member handles commands of the given commandName, false otherwise
    • handlesQuery

      public boolean handlesQuery(QualifiedName queryName)
      Indicates whether the member handles queries by the given queryName.
      Parameters:
      queryName - the name of the query to check for
      Returns:
      true when the member handles queries by the given queryName, false otherwise
    • 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 '=='.
      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.
    • loadFactor

      public int loadFactor()
      Returns the value of the loadFactor record component.
      Returns:
      the value of the loadFactor record component
    • commands

      public Set<QualifiedName> commands()
      Returns the value of the commands record component.
      Returns:
      the value of the commands record component
    • queries

      public Set<QualifiedName> queries()
      Returns the value of the queries record component.
      Returns:
      the value of the queries record component