Class MemberId
java.lang.Object
io.krabka.streams.coordination.MemberId
- All Implemented Interfaces:
Comparable<MemberId>
The validated identity of one member that competes for a role.
A member picks its own id and keeps that id across a reconnect, so the succession order survives a short network failure. The id is the compaction key of the registration record of the member, so two members of one role need two ids.
of(String) is the only way to build a member id, so every
MemberId value is proof that the id is well formed. The factory rejects an
empty id and an id longer than MAX_LENGTH bytes.
Example
MemberId me = MemberId.of(InetAddress.getLocalHost().getHostName());
transport.register(Role.of("controller"), me);
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe maximum length of a member id, in bytes. -
Method Summary
-
Field Details
-
MAX_LENGTH
public static final int MAX_LENGTHThe maximum length of a member id, in bytes.- See Also:
-
-
Method Details
-
of
Parses a member id.- Parameters:
id- the member id, in UTF-8- Returns:
- the validated member id
- Throws:
CoordinationException- if the id is empty or holds more thanMAX_LENGTHbytesNullPointerException- if the id is null
-
id
-
compareTo
Orders two member ids by their text.- Specified by:
compareToin interfaceComparable<MemberId>- Parameters:
other- the member id to compare against- Returns:
- a negative number, zero, or a positive number as this id sorts before, with, or after the other id
-
equals
-
hashCode
-
toString
-