Enum Class RecordKind

java.lang.Object
java.lang.Enum<RecordKind>
io.krabka.streams.coordination.RecordKind
All Implemented Interfaces:
Serializable, Comparable<RecordKind>, Constable

public enum RecordKind extends Enum<RecordKind>
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");
}
  • Enum Constant Details

    • REGISTRATION

      public static final RecordKind REGISTRATION
      One member of a role announces that it is available.
    • LEASE

      public static final RecordKind LEASE
      One role names the member that holds it now.
  • Method Details

    • values

      public static RecordKind[] 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

      public static RecordKind valueOf(String name)
      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 name
      NullPointerException - if the argument is null
    • code

      public short code()
      Returns the wire code a writer puts in the key.
      Returns:
      0 for REGISTRATION and 1 for LEASE
    • fromCode

      public static RecordKind fromCode(short code)
      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