Record Class BarrierAlignment

java.lang.Object
java.lang.Record
io.krabka.streams.columnar.barrier.BarrierAlignment
Record Components:
group - the barrier group whose cuts the runner aligns on
reader - the reader the runner pulls cuts from
listener - the callback the runner calls when a barrier fires

public record BarrierAlignment(String group, BarrierCutReader reader, BarrierListener listener) extends Record
Tells a group runner which barrier group to align on.

Pass one to the ColumnarRunner.group overload that takes it. The runner then reads the group's cuts from __barrier_state, holds back every record at or above each partition's marker offset, and fires the barrier when every assigned partition reaches the cut. At that point it snapshots each owned partition under the cut's epoch, commits the cut offsets, and calls the listener.

Give the reader a consumer of its own. The runner's consumer is subscribed to the topology's source topics, and the reader replaces the assignment of the consumer it drives.

Example

var alignment = BarrierAlignment.on("transactions", new BarrierCutReader(cutConsumer))
    .withListener(cut -> System.out.println("epoch " + cut.epoch()));

try (var runner = ColumnarRunner.group(topology, consumer, producer,
        ColumnarErrorPolicy.fail(), new FileColumnarStateStore(directory),
        new ColumnarMetrics(), alignment)) {
    runner.runOnce(Duration.ofSeconds(1));
}
  • Constructor Details

    • BarrierAlignment

      public BarrierAlignment(String group, BarrierCutReader reader, BarrierListener listener)
      Rejects null components.
      Parameters:
      group - the barrier group whose cuts the runner aligns on
      reader - the reader the runner pulls cuts from
      listener - the callback the runner calls when a barrier fires
  • Method Details

    • on

      public static BarrierAlignment on(String group, BarrierCutReader reader)
      Creates an alignment with no listener.
      Parameters:
      group - the barrier group whose cuts the runner aligns on
      reader - the reader the runner pulls cuts from
      Returns:
      the alignment
    • withListener

      public BarrierAlignment withListener(BarrierListener newListener)
      Returns a copy of this alignment with another listener.
      Parameters:
      newListener - the callback the runner calls when a barrier fires
      Returns:
      the copy
    • toString

      public final String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • group

      public String group()
      Returns the value of the group record component.
      Returns:
      the value of the group record component
    • reader

      public BarrierCutReader reader()
      Returns the value of the reader record component.
      Returns:
      the value of the reader record component
    • listener

      public BarrierListener listener()
      Returns the value of the listener record component.
      Returns:
      the value of the listener record component