Interface TrackingStrategy

All Superinterfaces:
AutoCloseable, Closeable
All Known Implementing Classes:
DefaultTrackingStrategy

public interface TrackingStrategy extends Closeable
A TrackingStrategy defines how a Tracker consumes messages from a message log or distributed segment space.

This interface enables pluggable strategies for message consumption and parallelism. Depending on the configuration and type of tracker, a strategy may either:

  • Fetch and supply message batches directly from the message store (tailing a log), or
  • Negotiate segment claims and delegate message retrieval to the tracker itself (client-side tracking).

Tracking strategies are a key part of Fluxzero's support for distributed, fault-tolerant, and parallel message handling.

Responsibilities

A TrackingStrategy is responsible for:

Implementations should be thread-safe and able to handle dynamic tracker registration and segment rebalancing.

  • Method Details

    • getBatch

      Requests a new batch of messages for the given tracker.

      This method is typically invoked by the Tracker when it is ready to handle more messages. Depending on the strategy, this method may:

      • Fetch messages directly from a MessageStore and complete the result (e.g. for log tailing), or
      • Suspend the result until messages become available
      Parameters:
      tracker - the tracker requesting a batch
      Returns:
      future completed with the requested batch
    • claimSegment

      CompletableFuture<ClaimResult> claimSegment(Tracker tracker)
      Claims one or more message segments for the given tracker.

      This method is invoked when segment-based partitioning is enabled. It ensures that each segment is only claimed by a single tracker at a time and may release conflicting claims if necessary.

      Parameters:
      tracker - the tracker attempting to claim a segment
      Returns:
      future completed with the claimed segment and current position
    • disconnectTrackers

      Set<Tracker> disconnectTrackers(Predicate<Tracker> predicate, boolean sendFinalBatch)
      Disconnects trackers that match the provided filter.

      This is typically used during client shutdown, reconfiguration, or error handling to forcibly remove trackers from the strategy's internal registry.

      Parameters:
      predicate - filter for matching trackers to disconnect
      sendFinalBatch - if true, a final empty batch should be sent to each disconnected tracker to allow graceful termination
      Returns:
      the trackers that were disconnected (empty if no trackers matched the filter)
    • close

      void close()
      Closes the tracking strategy and releases any underlying resources.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable