Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents

Status

Current state: Under Discussion Accepted

Discussion thread: (pending) here

JIRA

Jira
serverASF JIRA
serverId5aa69414-a9e9-3523-82ec-879b028fb15b
keyKAFKA-7080

Draft PR: https://github.com/apache/kafka/pull/5257

Release: 2.1

Please keep the discussion on the mailing list rather than commenting on the wiki (wiki discussions get unwieldy fast).

...

Further, at this point, it seems that most applications will either want to accept the default segment interval (which is scaled to the retention period), or to select a specific size. In support of this, I propose to replace the "segments" nomenclature in Windows with "segmentInterval" as well. This has the beneficial side effect of correcting the accidental exposure of Windows.segments as a public mutable field.

Proposed Public Interface Change

...

No Format
/**
 * The number of segments the store has. If your store is segmented then this should be the number of segments
 * in the underlying store.
 * It is also used to reduce the amount of data that is scanned when caching is enabled.
 *
 * @return number of segments
 * @deprecated since 2.1. Use {@link WindowBytesStoreSupplier#segmentInterval()} instead.
 */
@Deprecated
int segments();

/**
 * The size of the segments (in milliseconds) the store has.
 * If your store is segmented then this should be the size of segments in the underlying store.
 * It is also used to reduce the amount of data that is scanned when caching is enabled.
 *
 * @return size of the segments (in milliseconds)
 */
long segmentInterval();


In Windows, we will:

  • make deprecate segments a private field (potentially breaking changeit was unintentionally made public before)
  • add a public segmentInterval() method
  • deprecate segments(int)
No Format
-+    @Deprecated public int segments;
+    private int segments = 3;

+    /**
+     * Return the segment interval in milliseconds.
+     *
+     * @return the segment interval
+     */
+    public long segmentInterval();

     /**
      * Set the number of segments to be used for rolling the window store.
      * This function is not exposed to users but can be called by developers that extend this class.
+     *
+     * Note: previously, this would bound the total number of segments in the store, but as of 2.1, it is used solely to determine the segment size. The actual number of segments is a function of how many future events are in flight.
      *
      * @param segments the number of segments to be used
      * @return itself
      * @throws IllegalArgumentException if specified segments is small than 2
+     * @deprecated since 2.1 Override segmentInterval() instead.
      */
+    @Deprecated
     protected Windows<W> segments(final int segments) throws IllegalArgumentException;

...