Record Class 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 theConsistentHashring, and so receives roughly twice as many commands. Must not be negative; a load factor of0keeps the member off the ring entirely.commands- thenamesof the commands this member subscribed toqueries- thenamesof the queries this member subscribed to
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 Summary
FieldsModifier and TypeFieldDescriptionstatic final MemberCapabilitiesCapabilities of a member that handles nothing at all. -
Constructor Summary
ConstructorsConstructorDescriptionMemberCapabilities(int loadFactor, Set<QualifiedName> commands, Set<QualifiedName> queries) Compact constructor validating that theloadFactoris not negative and that neither name set isnull, and defensively copying both sets. -
Method Summary
Modifier and TypeMethodDescriptioncommands()Returns the value of thecommandsrecord component.final booleanIndicates whether some other object is "equal to" this one.booleanhandlesCommand(QualifiedName commandName) Indicates whether the member holding these capabilities subscribed to a command with the givencommandName.booleanhandlesQuery(QualifiedName queryName) Indicates whether the member handles queries by the givenqueryName.final inthashCode()Returns a hash code value for this object.intReturns the value of theloadFactorrecord component.queries()Returns the value of thequeriesrecord component.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
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
Compact constructor validating that theloadFactoris not negative and that neither name set isnull, and defensively copying both sets.
-
-
Method Details
-
handlesCommand
Indicates whether the member holding these capabilities subscribed to a command with the givencommandName.- Parameters:
commandName- theQualifiedNameof the command to check for- Returns:
truewhen this member handles commands of the givencommandName,falseotherwise
-
handlesQuery
Indicates whether the member handles queries by the givenqueryName.- Parameters:
queryName- the name of the query to check for- Returns:
truewhen the member handles queries by the givenqueryName,falseotherwise
-
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 '=='. -
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
-