Enum Class RecordKind
- All Implemented Interfaces:
Serializable, Comparable<RecordKind>, Constable
Which record of
CoordinationCodec.TOPIC a key names.
The key carries the kind, so one topic holds both kinds and one compaction key covers both. The two kinds differ in what they claim. A registration announces that a member is available, and it carries no authority. A lease names the member that holds a role now, and its author held the epoch of the role when it wrote the record.
Example
CoordinationKey key = CoordinationCodec.decodeKey(record.key());
if (key.kind() == RecordKind.LEASE) {
System.out.println(key.role() + " changed hands");
}
-
Nested Class Summary
Nested classes/interfaces inherited from class Enum
Enum.EnumDesc<E> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionOne role names the member that holds it now.One member of a role announces that it is available. -
Method Summary
Modifier and TypeMethodDescriptionshortcode()Returns the wire code a writer puts in the key.static RecordKindfromCode(short code) Maps a wire code onto a record kind.static RecordKindReturns the enum constant of this class with the specified name.static RecordKind[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
REGISTRATION
One member of a role announces that it is available. -
LEASE
One role names the member that holds it now.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
code
public short code()Returns the wire code a writer puts in the key.- Returns:
0forREGISTRATIONand1forLEASE
-
fromCode
Maps a wire code onto a record kind.- Parameters:
code- the kind field read from a key- Returns:
- the matching record kind
- Throws:
CoordinationException- if no record kind carries the code
-