Uploaded image for project: 'Samza'
  1. Samza
  2. SAMZA-234

SystemConsumer should signal when it has consumed all available input

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      Extracting this out of SAMZA-179. As suggested by Jakob Homan in a comment, there should be a way for a SystemConsumer to indicate that it has caught up (i.e. there currently isn't any data left to consume).

      This will be useful for anything that needs to change behaviour depending on whether it is backlogged. For example, bootstrap streams (with systems.*.streams.*.samza.bootstrap=true) are prioritised over all other inputs until the stream has caught up. And SAMZA-179 is proposing support for batch-style reprocessing jobs, which need to know when they are done.

      This is currently done by comparing the offset on an IncomingMessageEnvelope to the newest offset reported by the SystemAdmin. That works for Kafka, but not for Databus (which doesn't currently have an API for getting the newest offset), and not for files (if the offset is the byte offset of the start of a record in the file, there can never be a record whose byte offset is equal to the length of the file, assuming every record is more than zero bytes long). This indicates that the logic for detecting how far behind a consumer is should be specific to the system, not an offset calculation in samza-core.

      One way for SystemConsumer to signal that it has caught up would be for SystemConsumer.poll to return an empty list of IncomingMessageEnvelopes. However, that may be dangerous, because there could be reasons for it to return an empty list even if it hasn't caught up. A better solution would therefore be to add a method like isCaughtUp() to the SystemConsumer interface.

      To discuss:

      • Should it report caught-up state for each partition individually, or for all partitions collectively?
      • Should backlog be reported as a boolean (caught up or not), or as a number (a kind of progress meter, cf. SAMZA-228)?

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                martinkl Martin Kleppmann
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated: