Record Class MemberCapabilitiesPayload

java.lang.Object
java.lang.Record
io.axoniq.framework.springcloud.discovery.MemberCapabilitiesPayload
Record Components:
nodeId - the identifier of the member, unique to its process, or null when an answer does not carry one, which a member reading it treats as not being a member of the cluster
loadFactor - the relative share of command load the member asks for
commands - the names of the commands the member subscribed to, sorted
queries - the names of the queries the member subscribed to, sorted

public record MemberCapabilitiesPayload(@Nullable String nodeId, int loadFactor, List<String> commands, List<String> queries) extends Record
The wire representation of a member's MemberAdvertisement: its node id and its MemberCapabilities, as served by MemberCapabilitiesController and read by RestCapabilityDiscoveryMode.

This record exists separately from MemberCapabilities so that the JSON on the wire is fixed by a type of this module's own, rather than following the record shape of QualifiedName. Names travel as plain strings, which is both the obvious JSON and stable against changes to QualifiedName itself. Fields are ordered lists rather than sets purely so that the serialized bytes of unchanged capabilities are themselves unchanged, which is what makes the ETag on the endpoint meaningful.

The queries field may be absent from a member running a version that predates query distribution, so members reading it must tolerate an absent or empty list.

Since:
5.4.0
Author:
Allard Buijze
  • Constructor Details

    • MemberCapabilitiesPayload

      public MemberCapabilitiesPayload(@Nullable String nodeId, int loadFactor, List<String> commands, List<String> queries)
      Compact constructor defaulting null name lists to empty, so a payload from a member that omits a field altogether still reads.
      Parameters:
      nodeId - the identifier of the member, unique to its process, or null when an answer does not carry one
      loadFactor - the relative share of command load the member asks for
      commands - the names of the commands the member subscribed to, sorted
      queries - the names of the queries the member subscribed to, sorted
  • Method Details

    • from

      public static MemberCapabilitiesPayload from(String nodeId, MemberCapabilities capabilities)
      Converts the given nodeId and capabilities into their wire representation.
      Parameters:
      nodeId - the identifier of the member the capabilities belong to
      capabilities - the capabilities to represent on the wire
      Returns:
      the wire representation of the given nodeId and capabilities
    • toCapabilities

      public MemberCapabilities toCapabilities()
      Converts this wire representation back into MemberCapabilities.
      Returns:
      the capabilities this payload represents
    • entityTag

      public String entityTag()
      Returns an entity tag identifying the content of this payload, for use as the HTTP ETag of the capabilities endpoint and the If-None-Match sent by a member polling it.

      The tag is derived from the payload's own fields rather than from its serialized bytes, so it does not depend on how the surrounding web stack chooses to render the JSON. Because the name lists are sorted, the tag only changes when the capabilities do. The node id is part of the tag, so that an application restarted at the same address answers a member still holding the previous process's tag with its new node id, rather than with 304 Not Modified.

      Returns:
      an entity tag for this payload's content, without the surrounding quotes an ETag header needs
    • quotedEntityTag

      public String quotedEntityTag()
      Returns this payload's entityTag() wrapped in the quotes an ETag or If-None-Match header value requires.
      Returns:
      this payload's entity tag, ready to be used as a header value
    • 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.
    • nodeId

      public @Nullable String nodeId()
      Returns the value of the nodeId record component.
      Returns:
      the value of the nodeId record component
    • loadFactor

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

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

      public List<String> queries()
      Returns the value of the queries record component.
      Returns:
      the value of the queries record component