Uploaded image for project: 'Kafka'
  1. Kafka
  2. KAFKA-9876 Implement Raft Protocol for Metadata Quorum
  3. KAFKA-12158

Consider better return type of RaftClient.scheduleAppend

    XMLWordPrintableJSON

    Details

    • Type: Sub-task
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.0.0
    • Component/s: None
    • Labels:
      None

      Description

      Currently `RaftClient` has the following Append API:

          Long scheduleAppend(int epoch, List<T> records);
      

      There are a few possible cases that the single return value is trying to handle:

      1. The epoch doesn't match or we are not the current leader => return Long.MaxValue
      2. We failed to allocate memory to write the the batch (backpressure case) => return null
      3. We successfully scheduled the append => return the expected offset

      It might be better to define a richer type so that the cases that must be handled are clearer. At a minimum, it would be better to return `OptionalLong` and get rid of the null case.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                dengziming dengziming
                Reporter:
                hachikuji Jason Gustafson
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: