Record Class MemberCapabilitiesPayload
- Record Components:
nodeId- the identifier of the member, unique to its process, ornullwhen an answer does not carry one, which a member reading it treats as not being a member of the clusterloadFactor- the relative share of command load the member asks forcommands- thenamesof the commands the member subscribed to, sortedqueries- thenamesof the queries the member subscribed to, sorted
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncommands()Returns the value of thecommandsrecord component.Returns an entity tag identifying the content of this payload, for use as the HTTPETagof the capabilities endpoint and theIf-None-Matchsent by a member polling it.final booleanIndicates whether some other object is "equal to" this one.static MemberCapabilitiesPayloadfrom(String nodeId, MemberCapabilities capabilities) Converts the givennodeIdandcapabilitiesinto their wire representation.final inthashCode()Returns a hash code value for this object.intReturns the value of theloadFactorrecord component.@Nullable StringnodeId()Returns the value of thenodeIdrecord component.queries()Returns the value of thequeriesrecord component.Returns this payload'sentityTag()wrapped in the quotes anETagorIf-None-Matchheader value requires.Converts this wire representation back intoMemberCapabilities.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
MemberCapabilitiesPayload
public MemberCapabilitiesPayload(@Nullable String nodeId, int loadFactor, List<String> commands, List<String> queries) Compact constructor defaultingnullname 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, ornullwhen an answer does not carry oneloadFactor- the relative share of command load the member asks forcommands- thenamesof the commands the member subscribed to, sortedqueries- thenamesof the queries the member subscribed to, sorted
-
-
Method Details
-
from
Converts the givennodeIdandcapabilitiesinto their wire representation.- Parameters:
nodeId- the identifier of the member the capabilities belong tocapabilities- the capabilities to represent on the wire- Returns:
- the wire representation of the given
nodeIdandcapabilities
-
toCapabilities
Converts this wire representation back intoMemberCapabilities.- Returns:
- the capabilities this payload represents
-
entityTag
Returns an entity tag identifying the content of this payload, for use as the HTTPETagof the capabilities endpoint and theIf-None-Matchsent 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
ETagheader needs
-
quotedEntityTag
Returns this payload'sentityTag()wrapped in the quotes anETagorIf-None-Matchheader value requires.- Returns:
- this payload's entity tag, ready to be used as a header value
-
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. -
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. -
equals
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 withObjects::equals(Object,Object); primitive components are compared with '=='. -
nodeId
Returns the value of thenodeIdrecord component.- Returns:
- the value of the
nodeIdrecord component
-
loadFactor
public int loadFactor()Returns the value of theloadFactorrecord component.- Returns:
- the value of the
loadFactorrecord component
-
commands
Returns the value of thecommandsrecord component.- Returns:
- the value of the
commandsrecord component
-
queries
Returns the value of thequeriesrecord component.- Returns:
- the value of the
queriesrecord component
-