DUE TO SPAM, SIGN-UP IS DISABLED. Goto Selfserve wiki signup and request an account.
| Table of Contents |
|---|
Status
Current state: Under DiscussionAccepted
Discussion thread: here
JIRA: here
...
All non-assignment metadata as defined in the
ConsumerGroupHeartbeatRequestsuch as the group ID, member ID, member epoch, instance ID, rack ID and rebalance timeout.The currently assigned active, standby and warm-up tasks. Each task is identified by a subtopology ID (which can be an arbitrary string in protocol for future extensibility, even though subtopologies are currently numbered) and a partition number.
The process ID to identify multiple members running in the same process (i.e. the same Streams client).
The user-defined endpoint to be used for running interactive queries.
- Topology metadata needed for creating internal topics and computing the assignment.
The topology epoch, which A unique ID of the processing topology. The ID is defined by the client, and will be the hash 0 by default. The epoch can be bumped by the client to deploy a new version of the topology representation by default.
Topologymetadata
needed for creating internal topics and computing the assignment.
For each task, the current sum of task changelog offsets and task changelog end offsets. These are used to determine whether a warm-up task is below
acceptable.recovery.lagand can be used to optimize the assignment in the assignor. For more details on these offsets see "Cumulative task changelog offsets and task changelog end offsets" section belowA flag to request shutdown of the whole application (only if the member epoch is the group leave epoch).
Group ID, member ID, member epoch, and instance ID (if defined by the client) are sent with each heartbeat request. Any other information that has not changed since the last heartbeat can be omitted, unless an error occurred.
...
The set of source topics. Here, the source topics can be defined through a Google RE2/J regular expression.
The set of repartition sink topics. We do not include non-repartition sink topics or output topics that the topology produces in using dynamic routing.
The set of changelog topics, replication factors and other topic-level configurations.
The set of repartitions topics, the number of partitions for each of them (optional), replication factors and other topic-level configurations.
- The
...
- set of copartition groups, that is, the set of source topics (user source topics, or internal repartition source topics) that have to have the same number of partitions, e.g. because they are being used inside a join.
Note that the metadata of topology does not specify the number of input partitions a source topology has, and similarly also does not specify the number of partitions for changelog topics, and may omit the number of partitions for some repartition topics (if it can be inferred). By leaving the number of partitions parametric, the broker can allow changing the number of partitions for certain topologies, without reinitializing the group. In particular, stateless topologies without repartitioning steps, can support any number of input partitions without reinitializing the broker-side topology.
The metadata sent to the broker via the heartbeat is persisted as a new record type in the __consumer_offsets topic and is part of the group coordinator state in subsequent requests. If one or more source topics or internal topics do not exist, the group will enter state NOT_READY and will attempt to create any missing internal topics (see more details below). Only after the topology metadata is initialized and all source topics and internal topics exist, the group coordinator starts assigning tasks to the members of the group.
Topology updates
To avoid unintentional topology updates or rollbacks, updating the broker-side topology after it has been initialized for a group requires bumping the client-side configuration topology.epoch, which defaults to 0. By default, whenever a Streams member joins the group with a topology that is different from the current topology of the streams group, and the topology epoch is not bumped, the group coordinator will respond with an error, indicating that the member is incorrectly updating the broker-side topology.
Any member can update the topology by sending a topology with a bumped topology epoch when joining. The group coordinator then updates the broker-side topology with the topology metadata sent by the member. If the topology epoch of an existing member does not correspond to the current topology epoch of the group anymore (so the topology of the member is stale w.r.t. the group's topology), this will be indicated in the heartbeat response (status STALE_TOPOLOGY)sent to that member (for informational purposes, e.g., logging a warning).
The topology epoch of the group and the topology epoch of each member are provided to the assignor, which will make sure that members with a topology epoch that does not correspond to the group's topology epoch will not get any new tasks assigned, avoiding problems caused by topology incompatibilities.
| Info | ||
|---|---|---|
| ||
For example of a rolling bounce to upgrade the topology, |
If internal topics exist, but no consistent set of topics can be created without changing the number of partitions of the existing topics, an error is returned. The topic-level configurations are not validated and only used for initialization.
Topology updates
Topology updates can be initiated by any member upon joining. Whenever a Streams member joins the group (whether a new member, or a static member after a restart) with a topology ID that is different from the current topology of the streams group, the group coordinator re-initializes the broker-side topology with the topology metadata contained in the first heartbeat of the Streams member. If the topology ID of an existing member does not correspond to the current topology ID of the group, this will be indicated in the heartbeat response sent to that member (for informational purposes, e.g., logging a warning).
The topology ID of the group and the topology ID of each member are provided to the assignor, which will make sure that members with a topology ID that does not correspond to the group's topology ID will not get any new tasks assigned, avoiding problems caused by topology incompatibilities.
| Info | ||
|---|---|---|
| ||
For example of a rolling bounce to upgrade the topology, let’s assume a sticky assignor with stateless tasks and no standby tasks and one thread per process for illustration. Assume we have 3 clients A, B, and C with a uniform assignment (#1 #0 is the topology IDepoch):
We shut down C to update its topology. Once we shut down C, the assignment is the following:
Then, C rejoins the group with topology ID #2epoch #1. This topology ID does not correspond to epoch bumps the group's topology ID, so C will not get any tasks assigned. A and B get to keep their tasks.
The broker will ask C epoch, and C also includes the information to initialize the new topology . Once the topology is initialized, from in its first heartbeat. From now on, A and B will not get new tasks assigned, but C will get new tasks assigned because now #2 #1 is the group's topology IDepoch. The rest of the assignment is unchanged - just that A and B cannot get any new tasks, but they can retain some of the tasks they have. So since the sticky assignor balances out the assignment, we should end up with something like this:
B is shut down for the topology update. Since, again, A cannot get new tasks but C can, the new assignment is:
Client B comes back with the new topology IDepoch, and gets new tasks assigned:
And so on. |
It is up to the client implementation how topology IDs are defined. The protocol and the broker only requires that two clients with the same topology ID should have the same topology. In the initial implementation, the topology ID will be derived from the topology by deterministic hashing. However, it would also be possible to derive an implementation where topology IDs are explicitly defined through a configuration. This would, for example, allow the topologies to be manually versioned or topology IDs be derived from a git commit hash.
Adding a strict mode, where topology updates are requested explicitly, any implicit updates of the topology are rejected and members with incompatible topologies are fenced out of the group can be built on top of this protocol, but will be postponed to a follow-up KIP.
Describing and listing streams groups
Streams groups will be returned in ListGroupsResponse with GroupType equal to the string streams. The group ID of a streams group can be used in OffsetFetchRequest and OffsetCommitRequest as usual. Sending a ConsumerGroupHeartbeatRequest to a streams group will return an GROUP_ID_NOT_FOUND error. Sending a StreamsGroupHeartbeatRequest to a consumer group will similarly return an GROUP_ID_NOT_FOUND error.
There will be a new RPC DescribeStreamsGroup that returns, given the group ID, all metadata related to the streams group, such as
The topology metadata with which the topology was initialized provided by the first heartbeat with the new topology.
The latest member metadata that each member provided through the
StreamsGroupHeartbeatAPI.The current target assignment generated by the assignor.
We also include extensions of the Admin API and the command-line tools to describe and modify streams groups.
Rebalance Process
Similar as in KIP-848 consumer groups, the rebalance process is entirely driven by the group coordinator, and based on the same three epochs: group epoch, assignment epoch, and member epoch. The main difference is the assigned resource - instead of assigning partitions to consumers, we assign tasks consisting of a subtopology ID and a partition number, and each task can be assigned to a client in three roles: as an active task, as a standby task or as a warm-up task.
We only explain the main differences in the rebalance process in regular consumer groups here.
The partition metadata for the group, which is tracked by the group coordinator, is the partition metadata of all input topics (i.e., user source topics and internal repartition topics we read from).
The group epoch is bumped:
- When a member joins or leaves the group.
- When a member is fenced or removed from the group by the group coordinator.
- When the partition metadata is updated. For instance when a new partition is added or a new topic matching the subscribed topics is created.
- When a member with an assigned warm-up task reports a task changelog offset and task changelog end offset whose difference is less that
acceptable.recovery.lag. - When a member updates its topology metadata, rack ID, client tags or process ID. Note: Typically, these do not change within the lifetime of a Streams client, so this only happens when a member with static membership rejoins with an updated configuration.
- When an assignment configuration for the group is updated.
Assignment
Every time the group epoch is bumped, a new task assignment is computed by calling the task assignor, which consists of assigning tasks as active, standby or warm-up tasks to members of the group. The task assignor is configured on the broker side both through a global static configuration that defined the default assignor for all groups, and a dynamic group-level configuration that sets the assignor for a specific group.
The AK implementation will provide the following assignors
highly_available- Like the currentHighAvailabilityTaskAssignorsticky- Like the currentStickyTaskAssignor
Which assignors are provided by the group coordinator is not part of the protocol and is specific to each implementation. In this KIP, we do not introduce a pluggable interface for a task assignors, but we leave it open to do so in the future.
If no task assignor is configured globally or on the group-level, the broker picks the assignor. The broker is free to make a dynamic decision here - the AK implementation will choose highly_available for stateful topologies and sticky for stateless topologies.
Each task assignor must make sure to fulfill the following invariants:
Each warm-up task that has reached
acceptable.recovery.lagmust be turned into an active task or a standby task, or be unassigned from the member.A stateful task (in the various roles) cannot be assigned to two clients with the same
processId.
Cumulative task changelog offsets and task changelog end offsets
Whenever a stateful task is added or removed to/from a Streams client, or when warm-up task reaches acceptable.recovery.lag and in regular intervals, defined by a broker-side configuration task.offset.interval.ms, each client reports two sets of offsets, the sums of task changelog offsets and the sums of task changelog end offsets. These sets can be used by the assignors, in particular the highly_available assignor, to determine which tasks are caught-up to acceptable.recovery.lag and optimize the assignment when multiple clients with a partial copy of the state exist.
Cumulative task changelog offsets
The cumulative changelog offset of a task is the sum of all positions in the changelog topics of the local state stores belonging to the task. A Streams member reports the cumulative changelog offsets for all tasks with local state. That is:
For each processing (active) task, the sum of the offsets last fully replicated to the broker in the changelog topic of each local state. Under at-least-once guarantees, this is going to correspond to the high watermark, under exactly-once semantics, it’s going to be the last stable offset.
For each restoring (active, standby or warm-up), task the sum of the positions in the changelog topic and checkpointed to the local state directory.
For each dormant task (task which is not owned, but which has state locally on disk), the sum of the checkpointed positions in the changelog topic present in its state directory. The client only reports the offsets for dormant tasks that we manage to acquire the lock to the state directory for.
Members that run in the same process (and use the same state directory) may report offsets for overlapping sets of dormant tasks. These offsets can conflict (since they are recorded at different points in time), but these conflicts can easily be resolved by taking the most recently received offsets. The current assignors will be updated to take this into account.
Cumulative task changelog end offsets
Similarly, the member reports the sum of the end offsets in all changelog topics for the currently owned tasks, if available. This simplifies the broker-side task assignment, since the broker doesn’t need to fetch the current end-offsets. Specifically:
For active processing tasks, the cumulative task changelog end offset is the same as the cumulative task changelog offset
For all restoring tasks (active, standby or warm-up), the cumulative end-offset is the sum of the last end offsets cached by the restore consumer. If an end offset of a topic partition is unknown, no end-offset is reported.
For dormant standby tasks, no end-offset is reported.
Using cumulative task changelog offsets and cumulative task changelog end offsets
By reporting cumulative task changelog offsets and cumulative task changelog end offsets instead of the cumulative task lag, we can determine most task lags in the group coordinator, without the group coordinator or the streams client having to do additional requests. Even if the end offsets of the topic partition is not known to that member, as long as it is known to another member in the group. However, it may happen that no end offset is known in the group coordinator - for example, for tasks that are dormant on at least one client, and no member currently owns that task as active, standby or warm-up tasks. In these cases, the task with unknown end-offsets are never considered to be caught-up, however, the cumulative task changelog offset can still be used when deciding on where to place a new active, standby or warm-up task - typically, by selecting the client with the maximal cumulative task changelog offset that fulfils all other requirements.
Reconciliation of the group
Once a new target assignment is installed, each member will independently reconcile their current assignment with their new target assignment. Ultimately, each member will converge to their target epoch and assignment. The reconciliation process handles active tasks and standby/warm-up tasks differently:
Active tasks are reconciled like topic partitions in the KIP-848 consumer group protocol, that is, for reconciling the target assignment, the reconciliation follows three phases:
The group coordinator first asks the member to revoke any active tasks that are not assigned to that member in the target assignment any more, by removing those active tasks from the set of tasks sent to the member in the heartbeat response
The member must first confirm revocation of these active tasks by removing them from the set of active tasks sent in the heartbeat request
Now, active tasks will be incrementally assigned to the member. An active task is assigned as soon as no other client owns it anymore, that is, once the previous owner (if any) has confirmed the revocation of the corresponding active task.
Standby and warm-up tasks are reconciled in parallel with active tasks, but following slightly different logic:
As for active tasks, standby and warm-up tasks removed from the members target assignment are removed from the assignment sent in the heartbeat response immediately, that is, with the next heartbeat. The member confirms the revocation of the tasks as soon as the state directory (or any other resource related to the task) is closed.
Newly assigned standby and warm-up tasks await that any member with the same
processIdowning that task (as active or standby) confirms revocation of the task by removing it from the corresponding set in a heartbeat response. That is, a task that is not an active task or a standby task on any other member with the sameprocessIdcan be assigned immediately. Otherwise, it is assigned as soon as the blocking task is revoked. Target assignments that assign a task to two members with the sameprocessIdare invalid.
Streams Group States
The possible states of the streams group are EMPTY, ASSIGNING, RECONCILING , STABLE, DEAD as for consumer groups.
Global & Dynamic Group Configuration
We make core assignment options configurable centrally on the broker, without relying on each clients configuration. This allows tuning a streams group without redeploying the streams application. The three core assignment options will be introduced on the broker-side: acceptable.recovery.lag, num.warmup.replicas and num.standby.replicas. They can be configured both globally on the broker, and dynamically for specific streams groups through the IncrementalAlterConfigs and DescribeConfigs RPCs.
Online Migration from a Classic Consumer Group to a Streams Group
As in KIP-848, upgrading from a classic consumer group currently used in Kafka Streams to the new Streams group is possible by rolling the Streams clients assuming the Streams protocol is enabled on the brokers. When the first consumer of a Streams client using the new Streams rebalance protocol joins the group, the group is converted from a classic group to a streams group. When the last consumer of an Streams client using the new Streams rebalance protocol leaves the group, the group is converted back to a classic group. Note that the group epoch starts at the current group generation. During the migration, all the JoinGroup, SyncGroup and Heartbeat calls from the non-upgraded consumers are translated to the new Streams protocol.
Let's recapitulate how the classic rebalance protocol works in Streams. First, the consumers in a Streams client join or re-join the group with the JoinGroup API. The JoinGroup request contains the subscriped topics, the owned partitions, the generation ID, the Streams-specific subscription info, and some other fields. The Streams-specific subscription info contains the process ID of the Streams client, the owned active and standby tasks, the task offset sums, the user endpoints for Interactive Query and some more fields. When all the consumers of the Streams clients of the Streams application have joined, the group coordinator picks a leader for the group out of the consumers and sends back the JoinGroup response to all the members of the group (i.e. consumers that joined). The JoinGroup response contains the member ID, the generation ID, the member ID of the leader (to make the leader aware of leadership) as well as all the consumer and Streams-specific metadata about subscribed topics, owned partitions and tasks etc. The leader uses the data in the JoinGroup response for computing the assignment. Second, all the members in the Streams clients collect their assignment - computed by the leader - by using the SyncGroup API. The leader sends the computed assignment with the SyncGroup request to the group coordinator and the group coordinator distributes the assignment to the members through the SyncGroup response. In parallel, the members heartbeat with the Heartbeat API in order to maintain their session. The Heartbeat API is also used by the group coordinator to inform the members about an ongoing rebalance. All those interactions are synchronized on the generation of the group. It is important to note that the consumer does not make any assumption about the generation ID. It basically uses what it receives from the group coordinator. The classic rebalance protocol ussed in Streams supports two modes: Eager and Cooperative. In the eager mode, the consumer revokes all its partitions before rejoining the group during a rebalance. In the cooperative mode, the consumer does not revoke any partitions before rejoining the group. However, it revokes the partitions that it does not own anymore when it receives its new assignment and rejoins immediately if he had to revoke any partitions.
The Streams rebalance protocol relies on the StreamsGroupHeartbeat API to do all the above. Concretely, the API updates the group state, provides the active, standby, and warm-up tasks owned by the Streams client, gets back the assignment, and updates the session. We can remap those to the classic protocol as follow: the JoinGroup API updates the group state and provides the active and standby tasks owned (warm-ups are standby tasks in the classic protocol), the SyncGroup API gets back the task assignment, and the Heartbeat API updates the session. The main difference here is that the JoinGroup and SyncGroup does not run continuously. The group coordinator has to trigger it when it is need by returning the REBALANCE_IN_PROGRESS error in the heartbeat response.
The implementation of the new Streams protocol in the group coordinator will handle the JoinGroup and SyncGroup API of the classic protocol. The group coordinator will ensure that a rebalance is triggered when the assignment of a Streams client on the classic protocol needs to be updated by returning REBALANCE_IN_PROGRESS error in the heartbeat response.
When the first consumer of a Streams client that uses the new Streams rebalance protocol joins a classic group, the classic group in the group coordinator will be transformed to a streams group. The generation ID becomes the group epoch. The consumer of the Streams client initializes the group with the topology metadata. A rebalance is triggered by the group coordinator for all consumers still on the classic protocol by sending the REBALANCE_IN_PROGRESS error in the heartbeat. The consumers on the classic protocol send their owned active and standby tasks in the JoinGroup request to the group coordinator. The consumers on the Streams protocol send their owned active, standby, and warm-up tasks (i.e., should be empty since they just joined) through the StreamsGroupHeartbeat request to the group coordinator. In contrast to the classic protocol the group coordinator does not pick a leader for computing the assignment but computes the assignment itself. That is the target assignment. The group epoch is increased. From the target assignment the current member assignment are computed depending on the owned tasks. If members do not need to revoke any tasks, their member epoch is increased to the group epoch. If the members need to revoke a task, their member epoch stays the same. The group coordinator sends the new member epoch alongside the current member assignment through the StreamsGroupHeartbeat response to the members on the Streams protocol. The members still on the classic protocol receive the member epoch through the JoinGroup response but they still need to wait for the SyncGroup response for their current assignment. Basically, the group coordinator translates the JoinGroup and SyncGroup API to the Streams protocol internally and communicates to members still on the classic protocol via JoinGroup, SyncGroup as well as Heartbeat and with the members on the Streams protocol via the StreamsGroupHeartbeat.
A more detailed description of this process can be found in KIP-848 in Section Supporting Online Consumer Group Upgrade.
An example of a migration:
- classic group (generation=23)
- A
- B
- assignment
- A - active=[0_0, 0_2, 0_4], standby=[0_1, 0_3, 0_5]
- B - active=[0_1, 0_3, 0_5], standby=[0_0, 0_2, 0_4]
C joins using the Streams protocol. The classic group is transformed to a streams group.
- streams group (group epoch=24)
- A (classic)
- B (classic)
- C
- target assignment (epoch=24)
- A - active=[0_0, 0_2, 0_3], standby=[0_1, 0_5], warm-up=[]
- B - active=[0_1, 0_4, 0_5], standby=[0_2, 0_3], warm-up=[]
- C - active=[], standby=[0_0, 0_4], warm-up=[0_2, 0_5]
- member assignment
- A
- Receives REBALANCE_IN_PROGRESS error in heartbeat response
- JoinGroupRequest: active=[0_0, 0_2, 0_4], standby=[0_1, 0_3, 0_5]
- JoinGroupResponse: generation ID=24
- SyncGroupResponse: active=[0_0, 0_2, 0_3], standby=[0_1, 0_5]
- B
- Receives REBALANCE_IN_PROGRESS error in heartbeat response
- JoinGroupRequest: active=[0_1, 0_3, 0_5], standby=[0_0, 0_2, 0_4]
- JoinGroupResponse: generation ID=24
- SyncGroupResponse: active=[0_1, 0_4, 0_5], standby=[0_2, 0_3]
- C
- StreamsGroupHeartbeat: epoch=24, active=[], standby=[0_0, 0_4], warm-up=[0_2, 0_5]
- A
C's warm-up task 0_2 is caught up. A is requested to revoke active task 0_2, thus A does not increase its generation ID.
broker will reject members that attempt to join with a stale topology epoch, or with the current topology epoch but different topology metadata.
Handling topic topology mismatches
It can happen that the group is initialized to a topology, but source / sink or internal topics required by the topology do not exist or differ in their configuration from what is required for the topology to successfully execute. This is typically detected during the handling of the streams group heartbeat in the group coordinator, where we detect changes in either the topology or the topic metadata on the broker, triggering "topology configuration" process, in which the group coordinator performs the following steps:
- Check that all source topics exists, resolve source topic regular expressions and check that each of them resolve to at least one topic.
- Check that "copartition groups" are satisfied, that is, all source topics that are supposed to be copartitioned are indeed copartitioned.
- Derive the required number of partitions for all internal topics from the source topic configuration.
- Check that all internal topics exist with the right configuration.
If any source topics or internal topics are missing, the group enters a state NOT_READY. In NOT_READY, all heartbeats will be handled as usual (so they typically should not fail), but in the heartbeat response, the status will indicate which kind of problem exists - all members will get an empty assignment when the group is in NOT_READY state. Below, we describe the behavior of the protocol when any mismatch is detected during topic/topology configuration. The behaviors are ordered by precedence, for example, if source topics and internal topics are missing, then the groups takes on the behavior for missing source topics, not the behavior for missing internal topics.
- Source topics missing
Condition: A source topic is missing or a source topic regex resolves to zero topics.
Behavior: The group will enter/remain in stateNOT_READY. Heartbeat responses will indicate statusMISSING_SOURCE_TOPICS. In the status detail, we specify all missing source topics and all regular expressions matching zero topics. - Topics incorrectly partitioned
Condition: Some topics are incorrectly partitioned, if two topics are supposed to be copartitioned according to the topology, but in the current topic metadata on the broker, the number of partitions for the two topics is different, or the number of partitions in a changelog topic does not correspond to the maximal number of source topic partition for that subtopology.
Behavior: The group will enter/remain in stateNOT_READY. Heartbeat responses will indicate statusINCORRECTLY_PARTITIONED_TOPICS. In the status detail, we specify at least one incorrectly partitioned topic. - Internal topics are missing
Condition: One or more internal topics are missing.
Behavior: If discovered during a heartbeat, the group coordinator will attempt to create the internal topics by sending a corresponding topic create request will be sent to the Kraft coordinator. There can only be one such request in-flight at a time, an appropriate back-off mechanism will be used to prevent too many attempts to create the topics. If the appropriate ACL for topic creation are not assigned to the principle executing the heartbeat, no such attempt will be made. The group will enter/remain in stateNOT_READY. Heartbeat responses will indicate statusMISSING_INTERNAL_TOPICS. In the status detail, we specify whether an attempt to create the topics was made, whether and why a previous attempt failed, whether sufficient ACLs to create the topics are available. - Topic configuration mismatches
If an internal topic exists, but does not have the same configuration as defined in the topology (all parameters of the topic beside number of partitions, that is, replication factor, retention time, etc.), this will be logged on the broker, but otherwise be ignored.
Describing and listing streams groups
Streams groups will be returned in ListGroupsResponse with GroupType equal to the string streams. The group ID of a streams group can be used in OffsetFetchRequest and OffsetCommitRequest as usual. Sending a ConsumerGroupHeartbeatRequest to a streams group will return an GROUP_ID_NOT_FOUND error. Sending a StreamsGroupHeartbeatRequest to a consumer group will similarly return an GROUP_ID_NOT_FOUND error.
There will be a new RPC DescribeStreamsGroup that returns, given the group ID, all metadata related to the streams group, such as
The topology metadata of the group. This topology metadata is the result of the above "topology configuration" process, so it contains the topology metadata as initialized by one of the streams group members, but with a concrete number of partitions for each topic, and with source topic regular expressions resolved to a specific set of topics.
- The topology epoch of the group.
The latest member metadata that each member provided through the
StreamsGroupHeartbeatAPI.The current target assignment generated by the assignor.
We also include extensions of the Admin API and the command-line tools to describe and modify streams groups.
Rebalance Process
Similar as in KIP-848 consumer groups, the rebalance process is entirely driven by the group coordinator, and based on the same three epochs: group epoch, assignment epoch, and member epoch. The main difference is the assigned resource - instead of assigning partitions to consumers, we assign tasks consisting of a subtopology ID and a partition number, and each task can be assigned to a client in three roles: as an active task, as a standby task or as a warm-up task.
We only explain the main differences in the rebalance process in regular consumer groups here.
The partition metadata for the group, which is tracked by the group coordinator, is the partition metadata of all input topics (i.e., user source topics and internal repartition topics we read from).
The group epoch is bumped:
- When a member joins or leaves the group.
- When a member is fenced or removed from the group by the group coordinator.
- When the partition metadata is updated. For instance when a new partition is added or a new topic matching the subscribed topics is created.
- When a member with an assigned warm-up task reports a task changelog offset and task changelog end offset whose difference is less than
acceptable.recovery.lag. - When a member updates its topology metadata, rack ID, client tags or process ID. Note: Typically, these do not change within the lifetime of a Streams client, so this only happens when a member with static membership rejoins with an updated configuration.
- When an assignment configuration for the group is updated.
Assignment
Every time the group epoch is bumped, a new task assignment is computed by calling the task assignor, which consists of assigning tasks as active, standby or warm-up tasks to members of the group. The task assignor is configured on the broker side both through a global static configuration that defined the default assignor for all groups, and a dynamic group-level configuration that sets the assignor for a specific group.
The AK implementation will provide the following assignors
highly_available- Similar to the currentHighAvailabilityTaskAssignorsticky- similar to the currentStickyTaskAssignor
Which assignors are provided by the group coordinator is not part of the protocol and is specific to each implementation. In this KIP, we do not introduce a pluggable interface for a task assignors, but we leave it open to do so in the future.
If no task assignor is configured globally or on the group-level, the broker picks the assignor. The broker is free to make a dynamic decision here - the AK implementation will choose highly_available for stateful topologies and sticky for stateless topologies.
Each task assignor must make sure to fulfill the following invariants:
Each warm-up task that has reached
acceptable.recovery.lagmust be turned into an active task or a standby task, or be unassigned from the member.A stateful task (in the various roles) cannot be assigned to two clients with the same
processId.
Cumulative task changelog offsets and task changelog end offsets
Whenever a stateful task is added or removed to/from a Streams client, or when warm-up task reaches acceptable.recovery.lag and in regular intervals, defined by a broker-side configuration task.offset.interval.ms, each client reports two sets of offsets, the sums of task changelog offsets and the sums of task changelog end offsets. These sets can be used by the assignors, in particular the highly_available assignor, to determine which tasks are caught-up to acceptable.recovery.lag and optimize the assignment when multiple clients with a partial copy of the state exist.
Cumulative task changelog offsets
The cumulative changelog offset of a task is the sum of all positions in the changelog topics of the local state stores belonging to the task. A Streams member reports the cumulative changelog offsets for all tasks with local state. That is:
For each processing (active) task, the sum of the offsets last fully replicated to the broker in the changelog topic of each local state. Under at-least-once guarantees, this is going to correspond to the high watermark, under exactly-once semantics, it’s going to be the last stable offset.
For each restoring (active, standby or warm-up), task the sum of the positions in the changelog topic and checkpointed to the local state directory.
For each dormant task (task which is not owned, but which has state locally on disk), the sum of the checkpointed positions in the changelog topic present in its state directory. The client only reports the offsets for dormant tasks that we manage to acquire the lock to the state directory for.
Members that run in the same process (and use the same state directory) may report offsets for overlapping sets of dormant tasks. These offsets can conflict (since they are recorded at different points in time), but these conflicts can easily be resolved by taking the most recently received offsets. The current assignors will be updated to take this into account.
Cumulative task changelog end offsets
Similarly, the member reports the sum of the end offsets in all changelog topics for the currently owned tasks, if available. This simplifies the broker-side task assignment, since the broker doesn’t need to fetch the current end-offsets. Specifically:
For active processing tasks, the cumulative task changelog end offset is the same as the cumulative task changelog offset
For all restoring tasks (active, standby or warm-up), the cumulative end-offset is the sum of the last end offsets cached by the restore consumer. If an end offset of a topic partition is unknown, no end-offset is reported.
For dormant tasks, no end-offset is reported.
Using cumulative task changelog offsets and cumulative task changelog end offsets
By reporting cumulative task changelog offsets and cumulative task changelog end offsets instead of the cumulative task lag, we can determine most task lags in the group coordinator, without the group coordinator or the streams client having to do additional requests. Even if the end offsets of the topic partition is not known to that member, as long as it is known to another member in the group. However, it may happen that no end offset is known in the group coordinator - for example, for tasks that are dormant on at least one client, and no member currently owns that task as active, standby or warm-up tasks. In these cases, the task with unknown end-offsets are never considered to be caught-up, however, the cumulative task changelog offset can still be used when deciding on where to place a new active, standby or warm-up task - typically, by selecting the client with the maximal cumulative task changelog offset that fulfils all other requirements.
Reconciliation of the group
Once a new target assignment is installed, each member will independently reconcile their current assignment with their new target assignment. Ultimately, each member will converge to their target epoch and assignment. The reconciliation process handles active tasks and standby/warm-up tasks differently:
Active tasks are reconciled like topic partitions in the KIP-848 consumer group protocol, that is, for reconciling the target assignment, the reconciliation follows three phases:
The group coordinator first asks the member to revoke any active tasks that are not assigned to that member in the target assignment any more (if either no warmup tasks are used at all, or if the target member has a hot standby/warmup task), by removing those active tasks from the set of tasks sent to the member in the heartbeat response
The member must first confirm revocation of these active tasks by removing them from the set of active tasks sent in the heartbeat request
Now, active tasks will be incrementally assigned to the member. An active task is assigned as soon as no other client owns it anymore, that is, once the previous owner (if any) has confirmed the revocation of the corresponding active task.
Standby and warm-up tasks are reconciled in parallel with active tasks, but following slightly different logic:
As for active tasks, standby and warm-up tasks removed from the members target assignment are removed from the assignment sent in the heartbeat response immediately, that is, with the next heartbeat. The member confirms the revocation of the tasks as soon as the state directory (or any other resource related to the task) is closed.
Newly assigned standby and warm-up tasks await that any member with the same
processIdowning that task (as active or standby) confirms revocation of the task by removing it from the corresponding set in a heartbeat response. That is, a task that is not an active task or a standby task on any other member with the sameprocessIdcan be assigned immediately. Otherwise, it is assigned as soon as the blocking task is revoked. Target assignments that assign a task to two members with the sameprocessIdare invalid.
Streams Group States
The possible states of the streams group are EMPTY, ASSIGNING, RECONCILING , STABLE, NOT_READY, DEAD. The states are similar as consumer groups, but contain an extra stat NOT_READY, which is used when a group is not empty and has a topology set, but not all topics are present to start processing using the topology.
Global & Dynamic Group Configuration
We make core assignment options configurable centrally on the broker, without relying on each clients configuration. This allows tuning a streams group without redeploying the streams application. The three core assignment options will be introduced on the broker-side: acceptable.recovery.lag, num.warmup.replicas, num.standby.replicas, and rack.aware.assignment.tags. They can be configured both globally on the broker, and dynamically for specific streams groups through the IncrementalAlterConfigs and DescribeConfigs RPCs.
We store the last used assignment configuration in the group metadata on the broker. This way, we can detect if an assignment configuration is dynamically changed, and we can trigger reassignment immediately.
Online Migration from a Classic Consumer Group to a Streams Group
As in KIP-848, upgrading from a classic consumer group currently used in Kafka Streams to the new streams group is possible by rolling the Streams clients, assuming the Streams protocol is enabled on the brokers. When the first consumer of a Streams client using the new Streams rebalance protocol joins the group, the group is converted from a classic group to a streams group. When the last consumer of an Streams client using the new Streams rebalance protocol leaves the group, the group is converted back to a classic group. Note that the group epoch starts at the current group generation. During the migration, all the JoinGroup, SyncGroup and Heartbeat calls from the non-upgraded consumers are translated to the new Streams protocol.
Let's recapitulate how the classic rebalance protocol works in Streams. First, the consumers in a Streams client join or re-join the group with the JoinGroup API. The JoinGroup request contains the subscribed topics, the owned partitions, the generation ID, the Streams-specific subscription info, and some other fields. The Streams-specific subscription info contains the process ID of the Streams client, the owned active and standby tasks, the task offset sums, the user endpoints for Interactive Query, and some more fields. When all the consumers of the Streams clients of the Streams application have joined, the group coordinator picks a leader for the group out of the consumers and sends back the JoinGroup response to all the members of the group (i.e., consumers that joined). The JoinGroup response contains the member ID, the generation ID, and the member ID of the leader (to make the leader aware of leadership) as well as all the consumer and Streams-specific metadata about subscribed topics, owned partitions, tasks, etc. The leader uses the data in the JoinGroup response for computing the assignment. Second, all the members in the Streams clients collect their assignment—computed by the leader—by using the SyncGroup API. The leader sends the computed assignment with the SyncGroup request to the group coordinator, and the group coordinator distributes the assignment to the members through the SyncGroup response. In parallel, the members heartbeat with the Heartbeat API in order to maintain their session. The Heartbeat API is also used by the group coordinator to inform the members about an ongoing rebalance. All those interactions are synchronized on the generation of the group. It is important to note that the consumer does not make any assumption about the generation ID. It basically uses what it receives from the group coordinator. The classic rebalance protocol used in Streams supports two modes: Eager and Cooperative. In the eager mode, the consumer revokes all its partitions before rejoining the group during a rebalance. In the cooperative mode, the consumer does not revoke any partitions before rejoining the group. However, it revokes the partitions that it does not own anymore when it receives its new assignment and rejoins immediately if it had to revoke any partitions.
The Streams rebalance protocol relies on the StreamsGroupHeartbeat API to do all the above. Concretely, the API updates the group state, provides the active, standby, and warm-up tasks owned by the Streams client, gets back the assignment, and updates the session. We can remap those to the classic protocol as follows: The JoinGroup API updates the group state and provides the active and standby tasks owned (warm-ups are standby tasks in the classic protocol), the SyncGroup API gets back the task assignment, and the Heartbeat API updates the session. The main difference here is that the JoinGroup and SyncGroup do not run continuously. The group coordinator has to trigger it when it is needed by returning the REBALANCE_IN_PROGRESS error in the heartbeat response.
The implementation of the new Streams protocol in the group coordinator will handle the JoinGroup and SyncGroup APIs of the classic protocol. The group coordinator will ensure that a rebalance is triggered when the assignment of a Streams client on the classic protocol needs to be updated by returning a REBALANCE_IN_PROGRESS error in the heartbeat response.
When the first consumer of a Streams client that uses the new Streams rebalance protocol joins a classic group, the classic group in the group coordinator will be transformed to a streams group. The generation ID becomes the group epoch. The consumer of the Streams client initializes the group with the topology metadata. A rebalance is triggered by the group coordinator for all consumers still on the classic protocol by sending the REBALANCE_IN_PROGRESS error in the heartbeat. The consumers on the classic protocol send their owned active and standby tasks in the JoinGroup request to the group coordinator. The consumers on the Streams protocol send their owned active, standby, and warm-up tasks (i.e., should be empty since they just joined) through the StreamsGroupHeartbeat request to the group coordinator. In contrast to the classic protocol, the group coordinator does not pick a leader for computing the assignment but computes the assignment itself. That is the target assignment. The group epoch is increased. From the target assignment, the current member assignment is computed depending on the owned tasks. If members do not need to revoke any tasks, their member epoch is increased to the group epoch. If the members need to revoke a task, their member epoch stays the same. The group coordinator sends the new member epoch alongside the current member assignment through the StreamsGroupHeartbeat response to the members on the Streams protocol. The members still on the classic protocol receive the member epoch through the JoinGroup response, but they still need to wait for the SyncGroup response for their current assignment. Basically, the group coordinator translates the JoinGroup and SyncGroup API to the Streams protocol internally and communicates to members still on the classic protocol via JoinGroup, SyncGroup as well as Heartbeat and with the members on the Streams protocol via the StreamsGroupHeartbeat.
The Streams protocol also assigns warm-up tasks. However, the classic protocol does not have any notion of a warm-up task. If the group coordinator assigns a warm-up task to a Streams client on the classic protocol, that warm-up task is translated to a standby task in the assignment for the Streams client on the classic protocol. The group coordinator chooses one of the Streams clients on the classic protocol to trigger a probing rebalance.
A more detailed description of this process can be found in KIP-848 in Section Supporting Online Consumer Group Upgrade.
Example
- classic group (generation=23)
- A
- B
- assignment
- A -
- streams group (group epoch=25)
- A (classic)
- B (classic)
- C
- target assignment (epoch=25)
- A - active=[0_0, 0_3], standby=[0_1, 0_5], warm-up=[]
- B - active=[0_1, 0_4, 0_5], standby=[0_2, 0_3], warm-up=[]
- C - active=[0_2], standby=[0_0, 0_4], warm-up=[0_5]
- member assignment
- A
- Receives REBALANCE_IN_PROGRESS error in heartbeat response JoinGroupRequest: active=[0_0, 0_2, 0_34], standby=[0_1, 0_5], warm-up=[]
- JoinGroupResponse: generation ID=24 SyncGroupResponse: active=[0_0, 0_3], standby=[ 0_1, 0_5]
- B
- Receives REBALANCE_IN_PROGRESS error in heartbeat response JoinGroupRequest: - active=[0_1, 0_43, 0_5], standby=[0_20, 0_3]
- JoinGroupResponse: generation ID=25 SyncGroupResponse: active=[0_12, 0_4, 0_5], standby=[0_2, 0_3]
- C
- StreamsGroupHeartbeat: epoch=25, active=[], standby=[0_0, 0_4], warm-up=[0_5]
- ]
C joins using the Streams protocol. The classic group is transformed to a streams groupA follow-up rebalance is triggered so that A can report the revoked active task 0_2. Since A does not need to revoke tasks anymore the generation ID is increased.
- streams group (group epoch=
...
- 24)
- A (classic)
- B (classic)
- C (streams)
- target assignment (epoch=
...
- 24)
- A - active=[0_0, 0_2, 0_3], standby=[0_1, 0_5], warm-up=[]
- B - active=[0_1, 0_4, 0_5], standby=[0_2, 0_3], warm-up=[]
- C - active=[
...
- ], standby=[0_0, 0_4], warm-up=[0_2, 0_5]
- member assignment
- A
- Receives REBALANCE_IN_PROGRESS error in heartbeat response
- JoinGroupRequest: active=[0_0, 0_
- A
...
- 2, 0_4], standby=[0_1, 0_3, 0_5
...
- ]
- JoinGroupResponse: generation ID=
...
- 24
- SyncGroupResponse: active=[0_0, 0_2, 0_3], standby=[0_1, 0_5]
- B
- Receives REBALANCE_IN_PROGRESS error in heartbeat response
- JoinGroupRequest: active=[0_1, 0_
...
- 3, 0_5], standby=[0_0, 0_2, 0_
...
- 4]
- JoinGroupResponse: generation ID=
...
- 24
- SyncGroupResponse: active=[0_1, 0_4, 0_5], standby=[0_2, 0_3]
- C
- StreamsGroupHeartbeat: epoch=
...
- 24, active=[
...
- ], standby=[0_0, 0_4], warm-up=[0_2, 0_5]
If C leaves the group now, the group coordinator transforms back the group to a classic group and only use JoinGroup, SyncGroup, and Heartbeat to communicate with the members. The records of the Streams protocol are deleted from the __consumer_offsets topic.
Public Interfaces
This section lists the changes impacting the public interfaces.
KRPC
New Errors
The conditions in which these errors are returned are stated further down.
STREAMS_INVALID_TOPOLOGY- The supplied topology is invalid. Returned if the client sends a topology that does not fulfill the expected invariants, see below in the sections "Request Validation".STREAMS_MISSING_SOURCE_TOPICS- There are source topics missing for a topology that is supposed to be initialized. Also returned if the source topic regular expression matched no topics.STREAMS_INCONSISTENT_INTERNAL_TOPICS- There are internal topics present on the broker that are not consistent with the internal topic requirements of the provided topology.
StreamsGroupHeartbeat
The StreamsGroupHeartbeat API is the new core API used by streams application to form a group. The API allows members to initialize a topology, advertise their state, and their owned tasks. The group coordinator uses it to assign/revoke tasks to/from members. This API is also used as a liveness check.
Request Schema
The member must set all the (top level) fields with the exception of RackId and InstanceId when it joins for the first time or when an error occurs (e.g. request timed out). Otherwise, it is expected to only fill in the fields which have changed since the last heartbeat.
C's warm-up task 0_2 is caught up. A is requested to revoke active task 0_2, thus A does not increase its generation ID.
- streams group (group epoch=25)
- A (classic)
- B (classic)
- C (streams)
- target assignment (epoch=25)
- A - active=[0_0, 0_3], standby=[0_1, 0_5], warm-up=[]
- B - active=[0_1, 0_4, 0_5], standby=[0_2, 0_3], warm-up=[]
- C - active=[0_2], standby=[0_0, 0_4], warm-up=[0_5]
- member assignment
- A
- Receives REBALANCE_IN_PROGRESS error in heartbeat response
- JoinGroupRequest: active=[0_0, 0_2, 0_3], standby=[0_1, 0_5], warm-up=[]
- JoinGroupResponse: generation ID=24
- SyncGroupResponse: active=[0_0, 0_3], standby=[0_1, 0_5]
- B
- Receives REBALANCE_IN_PROGRESS error in heartbeat response
- JoinGroupRequest: active=[0_1, 0_4, 0_5], standby=[0_2, 0_3]
- JoinGroupResponse: generation ID=25
- SyncGroupResponse: active=[0_1, 0_4, 0_5], standby=[0_2, 0_3]
- C
- StreamsGroupHeartbeat: epoch=25, active=[], standby=[0_0, 0_4], warm-up=[0_5]
- A
A follow-up rebalance is triggered so that A can report the revoked active task 0_2. Since A does not need to revoke tasks anymore the generation ID is increased.
- streams group (group epoch=25)
- A (classic)
- B (classic)
- C (streams)
- target assignment (epoch=25)
- A - active=[0_0, 0_3], standby=[0_1, 0_5], warm-up=[]
- B - active=[0_1, 0_4, 0_5], standby=[0_2, 0_3], warm-up=[]
- C - active=[0_2], standby=[0_0, 0_4], warm-up=[0_5]
- member assignment
- A
- Receives REBALANCE_IN_PROGRESS error in heartbeat response
- JoinGroupRequest: active=[0_0, 0_3], standby=[0_1, 0_5], warm-up=[]
- JoinGroupResponse: generation ID=25
- SyncGroupResponse: active=[0_0, 0_3], standby=[0_1, 0_5]
- B
- Receives REBALANCE_IN_PROGRESS error in heartbeat response
- JoinGroupRequest: active=[0_1, 0_4, 0_5], standby=[0_2, 0_3]
- JoinGroupResponse: generation ID=25
- SyncGroupResponse: active=[0_1, 0_4, 0_5], standby=[0_2, 0_3]
- C
- StreamsGroupHeartbeat: epoch=25, active=[0_2], standby=[0_0, 0_4], warm-up=[0_5]
- A
If C leaves the group now, the group coordinator transforms back the group to a classic group and only use JoinGroup, SyncGroup, and Heartbeat to communicate with the members. The records of the Streams protocol are deleted from the __consumer_offsets topic.
Public Interfaces
This section lists the changes impacting the public interfaces.
KRPC
New Errors
The conditions in which these errors are returned are stated further down.
STREAMS_INVALID_TOPOLOGY- The supplied topology is invalid. Returned if the client sends a topology that does not fulfill the expected invariants, see below in the sections "Request Validation".STREAMS_INVALID_TOPOLOGY_EPOCH- The client provided a invalid topology epoch with respect to the stream group state, for example, the topology was changed by the epoch not bumped.STREAMS_TOPOLOGY_FENCED- When a client attempts to join with an outdated topology epoch.
StreamsGroupHeartbeat
The StreamsGroupHeartbeat API is the new core API used by streams application to form a group. The API allows members to initialize a topology, advertise their state, and their owned tasks. The group coordinator uses it to assign/revoke tasks to/from members. This API is also used as a liveness check.
Request Schema
The member must set all the (top level) fields with the exception of RackId and InstanceId when it joins for the first time or when an error occurs (e.g. request timed out). Otherwise, it is expected to only fill in the fields which have changed since the last heartbeat.
| Note |
|---|
Update for Apache Kafka 4.4 release. In Apache Kafka 4.2 release, there is a bug in the implementation of the |
| Code Block | ||||
|---|---|---|---|---|
| ||||
{
"apiKey": TBD,
"type": "request",
"listeners": ["broker"],
"name": "StreamsGroupHeartbeatRequest",
"validVersions": "0", // "0" in 4.2/4.3 release; bumped to "0-1" in 4.4 release
"flexibleVersions": "0+",
"fields": [
| ||||
| Code Block | ||||
| ||||
{ "apiKey": TBD, "type": "request", "listeners": ["broker"], "name": "StreamsGroupHeartbeatRequest", "validVersions": "0", "flexibleVersions": "0+", "fields": [ { "name": "GroupId", "type": "string", "versions": "0+", "entityType": "groupId", "about": "The group identifier." }, { "name": "MemberId", "type": "string", "versions": "0+", "about": "The member ID generated by the coordinator. The member ID must be kept during the entire lifetime of the member." }, { "name": "MemberEpoch", "type": "int32", "versions": "0+", "about": "The current member epoch; 0 to join the group; -1 to leave the group; -2 to indicate that the static member will rejoin." }, { "name": "InstanceId", "type": "string", "versions": "0+", "nullableVersions": "0+", "default": "null", "about": "null if not provided or if it didn't change since the last heartbeat; the instance ID for static membership otherwise." }, { "name": "RackId", "type": "string", "versions": "0+", "nullableVersions": "0+", "default": "null", "about": "null if not provided or if it didn't change since the last heartbeat; the rack ID of consumer otherwise." }, { "name": "RebalanceTimeoutMs", "type": "int32", "versions": "0+", "default": -1, "about": "-1 if it didn't change since the last heartbeat; the maximum time in milliseconds that the coordinator will wait on the member to revoke its partitions otherwise." }, { "name": "Topology", "type": "Topology", "versions": "0+", "nullableVersions": "0+", "default": null, "about": "The topology data of the streams application. Used to initialize the topology of the group and to check if the topology corresponds to the topology initialized for the group. Only sent when memberEpoch = 0, must be non-empty. Null otherwise.", "fields": [ { "name": "TopologyId", "type": "string", "versions": "0+", "about": "The ID of the topology. Used to check if the topology corresponds to the topology initialized on the brokers." }, { "name": "Subtopologies", "type": "[]Subtopology", "versions": "0+", "about": "The sub-topologies of the streams application.", "fields": [ { "name": "SubtopologyId", "type": "string", "versions": "0+", "about": "String to uniquely identify the sub-topology. Deterministically generated from the topology" }, { "name": "SourceTopics", "type": "[]string", "versions": "0+", "about": "The topics the topology reads from." }, { "name": "SourceTopicRegex", "type": "string", "versions": "0+", "nullableVersions": "0+", "default": "null", "about": "The regular expressions identifying topics the sub-topology reads from. null if not provided." }, { "name": "StateChangelogTopics", "type": "[]TopicInfo", "versions": "0+", "about": "The set of state changelog topics associated with this sub-topology. Created automatically." }, { "name": "RepartitionSinkTopicsGroupId", "type": "[]string", "versions": "0+", "entityType": "groupId", "about": "The repartition topics the sub-topology writes togroup identifier." }, { "name": "RepartitionSourceTopicsMemberId", "type": "[]TopicInfostring", "versions": "0+", "about": "The setmember ofID sourcegenerated topicsby thatthe arestreams internallyconsumer. createdThe repartitionmember topics.ID Createdmust automatically." } ] } ] } be kept during the entire lifetime of the streams consumer process." }, { "name": "ActiveTasksMemberEpoch", "type": "[]TaskIdsint32", "versions": "0+", "nullableVersionsabout": "0+", "default": "null", "about": "Currently owned active tasks for this client. Null if unchanged since last heartbeatThe current member epoch; 0 to join the group; -1 to leave the group; -2 to indicate that the static member will rejoin." }, { "name": "StandbyTasksEndpointInformationEpoch", "type": "[]TaskIdsint32", "versions": "0+", "nullableVersions": "0+", "default": "null", "about": "CurrentlyThe ownedcurrent standbyendpoint tasksepoch forof this client. Null if unchanged since last heartbeat." , represents the latest endpoint epoch this client received"}, { "name": "WarmupTasksInstanceId", "type": "[]TaskIdsstring", "versions": "0+", "nullableVersions": "0+", "default": "null", "about": "Currentlynull ownedif warm-upnot tasksprovided foror thisif client. Null if unchanged sinceit didn't change since the last heartbeat; the instance ID for static membership otherwise." }, { "name": "ProcessIdRackId", "type": "string", "versions": "0+", "nullableVersions": "0+", "default": "null", "about": "Identitynull ofif thenot streamsprovided instanceor thatif mayit have multiple consumers. Null if unchanged since last heartbeatdidn't change since the last heartbeat; the rack ID of the member otherwise." }, { "name": "UserEndpointRebalanceTimeoutMs", "type": "Endpointint32", "versions": "0+", "nullableVersions": "0+", "default": "null"-1, "about": "User-defined1 endpointif forit Interactive Queries. Null if unchanged since didn't change since the last heartbeat." }, { "name": "ClientTags", "type": "[]KeyValue", "versions": "0+", "nullableVersions": "0+", "default": "null", "about": "Used for rack-aware assignment algorithm. Null if unchanged since last heartbeat.; the maximum time in milliseconds that the coordinator will wait on the member to revoke its tasks otherwise." }, { "name": "TaskOffsetsTopology", "type": "[]TaskOffsetTopology", "versions": "0+", "nullableVersions": "0+", "default": "null", "about": "Cumulative changelog offsets for tasks. Only updated when a warm-up task has caught up, and according to the task offset interval. Null if unchanged since last heartbeat." }, The topology metadata of the streams application. Used to initialize the topology of the group and to check if the topology corresponds to the topology initialized for the group. Only sent when memberEpoch = 0, must be non-empty. Null otherwise.", "fields": [ { "name": "TaskEndOffsetsEpoch", "type": "[]TaskOffsetint32", "versions": "0+", "nullableVersions": "0+", "default": "null", "about": "CumulativeThe changelogepoch end-offsetsof forthe taskstopology. OnlyUsed updatedto whencheck aif warm-upthe tasktopology has caught up, and according corresponds to the tasktopology offsetinitialized interval.on Null if unchanged since last heartbeatthe brokers." }, { "name": "ShutdownApplicationSubtopologies", "type": "bool[]Subtopology", "versions": "0+", "default": false, "about": "WhetherThe allsub-topologies Streamsof clientsthe in the group should shut down." } ], "commonStructsstreams application.", "fields": [ { "name": "KeyValue", "versions": "0+", "fields": [ { "name": "KeySubtopologyId", "type": "string", "versions": "0+", "about": "key ofString to uniquely identify the subtopology. Deterministically generated from the configtopology" }, { "name": "ValueSourceTopics", "type": "[]string", "versions": "0+", "about": "valueThe oftopics the config"topology } ]reads from." }, { "name": "TopicInfo", "versions": "0+", "fields": [ { "name": "NameSourceTopicRegex", "type": "[]string", "versions": "0+", "about": "The name ofregular expressions identifying topics the subtopology reads topicfrom." }, { "name": "PartitionsStateChangelogTopics", "type": "int32[]TopicInfo", "versions": "0+", "about": "The numberset of partitions in the topic. Can be 0 if no specific number of partitions is enforced. Always 0 for changelog topics." }, state changelog topics associated with this subtopology. Created automatically." }, { "name": "TopicConfigsRepartitionSinkTopics", "type": "[]KeyValuestring", "versions": "0+", "nullableVersions": "0+", "default": "null", "about": "Topic-level configurations as key-value pairs."The repartition topics the subtopology writes to." }, } ]}, { "name": "EndpointRepartitionSourceTopics", "versionstype": "0+[]TopicInfo", "fieldsversions": [ "0+", { "name": "Host", "type": "string", "versionsabout": "0+", The set of source topics that are internally "about": "host of the endpointcreated repartition topics. Created automatically." }, { "name": "PortCopartitionGroups", "type": "int32[]CopartitionGroup", "versions": "0+", "about": "portA subset of the endpoint" } source topics that must be copartitioned.", ]}, { "name": "TaskOffset", "versionsfields": "0+", "fields": [ [ { "name": "SubtopologySourceTopics", "type": "string[]int16", "versions": "0+", "about": "The topics sub-topology identifierthe topology reads from. Index into the array on the subtopology level." }, { "name": "PartitionSourceTopicRegex", "type": "int32[]int16", "versions": "0+", "about": "The partition." }, { "nameabout": "Offset", "type": "int64", "versions": "0+", "about": "The offset." } ]Regular expressions identifying topics the subtopology reads from. Index into the array on the subtopology level." }, { "name": "TaskIds", "versions": "0+", "fields": [ { "name": "SubtopologyRepartitionSourceTopics", "type": "string[]int16", "versions": "0+", "about": "The sub-topology identifier." }, { "nameabout": "Partitions", "The set of source topics that are internally created repartition topics. Index into the array on the subtopology level." } ]} ]} ] }, { "name": "ActiveTasks", "type": "[]int32TaskIds", "versions": "0+", "nullableVersions": "0+", "default": "null", "about": "The partitions of the input topics processed by this memberCurrently owned active tasks for this client. Null if unchanged since last heartbeat." }, ]} ] } |
Required ACL
READon groupCREATEon cluster resource, orCREATEon all topics inStateChangelogTopicsandRepartitionSourceTopics- Note that this ACLs are only required if the group coordinator should create the internal topics implicitly. If the internal topics are created explicitly, this ACL is not needed for the Streams group heartbeat.
DESCRIBE_CONFIGSon all topics included in the message
Request Validation
INVALID_REQUEST is returned should the request not obey to the following invariants:
GroupIdmust be non-empty.Either
MemberIdis non-empty orMemberEpochis 0.MemberEpochmust be >= -2.InstanceId, if not null, must be non-empty.RebalanceTimeoutMsmust be larger than zero in the first heartbeat request.ActiveTasks,StandbyTasksandWarmupTaskshave to be disjoint setsEach element of
ActiveTasks,StandbyTasksandWarmupTaskshas to be a valid task ID in the topology initialized for the group ID.ActiveTasks,StandbyTasksandWarmupTaskshave to be non-null and empty when joining (member epoch is 0)
STREAMS_INVALID_TOPOLOGY is returned when the request contains a new topology and should the topology not obey the following invariants:
A
StateChangelogTopictopics must not have a defined partition number.A
RepartitionSourceTopiccannot be inSourceTopicsorStateChangelogTopicsof any subtopology.A
StateChangelogTopiccannot be inSourceTopicsorRepartitionSinkTopicorRepartitionSourceTopicsof any subtopology.A
RepartitionSourceTopicof one subtopology must be aRepartitionSinkTopicof at least one other subtopology.
STREAMS_MISSING_SOURCE_TOPICS is returned if there are source topics missing during the initialization of the topology. Also returned if the source topic regular expression matched no topics.
STREAMS_INCONSISTENT_INTERNAL_TOPICS is returned if there are internal topics present on the broker that are not consistent with the internal topic requirements of the provided topology.
Request Handling
When the group coordinator handles a StreamsGroupHeartbeat request:
- Performs request validation.
If the member joins the group (i.e. member epoch is 0):
- If the group is initialized:
- Looks up the group
- If the group is not initialized:
- Creates group and initializes the topology by creating all required internal topics.
- Writes the topology, keyed with the
GroupIdto the consumer offset topic. Existing records will be overwritten.
GROUP_ID_NOT_FOUNDis returned if the group ID is associated with a group type that is notstreamsorclassic(the latter will be allowed for migration).- Creates the member.
- If the group is initialized:
- If the member is already part of the group (i.e. member epoch is greater than 0):
- Looks up the group.
GROUP_ID_NOT_FOUNDis returned if the group ID does not exist anymore.- If the member does not exist, returns
UNKNOWN_MEMBER_ID - Checks whether the member epoch matches the member epoch in its current assignment.
FENCED_MEMBER_EPOCHis returned otherwise. The member is also removed from the group.- There is an edge case here. When the group coordinator transitions a member to its target epoch, the heartbeat response with the new member epoch may be lost. In this case, the member will retry with the member epoch that it knows about and its request will be rejected with a
FENCED_MEMBER_EPOCH. This will be handled as in KIP-848.
- There is an edge case here. When the group coordinator transitions a member to its target epoch, the heartbeat response with the new member epoch may be lost. In this case, the member will retry with the member epoch that it knows about and its request will be rejected with a
- Updates information of the member if needed. The group epoch is incremented if there is any change.
- Reconcile the member assignments as explained earlier in this document.
Reponse Schema
The group coordinator will only set the ActiveTasks, StandbyTasks and WarmupTasks fields until the member acknowledges that it has converged to the desired assignment. This is done to ensure that the members converge to the target assignment.
{ "name": "StandbyTasks", "type": "[]TaskIds", "versions": "0+", "nullableVersions": "0+", "default": "null",
"about": "Currently owned standby tasks for this client. Null if unchanged since last heartbeat." },
{ "name": "WarmupTasks", "type": "[]TaskIds", "versions": "0+", "nullableVersions": "0+", "default": "null",
"about": "Currently owned warm-up tasks for this client. Null if unchanged since last heartbeat." },
{ "name": "ProcessId", "type": "string", "versions": "0+", "nullableVersions": "0+", "default": "null",
"about": "Identity of the streams instance that may have multiple consumers. Null if unchanged since last heartbeat." },
{ "name": "UserEndpoint", "type": "Endpoint", "versions": "0+", "nullableVersions": "0+", "default": "null",
"about": "User-defined endpoint for Interactive Queries. Null if unchanged since last heartbeat or if not defined on the client." },
{ "name": "ClientTags", "type": "[]KeyValue", "versions": "0+", "nullableVersions": "0+", "default": "null",
"about": "Used for rack-aware assignment algorithm. Null if unchanged since last heartbeat." },
{ "name": "TaskOffsets", "type": "[]TaskOffset", "versions": "0+", "nullableVersions": "0+", "default": "null",
"about": "Cumulative changelog offsets for tasks. Only updated when a warm-up task has caught up, and according to the task offset interval. Null if unchanged since last heartbeat." },
{ "name": "TaskEndOffsets", "type": "[]TaskOffset", "versions": "0+", "nullableVersions": "0+", "default": "null",
"about": "Cumulative changelog end-offsets for tasks. Only updated when a warm-up task has caught up, and according to the task offset interval. Null if unchanged since last heartbeat." },
{ "name": "ShutdownApplication", "type": "bool", "versions": "0+", "default": false,
"about": "Whether all Streams clients in the group should shut down." }
],
"commonStructs": [
{ "name": "KeyValue", "versions": "0+", "fields": [
{ "name": "Key", "type": "string", "versions": "0+",
"about": "key of the config" },
{ "name": "Value", "type": "string", "versions": "0+",
"about": "value of the config" }
]},
{ "name": "TopicInfo", "versions": "0+", "fields": [
{ "name": "Name", "type": "string", "versions": "0+",
"about": "The name of the topic." },
{ "name": "Partitions", "type": "int32", "versions": "0+",
"about": "The number of partitions in the topic. Can be 0 if no specific number of partitions is enforced. Always 0 for changelog topics." },
{ "name": "ReplicationFactor", "type": "int16", "versions": "0+",
"about": "The replication factor of the topic. Can be 0 if the default replication factor should be used." },
{ "name": "TopicConfigs", "type": "[]KeyValue", "versions": "0+",
"about": "Topic-level configurations as key-value pairs."
}
]},
{ "name": "Endpoint", "versions": "0+", "fields": [
{ "name": "Host", "type": "string", "versions": "0+",
"about": "host of the endpoint" },
{ "name": "Port", "type": "uint16", "versions": "0+",
"about": "port of the endpoint" }
]},
{ "name": "TaskOffset", "versions": "0+", "fields": [
{ "name": "SubtopologyId", "type": "string", "versions": "0+",
"about": "The subtopology identifier." },
{ "name": "Partition", "type": "int32", "versions": "0+",
"about": "The partition." },
{ "name": "Offset", "type": "int64", "versions": "0+",
"about": "The offset." }
]},
{ "name": "TaskIds", "versions": "0+", "fields": [
{ "name": "SubtopologyId", "type": "string", "versions": "0+",
"about": "The subtopology identifier." },
{ "name": "Partitions", "type": "[]int32", "versions": "0+",
"about": "The partitions of the input topics processed by this member." }
]}
]
} |
Required ACL
READon groupCREATEon cluster resource, orCREATEon all topics inStateChangelogTopicsandRepartitionSourceTopics- Note that this ACLs are only required if the group coordinator should create the internal topics implicitly. If the internal topics are created explicitly, this ACL is not needed for the Streams group heartbeat.
DESCRIBEon all topics included in the message
Request Validation
INVALID_REQUEST is returned should the request not obey to the following invariants:
GroupIdmust be non-empty.MemberIdmust be non-empty.MemberEpochmust be >= -2.InstanceId, if not null, must be non-empty.RebalanceTimeoutMsmust be larger than zero in the first heartbeat request.ActiveTasks,StandbyTasksandWarmupTaskshave to be disjoint setsActiveTasks,StandbyTasksandWarmupTaskshave to be non-null and empty when joining (member epoch is 0)- If
MemberEpochis 0,Topologyshould be non-null. Otherwise, it should benull.
STREAMS_INVALID_TOPOLOGY is returned when the request contains a new topology and should the topology not obey the following invariants:
A
StateChangelogTopictopics must not have a defined partition number.A
RepartitionSourceTopiccannot be inSourceTopicsorStateChangelogTopicsof any subtopology.A
StateChangelogTopiccannot be inSourceTopicsorRepartitionSinkTopicorRepartitionSourceTopicsof any subtopology.A
RepartitionSourceTopicof one subtopology must be aRepartitionSinkTopicof at least one other subtopology.- All indices in
CopartitionGroupsmust be valid indices in the corresponding topic arrays.
Request Handling
When the group coordinator handles a StreamsGroupHeartbeat request:
- Performs request validation.
If the member joins the group (i.e. member epoch is 0):
- Look up or create the group.
- If the group is created the topology epoch of the group is set to the topology epoch sent by the member.
GROUP_ID_NOT_FOUNDis returned if the group ID is associated with a group type that is notstreamsorclassic(the latter will be allowed for migration).- Compare the topology epoch of the request ER to the topology epoch of the group EG
- If ER=EG, check if topology metadata in the request is equal to the topology metadata of the group, otherwise fail with
STREAMS_INVALID_TOPOLOGY_EPOCH - If ER<EG, fail with
STREAMS_TOPOLOGY_FENCED - If ER>EG+1, fail with
STREAMS_INVALID_TOPOLOGY_EPOCH - If ER=EG+1, update the topology by writing the new topology record to the offset topic
- If ER=EG, check if topology metadata in the request is equal to the topology metadata of the group, otherwise fail with
- Creates the member.
- Look up or create the group.
- If the member is already part of the group (i.e. member epoch is greater than 0):
- Looks up the group.
GROUP_ID_NOT_FOUNDis returned if the group ID does not exist anymore.- If the member does not exist, returns
UNKNOWN_MEMBER_ID - Checks whether the member epoch matches the member epoch in its current assignment.
FENCED_MEMBER_EPOCHis returned otherwise. The member is also removed from the group.- There is an edge case here. When the group coordinator transitions a member to its target epoch, the heartbeat response with the new member epoch may be lost. In this case, the member will retry with the member epoch that it knows about and its request will be rejected with a
FENCED_MEMBER_EPOCH. This will be handled as in KIP-848.
- There is an edge case here. When the group coordinator transitions a member to its target epoch, the heartbeat response with the new member epoch may be lost. In this case, the member will retry with the member epoch that it knows about and its request will be rejected with a
- If the topology epoch in the request is less than the topology epoch of the group, set state
STALE_TOPOLOGYin the response.
- Updates information of the member if needed. The group epoch is incremented if there is any change.
- If the topology or topic metadata changed, detect any topology / topic mismatches as described earlier in this document.
- Reconcile the member assignments as explained earlier in this document.
- When a member assignment gets changed it will bump the StreamsGroup
EndpointEpochand bump the corresponding memberEndpointInformationEpochin the response. When all membersEndpointInformationEpochvalues converge on the same value as the group-wide EndpointEpoch updated IQ information will be included in the member heartbeat response.
Response Schema
The group coordinator will only set the ActiveTasks, StandbyTasks and WarmupTasks fields until the member acknowledges that it has converged to the desired assignment. This is done to ensure that the members converge to the target assignment.
| Note |
|---|
Update for Apache Kafka 4.4 release. In Apache Kafka 4.2 release, there is a bug in the implementation of the |
| Code Block | ||||
|---|---|---|---|---|
| ||||
{
"apiKey": TBD,
"type": "response",
"name": "StreamsGroupHeartbeatResponse",
"validVersions": "0", // "0" in 4.2/4.3 release; bumped to "0-1" in 4.4 release
"flexibleVersions": "0+",
// Supported errors:
// - GROUP_AUTHORIZATION_FAILED (version 0+)
// - GROUP_ID_NOT_FOUND (version 0+)
// - NOT_COORDINATOR (version 0+)
// - COORDINATOR_NOT_AVAILABLE (version 0+)
// - COORDINATOR_LOAD_IN_PROGRESS (version 0+)
// - INVALID_REQUEST (version 0+)
// - UNKNOWN_MEMBER_ID (version 0+)
// - FENCED_MEMBER_EPOCH (version 0+)
// - UNRELEASED_INSTANCE_ID (version 0+)
// - GROUP_MAX_SIZE_REACHED (version 0+)
// - TOPIC_AUTHORIZATION_FAILED (version 0+)
// - CLUSTER_AUTHORIZATION_FAILED (version 0+)
// - STREAMS_INVALID_TOPOLOGY (version 0+)
// - STREAMS_INVALID_TOPOLOGY_EPOCH (version 0+)
// - STREAMS_TOPOLOGY_FENCED (version 0+)
"fields": [
{ "name": "ThrottleTimeMs", "type": "int32", "versions": "0+",
"about": "The duration in milliseconds for which the request was throttled due to a quota violation, or zero if the request did not violate any quota." },
{ "name": "ErrorCode", "type": "int16", "versions": "0+",
"about": "The top-level error code, or 0 if there was no error" },
{ "name": "ErrorMessage", "type": "string", "versions": "0+", "nullableVersions": "0+", "default": "null",
"about": "The top-level error message, or null if there was no error." },
{ "name": "MemberId", "type": "string", "versions": "0+",
"about": "The member id is always generated by the streams consumer."},
{ "name": "MemberEpoch", "type": "int32", "versions": "0+",
"about": "The member epoch." },
{ "name": "HeartbeatIntervalMs", "type": "int32", "versions": "0+",
"about": "The heartbeat interval in milliseconds." },
{ "name": "AcceptableRecoveryLag", "type": "int32", "versions": "0+",
"about": "The maximal lag a warm-up task can have to be considered caught-up." }, // incorrectly implemented as `int32` in 4.2 release; updated to `int64` and request/response version bump to "1" in 4.4 release.
{ "name": "TaskOffsetIntervalMs", "type": "int32", "versions": "0+",
"about": "The interval in which the task changelog offsets on a client are updated on the broker. The offsets are sent with the next heartbeat after this time has passed." },
{ "name": "Status", "type": "[]Status", "versions": "0+", "nullableVersions": "0+", "default": "null",
"about": "Indicate zero or more status for the group. Null if unchanged since last heartbeat." },
// The streams app knows which partitions to fetch from given this information
{ "name": "ActiveTasks", "type": "[]TaskIds", "versions": "0+", "nullableVersions": "0+", "default": "null",
"about": "Assigned active tasks for this client. Null if unchanged since last heartbeat." },
{ "name": "StandbyTasks", "type": "[]TaskIds", "versions": "0+", "nullableVersions": "0+", "default": "null",
"about": "Assigned standby tasks for this client. Null if unchanged since last heartbeat." },
{ "name": "WarmupTasks", "type": "[]TaskIds", "versions": "0+", "nullableVersions": "0+", "default": "null",
"about": "Assigned warm-up tasks for this client. Null if unchanged since last heartbeat." },
// IQ-related information
{ "name": "EndpointInformationEpoch", "type": "int32", "versions": "0+",
"about": "The endpoint epoch set in the response"},
{ "name": "PartitionsByUserEndpoint", "type": "[]EndpointToPartitions", "versions": "0+", "nullableVersions": "0+", "default": "null",
"about": "Global assignment information used for IQ. Null if unchanged since last heartbeat." ,
"fields": [
{ "name": "UserEndpoint", "type": "Endpoint", "versions": "0+",
"about": "User-defined endpoint to connect to the node" },
{ "name": "ActivePartitions", "type": "[]TopicPartition", "versions": "0+",
"about": "All active partitions available on the node" },
{ "name": "StandbyPartitions", "type": "[]TopicPartition", "versions": "0+",
"about": "All standby paritions available on the node"}
]
}
],
"commonStructs": [
{ "name": "Status", "versions": "0+", "fields": [
// Possible status codes
// 0 - STALE_TOPOLOGY - The topology epoch supplied is lower than the topology epoch for this streams group.
// 1 - MISSING_SOURCE_TOPICS - One or more source topics are missing or a source topic regex resolves to zero topics.
// Missing topics are indicated in the StatusDetail.
// 2 - INCORRECTLY_PARTITIONED_TOPICS - One or more topics are incorrectly partitioned, that is, they are not copartitioned despite being
// part of a copartition group, or the number of partitions in a changelog topic does not correspond
// to the maximal number of source topic partition for that subtopology.
// Incorrectly partitioned topics are indicated in the StatusDetail.
// 3 - MISSING_INTERNAL_TOPICS - One or more internal topics are missing.
// Missing topics are indicated in the StatusDetail.
// The group coordinator will attempt to create all missing internal topics, if any errors occur during
// topic creation, this will be indicated in StatusDetail.
// 4 - SHUTDOWN_APPLICATION - A client requested the shutdown of the whole application.
// 5 - ASSIGNMENT_DELAYED - No assignment was provided because assignment computation was delayed.
// 6 - MISSING_CLIENT_TAGS - (Response v1+ only) The GC is configured to use `client.tag.` for rack-aware standby task assignment, but the client does not provide this tag
{ "name": "StatusCode", "type": "int8 | ||||
| Code Block | ||||
| ||||
{ "apiKey": TBD, "type": "response", "name": "StreamsGroupHeartbeatResponse", "validVersions": "0", "flexibleVersions": "0+", // Supported errors: // - GROUP_AUTHORIZATION_FAILED (version 0+) // - GROUP_ID_NOT_FOUND (version 0+) // - NOT_COORDINATOR (version 0+) // - COORDINATOR_NOT_AVAILABLE (version 0+) // - COORDINATOR_LOAD_IN_PROGRESS (version 0+) // - INVALID_REQUEST (version 0+) // - UNKNOWN_MEMBER_ID (version 0+) // - FENCED_MEMBER_EPOCH (version 0+) // - UNRELEASED_INSTANCE_ID (version 0+) // - GROUP_MAX_SIZE_REACHED (version 0+) // - TOPIC_AUTHORIZATION_FAILED (version 0+) // - CLUSTER_AUTHORIZATION_FAILED (version 0+) // - STREAMS_INVALID_TOPOLOGY (version 0+) // - STREAMS_MISSING_SOURCE_TOPICS (version 0+) // - STREAMS_INCONSISTENT_INTERNAL_TOPICS (version 0+) "fields": [ // Same as consumer group heart beat { "name": "ThrottleTimeMs", "type": "int32", "versions": "0+", "about": "The duration in milliseconds for which the request was throttled due to a quota violation, or zero if the request did not violate any quota." }, { "name": "ErrorCode", "type": "int16", "versions": "0+", "about": "The top-level error code, or 0 if there was no error" }, { "name": "ErrorMessage", "type": "string", "versions": "0+", "nullableVersions": "0+", "default": "null", "about": "The top-level error message, or null if there was no error." }, { "name": "MemberId", "type": "string", "versions": "0+", "nullableVersions": "0+", "default": "null", "about": "The member id generated by the coordinator. Only provided when the member joins with MemberEpoch == 0." }, { "name": "MemberEpoch", "type": "int32", "versions": "0+", "about": "The member epoch." }, { "name": "HeartbeatIntervalMs", "type": "int32", "versions": "0+", "about": "The heartbeat interval in milliseconds." }, { "name": "AcceptableRecoveryLag", "type": "int32", "versions": "0+", "about": "The maximal lag a warm-up task can have to be considered caught-up." }, { "name": "TaskOffsetIntervalMs", "type": "int32", "versions": "0+", "about": "The interval in which the task changelog offsets on a client are updated on the broker. The offsets are sent with the next heartbeat after this time has passed." }, // Topology updating { "name": "GroupTopologyId", "type": "string", "versions": "0+", "nullableVersions": "0+", "default": null, "about": "The current ID of the topologyA code to indicate that a particular status is active for the group. Null if unchanged since last heartbeat. membership" }, { "name": "StatusStatusDetail", "type": "[]Statusstring", "versions": "0+", "nullableVersions": "0+", "default": "null", "about": "IndicateA zerostring orrepresentation moreof status for the groupstatus. Null if unchanged since last heartbeat." " } ]}, // The streams app knows which partitions to fetch from given this information { "name": "TopicPartition", "versions": "0+", "fields": [ { "name": "ActiveTasksTopic", "type": "[]TaskIdsstring", "versions": "0+", "nullableVersions": "0+", "default": "null", "about": "Assigned active tasks for this client. Null if unchanged since last heartbeat.topic name" }, { "name": "StandbyTasksPartitions", "type": "[]TaskIds", "versions": "0+", "nullableVersions": "0+int32", "defaultversions": "null0+", "about": "partitions"Assigned standby} tasks for this client. Null if unchanged since last heartbeat." ]}, { "name": "WarmupTasksTaskIds", "typeversions": "[]TaskIds0+", "versions"fields": [ { "name": "0+SubtopologyId", "nullableVersionstype": "0+string", "defaultversions": "null0+", "about": "AssignedThe warm-up tasks for this client. Null if unchanged since last heartbeat.subtopology identifier." }, // IQ-related information { "name": "PartitionsByUserEndpointPartitions", "type": "[]EndpointToPartitionsint32", "versions": "0+", "nullableVersions": "0+", "default": "null", "about": "Global assignment information used for IQ. Null if unchanged since last heartbeat." , "The partitions of the input topics processed by this member." } ]}, { "name": "Endpoint", "versions": "0+", "fields": [ { "name": "UserEndpointHost", "type": "Endpointstring", "versions": "0+", "about": "User-defined endpoint to connect tohost of the nodeendpoint" }, { "name": "PartitionsPort", "type": "[]TopicPartitionuint16", "versions": "0+", "about": "Allport partitionsof available on the nodeendpoint" } ]} ] } |
StreamsGroupDescribe API
Request Schema
| Code Block | ||||
|---|---|---|---|---|
| ||||
{ "apiKey": TBD, } ]"type": "request", "commonStructslisteners": ["broker"], "name": "StreamsGroupDescribeRequest", { "namevalidVersions": "Status0", "versionsflexibleVersions": "0+", "fields": [ { "name": // Possible status codes"GroupIds", "type": "[]string", "versions": "0+", "entityType": "groupId", "about": "The ids of the groups to describe" }, { "name": "IncludeAuthorizedOperations", "type": "bool", "versions": "0+", "about": "Whether to include authorized operations." } ] } |
Required ACL
DESCRIBE on the group resource
- DESCRIBE on all topics used in the group's topology
Request Validation
INVALID_REQUEST is returned should the request not obey the schema definition.
INVALID_GROUP_ID is returned should the group ID be empty.
Request Handling
When the group coordinator handle a StreamsGroupDescribeRequest request:
Checks whether the group ids exists. If it does not,
GROUP_ID_NOT_FOUNDis returned. Similarly, it is returned if the group ID is associated with a group type that is notstreams.Looks up the groups and returns the response.
Response Schema
| Code Block | ||||
|---|---|---|---|---|
| ||||
{ "apiKey": TBD, "type": "response", "name": "StreamsGroupDescribeResponse", "validVersions": "0", "flexibleVersions": "0+", // Supported errors: // - GROUP_AUTHORIZATION_FAILED (version 0+) // - NOT_COORDINATOR (version 0+) // - COORDINATOR_NOT_AVAILABLE (version 0+) // - COORDINATOR_LOAD_IN_PROGRESS (version 0+) // - INVALID_REQUEST (version 0+) // - INVALID_GROUP_ID (version 0+) // - GROUP_ID_NOT_FOUND (version 0+) "fields": [ // 0 - INCONSISTENT_TOPOLOGY - The topology ID supplied is inconsistent with the topology for this streams group. // 1 - MISSING_SOURCE_TOPICS - One or more source topics do not exist. Missing topics are indicated in the StatusDetail. // 2 - MISSING_INTERNAL_TOPICS - One or more internal topics do not exist. Missing topics are indicated in the StatusDetail. // 3 - SHUTDOWN_APPLICATION - A client requested the shutdown of the whole application. { "name": "StatusCodeThrottleTimeMs", "type": "int8int32", "versions": "0+", "about": "A code to indicate that a particular status is active for the group membership "about": "The duration in milliseconds for which the request was throttled due to a quota violation, or zero if the request did not violate any quota." }, { "name": "StatusDetailGroups", "type": "string[]DescribedGroup", "versions": "0+", "about": "AEach string representation of the status." } ]}described group.", { "name": "TopicPartition", "versions": "0+", "fields": [ { "name": "TopicErrorCode", "type": "stringint16", "versions": "0+", "about": "topic nameThe describe error, or 0 if there was no error." }, { "name": "PartitionsErrorMessage", "type": "[]int32string", "versions": "0+", "about"nullableVersions": "0+", "default": "partitionsnull", } ]}, { "nameabout": "TaskIds", "versions": "0+", "fields": [The top-level error message, or null if there was no error." }, { "name": "SubtopologyGroupId", "type": "string", "versions": "0+", "entityType": "groupId", "about": "The subtopologygroup ID identifierstring." }, { "name": "PartitionsGroupState", "type": "[]int32string", "versions": "0+", "about": "The partitionsgroup ofstate thestring, inputor topicsthe processed by this memberempty string." }, ]} { "name": "EndpointGroupEpoch", "type": "int32", "versions": "0+", "fieldsabout": [ "The group epoch." }, { "name": "HostAssignmentEpoch", "type": "stringint32", "versions": "0+", "about": "hostThe of the endpointassignment epoch." }, { "name": "PortTopology", "type": "int32Topology", "versions": "0+", "nullableVersions": "0+", "default": "null", "about": "port ofThe topology metadata currently initialized for the endpoint" } ]} ] } |
StreamsGroupDescribe API
Request Schema
| Code Block | ||||
|---|---|---|---|---|
| ||||
{ "apiKey": TBD, "type": "request", "listeners": ["broker"], "name": "StreamsGroupDescribeRequest", "validVersionsstreams application. Can be null in case of a describe error.", "fields": [ { "name": "Epoch", "type": "int32", "versions": "0+", "flexibleVersions "about": "0+"The epoch of the currently initialized topology for this group." }, "fields": [ { "name": "GroupIdsSubtopologies", "type": "[]stringSubtopology", "versions": "0+", "entityTypenullableVersions": "0+", "default": "groupIdnull", "about": "The ids of the groups to describe" } subtopologies of the streams application. This contains the configured subtopologies, where the number of partitions are set and any regular expressions are resolved to actual topics. Null if the group is uninitialized, source topics are missing or incorrectly partitioned.", { "name": "IncludeAuthorizedOperations", "type": "bool", "versions": "0+", "aboutfields": "Whether to include authorized operations." } ] } |
Required ACL
Read Group
Request Validation
INVALID_REQUEST is returned should the request not obey the schema definition.
INVALID_GROUP_ID is returned should the group ID be empty.
Request Handling
When the group coordinator handle a StreamsGroupDescribeRequest request:
Checks whether the group ids exists. If it does not,
GROUP_ID_NOT_FOUNDis returned. Similarly, it is returned if the group ID is associated with a group type that is notstreams.Looks up the groups and returns the response.
Response Schema
| Code Block | ||||
|---|---|---|---|---|
| ||||
{ "apiKey": TBD, "type": "response", [ { "name": "StreamsGroupDescribeResponseSubtopologyId", "validVersionstype": "0string", "flexibleVersionsversions": "0+", // Supported errors: // - GROUP_AUTHORIZATION_FAILED (version 0+) // - NOT_COORDINATOR (version 0+) // - COORDINATOR_NOT_AVAILABLE (version 0+) // - COORDINATOR_LOAD_IN_PROGRESS (version 0+) // - INVALID_REQUEST (version 0+) // - INVALID_GROUP_ID (version 0+) // - GROUP_ID_NOT_FOUND (version 0+) "fields": [ "about": "String to uniquely identify the subtopology." }, { "name": "ThrottleTimeMsSourceTopics", "type": "int32[]string", "versions": "0+", "about": "The duration in milliseconds for which the request was throttled due to a quota violation, or zero if the request did not violate any quota." }, "about": "The topics the subtopology reads from." }, { "name": "GroupsRepartitionSinkTopics", "type": "[]DescribedGroupstring", "versions": "0+", "about": "Each described group."The repartition topics the subtopology writes to." }, "fields": [ { "name": "ErrorCodeStateChangelogTopics", "type": "int16[]TopicInfo", "versions": "0+", "about": "The describe error, or 0 if there was no errorset of state changelog topics associated with this subtopology. Created automatically." }, { "name": "ErrorMessageRepartitionSourceTopics", "type": "string[]TopicInfo", "versions": "0+", "nullableVersions": "0+", "default": "null", "about": "The top-level error message, or null if there was no error set of source topics that are internally created repartition topics. Created automatically." }, { "name": "GroupId", "type": "string", "versions": "0+", "entityType": "groupId", ]} "about": "The group ID string." ]}, { "name": "GroupStateMembers", "type": "string[]Member", "versions": "0+", "about": "The group state string, or the empty string." }, members.", "fields": [ { "name": "GroupEpochMemberId", "type": "int32string", "versions": "0+", "about": "The groupmember epochID." }, { "name": "AssignmentEpochMemberEpoch", "type": "int32", "versions": "0+", "about": "The assignmentmember epoch." }, { "name": "TopologyIdInstanceId", "type": "string", "versions": "0+", "nullableVersions": "0+", "default": "null", "about": "The IDmember ofinstance the currently initialized topology ID for thisstatic groupmembership." }, { "name": "TopologyRackId", "type": "[]Subtopologystring", "versions": "0+", "about"nullableVersions": "0+", "default": "The sub-topologies of the streams application.", "null", "fieldsabout": ["The rack ID." }, { "name": "SubtopologyClientId", "type": "string", "versions": "0+", "about": "StringThe to uniquely identify the subtopologyclient ID." }, { "name": "SourceTopicsClientHost", "type": "[]string", "versions": "0+", "about": "The topics the topology reads from "The client host." }, { "name": "SourceTopicRegexTopologyEpoch", "type": "stringint32", "versions": "0+", "nullableVersions": "0+", "default": "null", "about": "The regular expressions identifying topicsepoch of the topology readson from. null if not providedthe client." }, { "name": "RepartitionSinkTopicsProcessId", "type": "[]string", "versions": "0+", "about": "TheIdentity topicsof the topology writes to. streams instance that may have multiple clients. " }, { "name": "StateChangelogTopicsUserEndpoint", "type": "[]TopicInfoEndpoint", "versions": "0+", "nullableVersions": "0+", "default": "null", "about": "TheUser-defined setendpoint offor stateInteractive changelogQueries. topicsNull associatedif withnot thisdefined subtopology.for Createdthis automaticallyclient." }, { "name": "RepartitionSourceTopicsClientTags", "type": "[]TopicInfoKeyValue", "versions": "0+", "about": "The set of source topics that are internally created repartition topics. Created automatically." } ] "Used for rack-aware assignment algorithm." }, { "name": "MembersTaskOffsets", "type": "[]MemberTaskOffset", "versions": "0+", "about": "The members.", "fields": [Cumulative changelog offsets for tasks." }, { "name": "MemberIdTaskEndOffsets", "type": "string[]TaskOffset", "versions": "0+", "about": "The member IDCumulative changelog end offsets for tasks." }, { "name": "MemberEpochAssignment", "type": "int32Assignment", "versions": "0+", "about": "The membercurrent epochassignment." }, { "name": "InstanceIdTargetAssignment", "type": "stringAssignment", "versions": "0+", "nullableVersions": "0+", "default": "null", "about": "The member instance ID for static membershiptarget assignment." }, { "name": "RackIdIsClassic", "type": "stringbool", "versions": "0+", "nullableVersions": "0+", "default": "null", "about": "The rack IDTrue for classic members that have not been upgraded yet." }, ]}, { "name": "ClientIdAuthorizedOperations", "type": "stringint32", "versions": "0+", "default": "-2147483648", "about": "The client ID32-bit bitfield to represent authorized operations for this group." }, ] } ], { "namecommonStructs": "ClientHost",[ { "typename": "stringEndpoint", "versions": "0+", "about"fields": "The client host." }, [ { "name": "TopologyIdHost", "type": "string", "versions": "0+", "about": "The IDhost of the topology on the client.endpoint" }, { "name": "ProcessIdPort", "type": "stringuint16", "versions": "0+", "about": "Identityport of the streamsendpoint" } instance that may have multiple clients. " }, ]}, { "name": "TaskOffset", "versions": "0+", "fields": [ { "name": "ClientTagsSubtopologyId", "type": "[]KeyValuestring", "versions": "0+", "about": "UsedThe for rack-aware assignment algorithmsubtopology identifier." }, { "name": "TaskOffsetsPartition", "type": "[]TaskOffsetint32", "versions": "0+", "about": "Cumulative changelog offsets for tasksThe partition." }, { "name": "TaskEndOffsetsOffset", "type": "[]TaskOffsetint64", "versions": "0+", "about": "CumulativeThe changelog end offsets for tasks." offset." } ]}, { "name": "TopicPartitions", "versions": "0+", "fields": [ { "name": "AssignmentTopicId", "type": "Assignmentuuid", "versions": "0+", "about": "The currenttopic assignmentID." }, { "name": "TargetAssignmentTopicName", "type": "Assignmentstring", "versions": "0+", "entityType": "topicName", "about": "The targettopic assignmentname." } ]}, { "name": "AuthorizedOperationsPartitions", "type": "[]int32", "versions": "0+", "default": "-2147483648", "about": "32-bit bitfield to represent authorized operations for this groupThe partitions." } ] } ], "commonStructs": [ { "name": "TaskOffsetAssignment", "versions": "0+", "fields": [ { "name": "SubtopologyActiveTasks", "type": "string[]TaskIds", "versions": "0+", "about": "The subtopology identifierActive tasks for this client." }, { "name": "PartitionStandbyTasks", "type": "int32[]TaskIds", "versions": "0+", "about": "The partitionStandby tasks for this client." }, { "name": "OffsetWarmupTasks", "type": "int64[]TaskIds", "versions": "0+", "about": "The offset.Warm-up tasks for this client. " } ]}, { "name": "TopicPartitionsTaskIds", "versions": "0+", "fields": [ { "name": "TopicIdSubtopologyId", "type": "uuidstring", "versions": "0+", "about": "The topicsubtopology IDidentifier." }, { "name": "TopicNamePartitions", "type": "string[]int32", "versions": "0+", "entityTypeabout": "topicName",The partitions of the input topics processed by this member." } ]}, { "aboutname": "The topic name." },KeyValue", "versions": "0+", "fields": [ { "name": "PartitionsKey", "type": "[]int32string", "versions": "0+", "about": "The partitions.key of the config" }, ]}, { "name": "AssignmentValue", "versionstype": "0+string", "fieldsversions": ["0+", { "nameabout": "ActiveTasks", "typevalue of the config" } ]}, { "name": "[]TaskIdsTopicInfo", "versions": "0+", "about": "Active tasks for this client." },"fields": [ { "name": "StandbyTasksName", "type": "[]TaskIdsstring", "versions": "0+", "about": "StandbyThe tasksname forof thisthe clienttopic." }, { "name": "WarmupTasksPartitions", "type": "[]TaskIdsint32", "versions": "0+", "about": "Warm-up tasks for this client. " } ]}, { "name": "TaskIds", "versions": "0+", "fields": [The number of partitions in the topic. Can be 0 if no specific number of partitions is enforced. Always 0 for changelog topics." }, { "name": "SubtopologyReplicationFactor", "type": "stringint16", "versions": "0+", "about": "The subtopology identifierreplication factor of the topic. Can be 0 if the default replication factor should be used." }, { "name": "PartitionsTopicConfigs", "type": "[]int32KeyValue", "versions": "0+", "about": "TheTopic-level partitionsconfigurations ofas the input topics processed by this member." } ]}, { "name": "KeyValue", "versions": "0+", "fields": [ { "name": "Key", "type": "string", "versions": "0+", "about": "key of the config" }, { "name": "Value", "type": "string", "versions": "0+", "about": "value of the config" } ]}, { "name": "TopicInfo", "versions": "0+", "fields": [ { "name": "Name", "type": "string", "versions": "0+", "about": "The name of the topic." }, { "name": "Partitions", "type": "int32", "versions": "0+", "about": "The number of partitions in the topic. Can be 0 if no specific number of partitions is enforced. Always 0 for changelog topics." }, { "name": "TopicConfigs", "type": "[]KeyValue", "versions": "0+", "nullableVersions": "0+", "default": "null", key-value pairs." } ]} ] } |
Response Handling
Nothing particular.
Records
This section describes the new record types required for the new protocol. Similar to KIP-848, we define new record types that persist all data related to groups, their members and their assignments in the __consumer_offsets compacted topic. Each record has a dedicated key type that uses the version to differentiate the records from the records introduced in KIP-848, and those used to persist the committed offsets.
Compared to consumer groups, we introduce one extra record type, that stores information about the topology of the group.
The size of the persisted member metadata in the __consumer_offset topic will have to respect the max message size. But those records are persisted separately for each member, so it should be less of a concern. The same problem affects plain consumers in KIP-848 for very large consumer groups. Eventually, we may implement a way to split the records into multiple messages, and there are currently plans to add transaction support to the group coordinator to make sure the records can be updated atomically. For the first version of the protocol, we will limit those records by the max message size.
Group Metadata
The assignment-related metadata for a group with N members is stored with N+1 records. One metadata record per member and one metadata record for the group.
- The member metadata record, keyed by the group ID and the member ID, stores all relevant metadata that is sent by a member to the coordinator in a heartbeat request. A notable exception are task changelog offsets and task changelog end offsets, which are not persisted, as they are constantly changing.
- The group metadata, keyed by the group ID, contains
- The group epoch
- A hash of the topology metadata
- The epoch of the last validated topology
- The last configuration used by the assignor
The records evolve in the following way:
- When the first member joins the group, the group metadata and the member metadata records for the member are first created.
- Every time a new member joins the group, another member metadata record is added
- Whenever a member updates its member metadata through the heartbeat, a new version of the member metadata record is appended.
- When a member leaves the group, a tombstone is written for the member metadata key.
When the group lost all members (or never had any) and offsets.retention.minutes expires, the group metadata tombstone is written. This can only happen in group state EMPTY.
StreamsGroupMemberMetadataKey
| Code Block | ||||
|---|---|---|---|---|
| ||||
{ "type": "data", "name": "StreamsGroupMemberMetadataKey", "validVersions": TBD, "flexibleVersions": "none", "fields": [ { "name": "GroupId", "type": "string", "versions": TBD, "about": "Topic-levelThe configurations as key-value pairs." }group id." }, ]} ] } |
Response Handling
Nothing particular.
Records
This section describes the new record types required for the new protocol. Similar to KIP-848, we define new record types that persist all data related to groups, their members and their assignments in the __consumer_offsets compacted topic. Each record has a dedicated key type that uses the version to differentiate the records from the records introduced in KIP-848, and those used to persist the committed offsets.
Compared to consumer groups, we introduce one extra record type, that stores information about the topology of the group.
The size of the persisted member metadata in the __consumer_offset topic will have to respect the max message size. But those records are persisted separately for each member, so it should be less of a concern. The same problem affects plain consumers in KIP-848 for very large consumer groups. Eventually, we may implement a way to split the records into multiple messages, and there are currently plans to add transaction support to the group coordinator to make sure the records can be updated atomically. For the first version of the protocol, we will limit those records by the max message size.
Group Metadata
The assignment-related metadata for a group with N members is stored with N+1 records. One metadata record per member and one metadata record for the group.
- The member metadata record, keyed by the group ID and the member ID, stores all relevant metadata that is sent by a member to the coordinator in a heartbeat request. A notable exception are task changelog offsets and task changelog end offsets, which are not persisted, as they are constantly changing.
- The group metadata, keyed by the group ID, contains the group epoch.
The records evolve in the following way:
- When the first member joins the group, the group metadata and the member metadata records for the member are first created.
- Every time a new member joins the group, another member metadata record is added
- Whenever a member updates its member metadata through the heartbeat, a new version of the member metadata record is appended.
- When a member leaves the group, a tombstone is written for the member metadata key.
When the group lost all members (or never had any) and offsets.retention.minutes expires, the group metadata tombstone is written. This can only happen in group state EMPTY.
StreamsGroupMemberMetadataKey
{ "name": "MemberId", "type": "string", "versions": TBD,
"about": "The member id." }
]
} |
StreamsGroupMemberMetadataValue
| Code Block | ||||
|---|---|---|---|---|
| ||||
{
"type": "data",
"name": "StreamsGroupMemberMetadataValue",
"validVersions": "0",
"flexibleVersions": "0+",
"fields": [
{ "name": "InstanceId", "versions": "0+", "nullableVersions": "0+", "type": "string",
"about": "The (optional) instance ID for static membership." },
{ "name": "RackId", "versions": "0+", "nullableVersions": "0+", "type": "string",
"about": "The (optional) rack id." },
{ "name": "ClientId", "versions": "0+", "type": "string",
"about": "The client id." },
{ "name": "ClientHost", "versions": "0+", "type": "string",
"about": "The client host." }, | ||||
| Code Block | ||||
| ||||
{ "type": "data", "name": "StreamsGroupMemberMetadataKey", "validVersions": TBD, "flexibleVersions": "none", "fields": [ { "name": "GroupIdRebalanceTimeoutMs", "type": "stringint32", "versions": TBD"0+", "default": -1, "about": "The grouprebalance idtimeout." }, { "name": "MemberIdTopologyEpoch", "type": "stringint32", "versions": TBD"0+", "about": "The member idepoch of the topology. Must be non-zero." }, ] } |
StreamsGroupMemberMetadataValue
| Code Block | ||||
|---|---|---|---|---|
| ||||
{ " { "name": "ProcessId", "type": "data"string", "versions": "0+", "nameabout": "StreamsGroupMemberMetadataValue"Identity of the streams instance that may have multiple consumers." }, "validVersions": "0", { "flexibleVersionsname": "0+UserEndpoint", "fieldstype": [ { "nameEndpoint": "InstanceId", "versions": "0+", "nullableVersions": "0+", "typedefault": "stringnull", "about": "The (optional) instance ID for static membershipUser-defined endpoint for running interactive queries on this instance." }, { "name": "RackIdClientTags", "versionstype": "0+[]KeyValue", "nullableVersionsversions": "0+", "type": "string", "about": "TheUsed (optional)for rack-aware assignment idalgorithm." } ], "commonStructs": [ { "name": "ClientIdEndpoint", "versions": "0+", "fields": [ { "name": "Host", "type": "string", "versions": "0+", "about": "Thehost of clientthe id.endpoint" }, { "name": "ClientHostPort", "versionstype": "0+uint16", "typeversions": "string0+", "about": "Theport of clientthe host.endpoint" }, { "name": "RebalanceTimeoutMs", "type]}, { "name": "int32KeyValue", "versions": "0+", "default": -1, "aboutfields": "The[ rebalance timeout." }, { "name": "TopologyIdKey", "type": "string", "versions": "0+", "about": "Thekey ID of the topology. Must be non-empty.config" }, { "name": "ProcessIdValue", "type": "string", "versions": "0+", "about": "Identityvalue of the streamsconfig" instance} that may have multiple consumers." },] } ] } |
StreamsGroupMetadataKey
| Code Block | ||||
|---|---|---|---|---|
| ||||
{
"nametype": "UserEndpointdata",
"typename": "EndpointStreamsGroupMetadataKey",
"versionsvalidVersions": "0+"TBD,
"aboutflexibleVersions": "User-defined endpoint for running interactive queries on this instance." },"none",
"fields": [
{ "name": "ClientTagsGroupId", "type": "[]KeyValuestring", "versions": "0+"TBD,
"about": "The group id." }
]
} |
StreamsGroupMetadataValue
| Code Block | ||||
|---|---|---|---|---|
| ||||
{ "type": "data"Used for rack-aware assignment algorithm." } ], "commonStructsname": ["StreamsGroupMetadataValue", { "namevalidVersions": "Endpoint0", "versionsflexibleVersions": "0+", "fields": [ { "name": "HostEpoch", "typeversions": "string0+", "versionstype": "0+int32", "about": "hostThe of the endpointgroup epoch." }, { "name": "PortMetadataHash", "typeversions": "int320+", "versionstype": "0+int64", "about": "portThe hash of theall endpoint"topics } in the group." ]}, { "name": "KeyValueValidatedTopologyEpoch", "versions": "0+", "taggedVersions": "fields"0+", "tag": [ { "name0, "default": "Key"-1, "type": "stringint32", "versionsabout": "0+", "about": "key of the configThe topology epoch whose topics are validated to be present in a valid configuration in the metadata." }, { "name": "Value"LastAssignmentConfigs","taggedVersions": "0+", "typenullableVersions": "string""0+","tag": 1, "versionsdefault": "0+"null, "type": "[]LastAssignmentConfig", "about": "valueThe oflast theused config"configuration } parameters as key-value ] pairs." } ] } |
StreamsGroupMetadataKey
| Code Block | ||||
|---|---|---|---|---|
| ||||
{ , "typecommonStructs": "data", [ { "name": "StreamsGroupMetadataKeyLastAssignmentConfig", "validVersionsversions": TBD, "flexibleVersions": "none", "0+", "fields": [ { "name": "GroupIdKey", "type": "string", "versions": TBD"0+", "about": "TheKey of groupthe idconfig." }, ] } |
StreamsGroupMetadataValue
| Code Block | ||||
|---|---|---|---|---|
| ||||
{ "type": "data", { "name": "StreamsGroupMetadataValueValue", "validVersionstype": "0string", "flexibleVersionsversions": "0+", "fields": [ { "nameabout": "Epoch", "versions": "0+", "type": "int32", "about": "The group epoch." Value of the config." } ]} ] } |
Group Topology Metadata
...
| Code Block | ||||
|---|---|---|---|---|
| ||||
{
"type": "data",
"name": "StreamsGroupPartitionMetadataValue",
"validVersions": "0",
"flexibleVersions": "0+",
"fields": [
{ "name": "Topics", "versions": "0+", "type": "[]TopicMetadata",
"about": "The list of topic metadata.", "fields": [
{ "name": "TopicId", "versions": "0+", "type": "uuid",
"about": "The topic id." },
{ "name": "StreamsGroupPartitionMetadataValueTopicName",
"validVersionsversions": "0+",
"flexibleVersionstype": "0+string",
"fields "about": [
"The topic name." },
{ "name": "TopicsNumPartitions", "versions": "0+", "type": "[]TopicMetadataint32",
"about": "The number of listpartitions of the topic metadata.", "fields": [ },
{ "name": "TopicIdPartitionMetadata", "versions": "0+", "type": "uuid[]PartitionMetadata",
"about": "The topic id." },
Partitions mapped to a set of racks. If the rack information is unavailable for all the partitions, an empty list is stored", "fields": [
{ "name": "TopicNamePartition", "versions": "0+", "type": "stringint32",
"about": "The topicpartition namenumber." },
{ "name": "NumPartitionsRacks", "versions": "0+", "type": "int32[]string",
"about": "The numberset of partitionsracks ofthat the topic." }, partition is mapped to." }
]}
]}
{ "name ]
} |
StreamsGroupTopologyKey
| Code Block | ||||
|---|---|---|---|---|
| ||||
{ "type": "PartitionMetadatadata", "versionsname": "0+StreamsGroupTopologyKey", "typevalidVersions": "[]PartitionMetadata"TBD, "aboutflexibleVersions": "Partitions mapped to a set of racks. If the rack information is unavailable for all the partitions, an empty list is stored",none", "fields": [ { "name": "PartitionGroupId", "versionstype": "0+string", "typeversions": "int32"TBD, "about": "The partitiongroup numberid." }, ] } |
StreamsGroupTopologyValue
| Code Block | ||||
|---|---|---|---|---|
| ||||
{ { "type": "data", "name": "RacksStreamsGroupTopologyValue", "versionsvalidVersions": "0+", "typeflexibleVersions": "[]string0+", "fields": [ { "name": "Epoch", "type": "int32", "aboutversions": "The0+", set of racks that the partition is mapped to." } ]} "about": "The epoch of the topology. " }, ]} ] } |
StreamsGroupTopologyKey
| Code Block | ||||
|---|---|---|---|---|
| ||||
{ { "name": "Subtopologies", "type": "data[]Subtopology", "nameversions": "StreamsGroupTopologyKey0+", "validVersions": TBD, "flexibleVersionsabout": "noneThe sub-topologies of the streams application.", "fields": [ { "name": "GroupIdSubtopologyId", "type": "string", "versions": TBD"0+", "about": "The group idString to uniquely identify the subtopology." }, ] } |
StreamsGroupTopologyValue
| Code Block | ||||
|---|---|---|---|---|
| ||||
{ "type { "name": "dataSourceTopics", "nametype": "StreamsGroupTopologyValue[]string", "validVersionsversions": "0+", "flexibleVersions "about": "0+"The topics the topology reads from." }, "fields": [ { "name": "TopologyIdSourceTopicRegex", "type": "[]string", "versions": "0+", "about": "TheRegular expressions IDidentifying oftopics the topology.subtopology Must be non-empty. reads from." }, { "name": "TopologyStateChangelogTopics", "type": "[]SubtopologyTopicInfo", "versions": "0+", "about": "The sub-topologiesset of thestate streams application.", "fields": [changelog topics associated with this subtopology." }, { "name": "SubtopologyRepartitionSinkTopics", "type": "[]string", "versions": "0+", "about": "StringThe torepartition uniquelytopics identify the subtopology writes to." }, { "name": "SourceTopicsRepartitionSourceTopics", "type": "[]stringTopicInfo", "versions": "0+", "about": "The set of source topics the topology reads fromthat are internally created repartition topics." }, { "name": "SourceTopicRegexCopartitionGroups", "type": "string[]CopartitionGroup", "versions": "0+", "nullableVersions": "0+", "default": "null", "about": "TheA regularsubset expressionsof identifyingsource topics thethat topologymust readsbe fromcopartitioned. null if not provided." },", "fields": [ { "name": "StateChangelogTopicsSourceTopics", "type": "[]TopicInfoint16", "versions": "0+", "about": "The set of state changelog topics associated with this subtopology. topics the topology reads from. Index into the array on the subtopology level." }, { "name": "RepartitionSinkTopicsSourceTopicRegex", "type": "[]stringint16", "versions": "0+", "about": "TheRegular expressions repartitionidentifying topics the sub-topology writes to subtopology reads from. Index into the array on the subtopology level." }, { "name": "RepartitionSourceTopics", "type": "[]TopicInfoint16", "versions": "0+", "about": "The set of source topics that are internally created repartition topics. Index into the array on the subtopology level." } ] } ] } ], "commonStructs": [ { "name": "TopicConfig", "versions": "0+", "fields": [ { "name": "key", "type": "string", "versions": "0+", "about": "The key of the topic-level configuration." }, { "name": "value", "type": "string", "versions": "0+", "about": "The value of the topic-level configuration," } ] }, { "name": "TopicInfo", "versions": "0+", "fields": [ { "name": "Name", "type": "string", "versions": "0+", "about": "The name of the topic the topic." }, { "name": "Partitions", "type": "int32", "versions": "0+", "about": "The number of partitions in the topic. Can be 0 if no specific number of partitions is enforced. Always 0 for changelog topics." }, { "name": "PartitionsReplicationFactor", "type": "int32int16", "versions": "0+", "about": "The numberreplication factor of partitions in the topic. Can be 0 if nothe specificdefault numberreplication offactor partitionsshould isbe enforced. Always 0 for changelog topics.used." }, { "name": "TopicConfigs", "type": "[]TopicConfig", "versions": "0+", "nullableVersions": "0+", "default": "null", "about": "Topic-level configurations as key-value pairs." } ]} ] } |
...
For each member, there is a record to store the current member assignment. The record is first created when a member joins (with an empty assignment). Every time an assignment is computed for the member during reconciliation, it is compared to the previous assignment for the member. If the assignment changed, a new version of the current member assignment record is appended to the consumer offset topic. When the member leaves the group, a tombstone is written to remove the record.
Together with the assignment, we track the epoch at which an active task was assigned. This helps with offset commit validation: We allow offset commits for partitions that belong to tasks in all epochs since the assignment epoch of the task.
StreamsGroupCurrentMemberAssignmentKey
...
| Code Block | ||||
|---|---|---|---|---|
| ||||
{
"type": "data",
"name": "StreamsGroupCurrentMemberAssignmentValue",
"validVersions": "0",
"flexibleVersions": "0+",
"fields": [
{ "name": "MemberEpoch", "versions": "0+", "type": "int32",
"about": "The current member epoch that is expected from the member in the heartbeat request." },
{ "name": "PreviousMemberEpoch", "versions": "0+", "type": "int32",
"about": "If the last epoch bump is lost before reaching the member, the member will retry with the previous epoch." },
{ "name": "State", "versions": "0+", "type": "int8",
"about": "The member state. See StreamsGroupMember.MemberState for the possible values." },
{ "name": "ActiveTasks", "versions": "0+", "type": "[]TaskIds",
"about": "Currently assigned active tasks for this streams client." },
{ "name": "StandbyTasks", "versions": "0+", "type": "[]TaskIds",
"about": "Currently assigned standby tasks for this streams client." },
{ "name": "WarmupTasks", "versions": "0+", "type": "[]TaskIds",
"about": "Currently assigned warm-up tasks for this streams client." },
{ "name": "ActiveTasksPendingRevocation", "versions": "0+", "type": "[]TaskIds",
"about": "The active tasks that must be revoked by this member." }
],
"commonStructs": [
{ "name": "TaskIdsStandbyTasksPendingRevocation", "versions": "0+", "fieldstype": "[]TaskIds",
{ "nameabout": "Subtopology", "typeThe standby tasks that must be revoked by this member." },
{ "name": "stringWarmupTasksPendingRevocation", "versions": "0+",
"type": "[]TaskIds",
"about": "The subtopology identifierwarmup tasks that must be revoked by this member." }
],
"commonStructs": [
{ "name": "Partitions", "type": "[]int32"TaskIds", "versions": "0+",
"aboutfields": "The[
partitions of the input topics processed by this member." }
]}
]
} |
Streams Group Target Assignment
The target assignment is stored in N + 1 records, where N is the number of members in the group. When a new target assignment is computed, the group coordinator will compare it with the current target assignment and only write the difference between the two assignments to the __consumer_offsets partition. That also means if a member left the group, a corresponding tombstone record is written. The assignment must be atomic, so the group coordinator will ensure that all the records are written in a single batch, limiting the size to the maximum batch size (default 1MB), as in consumer groups.
StreamsGroupTargetAssignmentMemberKey
| Code Block | ||||
|---|---|---|---|---|
| ||||
{ "type": "data", "name": "StreamsGroupTargetAssignmentMemberKey", "validVersions": TBD, "flexibleVersions": "none", "fields": [ { "name": "SubtopologyId", "type": "string", "versions": "0+", "about": "The subtopology identifier." }, { "name": "Partitions", "type": "[]int32", "versions": "0+", "about": "The partitions of the input topics processed by this member." }, { "name": "AssignmentEpochs", "versions": "0+", "nullableVersions": "0+", "taggedVersions": "GroupId"0+", "tag": 0, "type": "string[]int32", "versionsdefault": TBDnull, "about": "The group id." }, { "name": "MemberId", "type": "string", "versions": TBD, "about": "The member id." epoch at which any partition was assigned to the member. Used to fence zombie commits requests. Of the same length as partitions. If null, all assignment epochs are considered to be equal to the member epoch." } ]} ] } |
...
Streams Group Target Assignment
The target assignment is stored in N + 1 records, where N is the number of members in the group. When a new target assignment is computed, the group coordinator will compare it with the current target assignment and only write the difference between the two assignments to the __consumer_offsets partition. That also means if a member left the group, a corresponding tombstone record is written. The assignment must be atomic, so the group coordinator will ensure that all the records are written in a single batch, limiting the size to the maximum batch size (default 1MB), as in consumer groups.
StreamsGroupTargetAssignmentMemberKey
| Code Block | ||||
|---|---|---|---|---|
| ||||
{ "type": "data", "name": "StreamsGroupTargetAssignmentMemberValue",{ "validVersionstype": "0data", "flexibleVersionsname": "0+StreamsGroupTargetAssignmentMemberKey", "fieldsvalidVersions": [TBD, { "nameflexibleVersions": "ActiveTasksnone", "versions": "0+", "type"fields": "[]TaskIds", "about": "Currently assigned active tasks for this streams client." }, { "name": "StandbyTasksGroupId", "versionstype": "0+string", "typeversions": "[]TaskIds"TBD, "about": "CurrentlyThe assigned standby tasks for this streams clientgroup id." }, { "name": "WarmupTasksMemberId", "versionstype": "0+string", "typeversions": "[]TaskIds"TBD, "about": "CurrentlyThe assigned warm-up tasks for this streams clientmember id." } ] } |
StreamsGroupTargetAssignmentMemberValue
| Code Block | ||||
|---|---|---|---|---|
| ||||
{ "type, "commonStructs": [ { "name": "TaskIds", "versions": "0+", "fields": [ { "name": "Subtopologydata", "typename": "stringStreamsGroupTargetAssignmentMemberValue", "versionsvalidVersions": "0+", "about"flexibleVersions": "The0+", subtopology identifier."fields": },[ { "name": "PartitionsActiveTasks", "typeversions": "[]int320+", "versionstype": "0+[]TaskIds", "about": "TheCurrently partitionsassigned ofactive thetasks inputfor topicsthis processed by this memberstreams client." }, ]} ] } |
StreamsGroupTargetAssignmentMetadataKey
| Code Block | ||||
|---|---|---|---|---|
| ||||
{
"typename": "dataStandbyTasks",
"nameversions": "StreamsGroupTargetAssignmentMetadataKey0+",
"validVersionstype": TBD"[]TaskIds",
"flexibleVersionsabout": "none",
"fields": [Currently assigned standby tasks for this streams client." },
{ "name": "GroupIdWarmupTasks", "typeversions": "string0+", "versionstype": TBD"[]TaskIds",
"about": "TheCurrently group id." }
]
} |
StreamsGroupTargetAssignmentMetadataValue
| Code Block | ||||
|---|---|---|---|---|
| ||||
{ "type": "data"assigned warm-up tasks for this streams client." } ], "namecommonStructs": "StreamsGroupTargetAssignmentMetadataValue",[ { "validVersionsname": "0TaskIds", "flexibleVersionsversions": "0+", "fields": [ { "name": "AssignmentEpochSubtopologyId", "versionstype": "0+string", "typeversions": "int320+", "about": "The assignmentsubtopology epochidentifier." }, ] } |
Broker Metrics
The existing group metrics are extended to differentiate between streams groups and consumer groups and account for streams group states.
Number of groups based on type of the protocol, where the list of protocols is extended by the
protocol=streamsvariation.
kafka.server:type=group-coordinator-metrics,name=group-count,protocol={consumer|classic|streams}
Number of streams groups based on state
kafka.server:type=group-coordinator-metrics,name=streams-group-count,state={empty|initializing|assigning|reconciling|stable|dead}
Streams group rebalances sensor
kafka.server:type=group-coordinator-metrics,name=streams-group-rebalance-rate
kafka.server:type=group-coordinator-metrics,name=streams-group-rebalance-count
Broker Configurations
The new group protocol would be guarded by enabling a new version of the group.version feature flag on the broker side.
Updated properties
Configuration | Description | Values |
|---|---|---|
| The list of enabled rebalance protocols. |
This will be added to the default value of this configuration property once this feature is complete. |
New properties
Name | Type | Default | Doc |
|---|---|---|---|
group.streams.session.timeout.ms | int | 45s | The timeout to detect client failures when using the streams group protocol. |
group.streams.min.session.timeout.ms | int | 45s | The minimum session timeout. |
group.streams.max.session.timeout.ms | int | 60s | The maximum session timeout. |
group.streams.heartbeat.interval.ms | int | 5s | The heartbeat interval given to the members. |
group.streams.min.heartbeat.interval.ms | int | 5s | The minimum heartbeat interval. |
group.streams.max.heartbeat.interval.ms | int | 15s | The maximum heartbeat interval. |
group.streams.max.size | int | MaxValue | The maximum number of streams clients that a single streams group can accommodate. |
group.streams.acceptable.recovery.lag | long | 10’000 | The maximum acceptable lag (number of offsets to catch up) for a client to be considered caught-up enough to receive an active task assignment. |
group.streams.num.warmup.replicas | int | 2 | The maximum number of warmup replicas. |
group.streams.max.warmup.replicas | int | 20 | Maximum for dynamic configurations of the warmup replica configuration |
group.streams.num.standby.replicas | int | 0 | The number of standby replicas for each task. |
group.streams.max.standby.replicas | int | 2 | Maximum for dynamic configurations of the standby replica configuration |
group.streams.task.offset.interval.ms | int | 60s | The interval in which the task changelog offsets on a client are updated on the broker. The offsets are sent with the next heartbeat after this time has passed. |
group.streams.min.task.offset.interval.ms | int | 15s | Minimum for dynamic configurations of the task offset interval. Used to restrict users of the cluster from sending the task changelog offsets too often. |
group.streams.assignor.name | string | null | The name of the task assignor used for all streams groups. Can be |
Group Configurations
We will add new configurations for the resource type GROUP in DescribeConfigs and IncrementalAlterConfigs to override the default broker configurations dynamically for specific groups.
{ "name": "Partitions", "type": "[]int32", "versions": "0+",
"about": "The partitions of the input topics processed by this member." }
]}
]
} |
StreamsGroupTargetAssignmentMetadataKey
| Code Block | ||||
|---|---|---|---|---|
| ||||
{
"type": "data",
"name": "StreamsGroupTargetAssignmentMetadataKey",
"validVersions": TBD,
"flexibleVersions": "none",
"fields": [
{ "name": "GroupId", "type": "string", "versions": TBD,
"about": "The group id." }
]
} |
StreamsGroupTargetAssignmentMetadataValue
| Code Block | ||||
|---|---|---|---|---|
| ||||
{
"type": "data",
"name": "StreamsGroupTargetAssignmentMetadataValue",
"validVersions": "0",
"flexibleVersions": "0+",
"fields": [
{ "name": "AssignmentEpoch", "versions": "0+", "type": "int32",
"about": "The assignment epoch." }
]
} |
Broker Metrics
The existing group metrics are extended to differentiate between streams groups and consumer groups and account for streams group states.
Number of groups based on type of the protocol, where the list of protocols is extended by the
protocol=streamsvariation.
kafka.server:type=group-coordinator-metrics,name=group-count,protocol={consumer|classic|streams}
Number of streams groups based on state
kafka.server:type=group-coordinator-metrics,name=streams-group-count,state={empty|not_ready|assigning|reconciling|stable|dead}Streams group rebalances sensor
kafka.server:type=group-coordinator-metrics,name=streams-group-rebalance-rate
kafka.server:type=group-coordinator-metrics,name=streams-group-rebalance-count
Broker Configurations
The new group protocol would be guarded by enabling a new version of the group.version feature flag on the broker side.
Updated properties
Configuration | Description | Values |
|---|---|---|
| The list of enabled rebalance protocols. |
This will be added to the default value of this configuration property once this feature is complete. |
New properties
Name | Type | Default | Doc | |
|---|---|---|---|---|
group.streams.session.timeout.ms | int | 45s | The timeout to detect client failures when using the streams group protocol. | |
group.streams.min.session.timeout.ms | int | 45s | The minimum session timeout. | |
group.streams.max.session.timeout.ms | int | 60s | The maximum session timeout. | |
group.streams.heartbeat.interval.ms | int | 5s | The heartbeat interval given to the members. | |
group.streams.min.heartbeat.interval.ms | int | 5s | The minimum heartbeat interval. | |
group.streams.max.heartbeat.interval.ms | int | 15s | The maximum heartbeat interval. | |
group.streams.max.size | int | MaxValue | The maximum number of streams clients that a single streams group can accommodate. | |
group.streams.acceptable.recovery.lag | long | 10’000 | The maximum acceptable lag (number of offsets to catch up) for a client to be considered caught-up enough to receive an active task assignment.. | |
group.streams.num.warmup.replicas | int | 2 | The maximum number of warmup replicas. | |
group.streams.max.warmup.replicas | int | 20 | Maximum for dynamic configurations of the warmup replica configuration | |
group.streams.num.warmupstandby.replicas | int | 20 | The maximum number of warmup standby replicas for each task. | |
group.streams.nummax.standby.replicas | int | 0 | 2 | Maximum for dynamic configurations of the standby replica configurationThe number of standby replicas for each task. |
group.streams.task.offset.interval.ms | int | 60s | The interval in which the task changelog offsets on a client are updated on the broker. The offsets are sent with the next heartbeat after this time has passed. | |
group.streams.min.task.offset.interval.ms | int | 15s | Minimum for dynamic configurations of the task offset interval. Used to restrict users of the cluster from sending the task changelog offsets too often. | |
group.streams.assignor.name | string | null | The name of the task assignor used for this all streams groups. Can be |
Streams API
In a future major version, when the classic group protocol will be deprecated, the interfaces introduced in KIP-924 would be deprecated, unless an integration with this KIP is proposed in a follow-up KIP.
Streams Configurations
New configurations
Name | Type | Default | Doc |
|---|---|---|---|
group.protocol | enum | classic | A flag which indicates if the new protocol should be used or not. It could be: classic or streams |
Deprecations
In a future major version, when the classic group protocol will be deprecated, the following configuration options will be deprecated:
acceptable.recovery.lag
max.warmup.replicas
num.standby.replicas
probing.rebalance.interval.ms
| |||
group.streams.initial.rebalance.delay.ms | int | 3000 | The first rebalance of a group is delayed by this amount to allow more members to join the group. |
group.streams.rack.aware.assignment.tags | string[] |
rack.aware.assignment.strategy
rack.aware.assignment.traffic_cost
rack.aware.assignment.non_overlap_cost
task.assignor.class
Note that both the rack-aware task assignor and customizable client-side task assignment may be introduced into the new protocol in follow-up KIPs (see Future Work section). In this case, the latter 5 configuration options would not be deprecated in the future major version.
Admin API
Add the following methods to the org.apache.kafka.client.admin.AdminClient interface, mostly backed by the same implementations as the consumer group API.
...
Method signature
...
Description
...
RPC used
...
empty list | The client tags used for rack aware standby task assignment. |
Group Configurations
We will add new configurations for the resource type GROUP in DescribeConfigs and IncrementalAlterConfigs to override the default broker configurations dynamically for specific groups.
Name | Type | Default |
|---|---|---|
streams.session.timeout.ms | int | 45s |
streams.heartbeat.interval.ms | int | 5s |
streams.acceptable.recovery.lag | long | 10’000 |
streams.num.warmup.replicas | int | 2 |
streams.num.standby.replicas | int | 0 |
streams.task.offset.interval.ms | int | 60s |
streams.assignor.name | string | null |
streams.initial.rebalance.delay.ms | int | 3000 |
streams.rack.aware.assignment.tags | string[] | empty list |
Streams API
In a future major version, when the classic group protocol will be deprecated, the interfaces introduced in KIP-924 would be deprecated, unless an integration with this KIP is proposed in a follow-up KIP.
Streams Configurations
New configurations
Name | Type | Default | Doc |
|---|---|---|---|
group.protocol | enum | classic | A flag which indicates if the new protocol should be used or not. It could be: classic or streams |
topology.epoch | int | 0 | The epoch of the topology for the streams group. Ignored if |
Deprecations
In a future major version, when the classic group protocol will be deprecated, the following configuration options will be deprecated:
acceptable.recovery.lag
max.warmup.replicas
num.standby.replicas
probing.rebalance.interval.ms
rack.aware.assignment.tags
rack.aware.assignment.strategy
rack.aware.assignment.traffic_cost
rack.aware.assignment.non_overlap_cost
task.assignor.class
Note that both the rack-aware task assignor and customizable client-side task assignment may be introduced into the new protocol in follow-up KIPs (see Future Work section). In this case, the latter 5 configuration options would not be deprecated in the future major version.
Admin API
Add the following methods to the org.apache.kafka.client.admin.AdminClient interface, mostly backed by the same implementations as the consumer group API.
Method signature | Description | RPC used |
|---|---|---|
AlterStreamsGroupOffsetsResult alterStreamsGroupOffsets(String groupId, Map<TopicPartition, Long> offsets) | Alter offset information for a streams group. | OffsetCommit |
AlterStreamsGroupOffsetsResult alterStreamsGroupOffsets(String groupId, Map<TopicPartition, Long> offsets, AlterStreamsGroupOffsetsOptions options) | Alter offset information for a streams group. | OffsetCommit |
DeleteStreamsGroupOffsetsResult deleteStreamsGroupOffsets(String groupId, Set<String> topics) | Delete offset information for a set of topics in a streams group. | OffsetDelete |
DeleteStreamsGroupOffsetsResult deleteStreamsGroupOffsets(String groupId, Set<String> topics, DeleteStreamsGroupOffsetsOptions options) | Delete offset information for a set of topics in a streams group. | OffsetDelete |
DeleteStreamsGroupResult deleteStreamsGroups(Collection<String> groupIds) | Delete streams groups from the cluster. | DeleteGroups |
DeleteStreamsGroupResult deleteStreamsGroups(Collection<String> groupIds, DeleteStreamsGroupOptions options) | Delete streams groups from the cluster. | DeleteGroups |
DescribeStreamsGroupsResult describeStreamsGroups(Collection<String> groupIds) | Describe some streams groups in the cluster. | StreamsGroupDescribe |
DescribeStreamsGroupsResult describeStreamsGroups(Collection<String> groupIds, DescribeStreamsGroupsOptions options) | Describe some streams groups in the cluster. | StreamsGroupDescribe |
ListStreamsGroupOffsetsResult listStreamsGroupOffsets(Map<String, ListStreamsGroupOffsetsSpec> groupSpecs) | List the streams group offsets available in the cluster for the specified Streams groups. | OffsetFetch |
ListStreamsGroupOffsetsResult listStreamsGroupOffsets(Map<String, ListStreamsGroupOffsetsSpec> groupSpecs, ListStreamsGroupOffsetsOptions options) | List the streams group offsets available in the cluster for the specified Streams groups. | OffsetFetch |
These correspond to existing APIs for consumer groups and some of the code will be shared. The main reason for duplicating them is the naming, as the current API uses "consumerGroup" in the name, despite the RPCs just using "group". There are some differences:
- The
describeStreamsGroupsuses the DescribeStreamsGroup RPC and contains other information than consumer groups. - A streams group has an extra state - NOT_READY, and no legacy states from the classic protocol.
removeMembersFromConsumerGroupwill not have a corresponding API in this first version, as it is using the LeaveGroup RPC for classic consumer groups, which is not available for KIP-848-style groups.
Admin
| Code Block | ||||||
|---|---|---|---|---|---|---|
| ||||||
|
These correspond to existing APIs for consumer groups and some of the code will be shared. The main reason for duplicating them is the naming, as the current API uses "consumerGroup" in the name, despite the RPCs just using "group". There are some differences:
- The
describeStreamsGroupsuses the DescribeStreamsGroup RPC and contains other information than consumer groups. - A streams group has an extra state - INITIALIZING, and no legacy states from the classic protocol.
removeMembersFromConsumerGroupwill not have a corresponding API in this first version, as it is using the LeaveGroup RPC for classic consumer groups, which is not available for KIP-848-style groups.
Admin
| Code Block | ||||||
|---|---|---|---|---|---|---|
| ||||||
/** * Alters offsets for the specified group. In order to succeed, the group must be empty. * * <p>This is a convenience method for {@link #alterStreamsGroupOffsets(String, Map, AlterStreamsGroupOffsetsOptions)} with default options. * See the overload for more details. * * @param groupId The group for which to alter offsets. * @param offsets A map of offsets by partition. * @return The AlterStreamsGroupOffsetsResult. */ default AlterStreamsGroupOffsetsResult alterStreamsGroupOffsets(String groupId, Map<TopicPartition, Long> offsets) { return alterStreamsGroupOffsets(groupId, offsets, new AlterStreamsGroupOffsetsOptions()); } /** * Alters offsets for the specified group. In order to succeed, the group must be empty. * * <p>This operation is not transactional so it may succeed for some partitions while fail for others. * * @param groupId The group for which to alter offsets. * @param offsets A map of offsets by partition. Partitions not specified in the map are ignored. * @param options The options to use when altering the offsets. * @return The AlterStreamsGroupOffsetsResult. */ AlterStreamsGroupOffsetsResult alterStreamsGroupOffsets(String groupId, Map<TopicPartition, Long> offsets, AlterStreamsGroupOffsetsOptions options); /** * DeleteAlters offsets for the aspecified setgroup. ofIn topicsorder into asucceed, Streamsthe group withmust thebe default optionsempty. * * <p>This is a convenience method for {@link #deleteStreamsGroupOffsets#alterStreamsGroupOffsets(String, SetMap, DeleteStreamsGroupOffsetsOptionsAlterStreamsGroupOffsetsOptions)} with default options. * See the overload for more details. * * @param groupId The group for which to deletealter offsets. * @param topics The topicsoffsets A map of offsets by partition. * @return The DeleteStreamsGroupOffsetsResultAlterStreamsGroupOffsetsResult. */ default DeleteStreamsGroupOffsetsResultAlterStreamsGroupOffsetsResult deleteStreamsGroupOffsetsalterStreamsGroupOffsets(String groupId, Map<TopicPartition, Set<String>Long> topicsoffsets) { return deleteStreamsGroupOffsetsalterStreamsGroupOffsets(groupId, topicsoffsets, new DeleteStreamsGroupOffsetsOptionsAlterStreamsGroupOffsetsOptions()); } /** * DeleteAlters offsets for a set of topics in a Streams group the specified group. In order to succeed, the group must be empty. * * <p>This operation is not transactional so it may succeed for some partitions while fail for others. * * @param groupId The group for which to deletealter offsets. * @param topics The topics offsets A map of offsets by partition. Partitions not specified in the map are ignored. * @param options The options to use when altering deletingthe offsets in a Streams group. * @return The DeleteStreamsGroupOffsetsResultAlterStreamsGroupOffsetsResult. */ DeleteStreamsGroupOffsetsResultAlterStreamsGroupOffsetsResult deleteStreamsGroupOffsetsalterStreamsGroupOffsets(String groupId, Map<TopicPartition, Set<String> topics, DeleteStreamsGroupOffsetsOptions Long> offsets, AlterStreamsGroupOffsetsOptions options); /** * Delete Streams groups from the clusteroffsets for a set of topics in a Streams group with the default options. * * <p>This is a convenience method for {@link #deleteStreamsGroups(Collection<String>#deleteStreamsGroupOffsets(String, Set, DeleteStreamsGroupsOptionsDeleteStreamsGroupOffsetsOptions)} with default options. * See the overload for more details. * * @param groupIdsgroupId The IDsgroup offor the groupswhich to delete offsets. * @param topics The topics. * @return The DeleteStreamsGroupsResultDeleteStreamsGroupOffsetsResult. */ default DeleteStreamsGroupsResultDeleteStreamsGroupOffsetsResult deleteStreamsGroups(Collection<String> groupIdsdeleteStreamsGroupOffsets(String groupId, Set<String> topics) { return deleteStreamsGroups(groupIdsdeleteStreamsGroupOffsets(groupId, topics, new DeleteStreamsGroupsOptionsDeleteStreamsGroupOffsetsOptions()); } /** * Delete offsets for a set of topics in a Streams groups from the cluster. *group. * * @param groupId The group for which to delete offsets. * @param groupIdstopics The IDs of the groups to deletetopics. * @param options The options to use when deleting offsets in a Streams group. * @return The DeleteStreamsGroupsResultDeleteStreamsGroupOffsetsResult. */ DeleteStreamsGroupsResultDeleteStreamsGroupOffsetsResult deleteStreamsGroupsdeleteStreamsGroupOffsets(Collection<String>String groupIds, DeleteStreamsGroupsOptionsgroupId, Set<String> topics, DeleteStreamsGroupOffsetsOptions options); /** * DescribeDelete some Streams groups infrom the cluster, with the default options. * * <p>This is a convenience method for {@link #describeStreamsGroups#deleteStreamsGroups(CollectionCollection<String>, DescribeStreamsGroupsOptionsDeleteStreamsGroupsOptions)} with default options. * with default options.* See the overload for more details. * * @param groupIds The IDs of the groups to describedelete. * @return The DescribeStreamsGroupsResultDeleteStreamsGroupsResult. */ default DescribeStreamsGroupsResultDeleteStreamsGroupsResult describeStreamsGroupsdeleteStreamsGroups(Collection<String> groupIds) { return describeStreamsGroupsdeleteStreamsGroups(groupIds, new DescribeStreamsGroupsOptionsDeleteStreamsGroupsOptions()); } /** * DescribeDelete some Streams groups infrom the cluster. * * @param groupIds The IDs of the groups to describedelete. * @param options The options to use when describingdeleting a theStreams groupsgroup. * @return The DescribeStreamsGroupsResultDeleteStreamsGroupsResult. */ DescribeStreamsGroupsResultDeleteStreamsGroupsResult describeStreamsGroupsdeleteStreamsGroups(Collection<String> groupIds, DescribeStreamsGroupsOptions DeleteStreamsGroupsOptions options); /** * ListDescribe thesome Streams groupgroups offsets available in the cluster for the specified Streams groups , with the default options. * * <p>This is a convenience method for {@link #listStreamsGroupOffsets#describeStreamsGroups(MapCollection, ListStreamsGroupOffsetsOptionsDescribeStreamsGroupsOptions)} * towith listdefault offsetsoptions. ofSee allthe partitionsoverload for the specified Streams groups with default optionsmore details. * * @param groupSpecsgroupIds Map of Streams group ids to a spec that specifies the topic partitions The IDs of the groupgroups to list offsets fordescribe. * @return The ListStreamsGroupOffsetsResultDescribeStreamsGroupsResult. */ default ListStreamsGroupOffsetsResultDescribeStreamsGroupsResult listStreamsGroupOffsetsdescribeStreamsGroups(Map<String, ListStreamsGroupOffsetsSpec> groupSpecsCollection<String> groupIds) { return listStreamsGroupOffsetsdescribeStreamsGroups(groupSpecsgroupIds, new ListStreamsGroupOffsetsOptionsDescribeStreamsGroupsOptions()); } /** * ListDescribe thesome Streams group offsets availablegroups in the cluster for the specified Streams. * * @param groupIds The IDs of the groups to describe. * @param options The options to use when describing the groups. * @return The DescribeStreamsGroupsResult. */ @param groupSpecs Map of Streams group ids to a spec that specifies the topic partitions of the group to list offsets for. DescribeStreamsGroupsResult describeStreamsGroups(Collection<String> groupIds, * @param options The options to use when listing the Streams group offsets. * @return The ListStreamsGroupOffsetsResult */ ListStreamsGroupOffsetsResult listStreamsGroupOffsets(Map<String, ListStreamsGroupOffsetsSpec> groupSpecs, ListStreamsGroupOffsetsOptionsDescribeStreamsGroupsOptions options); /** * List the Streams group groupsoffsets available in the cluster for the specified Streams groups with the default options. * * <p>This is a convenience method for {@link #listStreamsGroups(ListStreamsGroupsOptions#listStreamsGroupOffsets(Map, ListStreamsGroupOffsetsOptions)} * to list offsets of all partitions for the specified Streams groups with default options. * * See @param groupSpecs Map of Streams group ids to a spec that specifies the overloadtopic forpartitions moreof details. the group to list offsets *for. * @return The ListStreamsGroupsResult.ListStreamsGroupOffsetsResult */ default ListStreamsGroupsResultListStreamsGroupOffsetsResult listStreamsGroups(listStreamsGroupOffsets(Map<String, ListStreamsGroupOffsetsSpec> groupSpecs) { return listStreamsGroupslistStreamsGroupOffsets(groupSpecs, new ListStreamsGroupsOptionsListStreamsGroupOffsetsOptions()); } /** * List the Streams group offsets available in the cluster for the specified Streams groups available in the cluster. *. * * @param groupSpecs Map of Streams group ids to a spec that specifies the topic partitions of the group to list offsets for. * @param options The options to use when listing the Streams group groupsoffsets. * @return The ListStreamsGroupsResult.ListStreamsGroupOffsetsResult */ ListStreamsGroupsResultListStreamsGroupOffsetsResult listStreamsGroups(ListStreamsGroupsOptionslistStreamsGroupOffsets(Map<String, ListStreamsGroupOffsetsSpec> groupSpecs, ListStreamsGroupOffsetsOptions options); |
AlterStreamsGroupOffsetResult
...
| Code Block | ||||||
|---|---|---|---|---|---|---|
| ||||||
/**
* A detailed description of a single streams group in the cluster.
*/
public class StreamsGroupDescription {
public StreamsGroupDescription(
final String groupId,
final Stringint topologyIdgroupEpoch,
final Collection<StreamsGroupSubtopologyDescription>int subtopologiestargetAssignmentEpoch,
final Collection<StreamsGroupMemberDescription>int memberstopologyEpoch,
final StreamsGroupStateCollection<StreamsGroupSubtopologyDescription> statesubtopologies,
final NodeCollection<StreamsGroupMemberDescription> coordinatormembers,
final Set<AclOperation> authorizedOperations);
GroupState groupState,
/**
final *Node Thecoordinator,
id of the streams group.
final Set<AclOperation> */authorizedOperations
public String groupId();
/**
* The id of the currently used topology, or null if uninitializedstreams group.
*/
public String topologyIdgroupId();
/**
* A list of the members of the streams group.
*/
public Collection<StreamsGroupMemberDescription> members();
/**
* AThe listepoch of the subtopologies in the streamsconsumer group.
*/
public Collection<StreamsGroupSubtopologyDescription>int subtopologiesgroupEpoch();
/**
* The streams group state, or UNKNOWN if the state is* tooThe newepoch forof usthe totarget parseassignment.
*/
public StreamsGroupStateint statetargetAssignmentEpoch();
/**
* The streamsepoch group coordinator, or null if of the coordinatorcurrently isused not knowntopology.
*/
public Nodeint coordinatortopologyEpoch();
/**
* authorizedOperationsA forlist thisof group,the ormembers nullof ifthe that information is not knownstreams group.
*/
public Set<AclOperation>Collection<StreamsGroupMemberDescription> authorizedOperationsmembers();
} |
StreamsGroupMemberDescription
| Code Block | ||||||
|---|---|---|---|---|---|---|
| ||||||
/** * A detailed descriptionlist of athe single membersubtopologies in the streams group. */ public class StreamsGroupMemberDescription { */ public Collection<StreamsGroupSubtopologyDescription> StreamsGroupMemberDescriptionsubtopologies(); /** final* StringThe memberId,state of the streams group, or UNKNOWN if the finalstate Optional<String>is instanceId, too new for us to parse. final String clientId,*/ public final String clientHost, GroupState groupState(); /** final String* topologyId,The group coordinator, or null if the coordinator is final String processId,not known. */ final Map<String,public String> clientTags,Node coordinator(); /** final List<TaskOffset>* taskOffsets,authorizedOperations for this group, or null if that information finalis List<TaskOffset>not taskEndOffsets,known. */ finalpublic Set<AclOperation> authorizedOperations(); } |
StreamsGroupMemberDescription
| Code Block | ||||||
|---|---|---|---|---|---|---|
| ||||||
/** * A detailed description of a single member in the group. */ public class StreamsGroupMemberDescription { StreamsGroupMemberAssignment assignment, final Optional<StreamsGroupMemberAssignment> targetAssignment); /** * The id of the group member. public StreamsGroupMemberDescription( final String */memberId, public String memberId(); final int /**memberEpoch, * The id offinal theint instancecurrentAssignmentEpoch, used for static membership,final ifOptional<String> available.instanceId, */ publicfinal Optional<String> instanceId(); rackId, /** final String clientId, * The client id of thefinal groupString member.clientHost, */ final public String clientId(); int topologyEpoch, /** final *String TheprocessId, host of the group member. final Optional<Endpoint> */userEndpoint, public String clientHost(); final /** Map<String, String> clientTags, * The idfinal ofList<TaskOffset> thetaskOffsets, topology present on the client. final List<TaskOffset> */taskEndOffsets, public String topologyId(); final StreamsGroupMemberAssignment /**assignment, * Identity of thefinal streamsStreamsGroupMemberAssignment instancetargetAssignment, that may have multiple clients. final boolean */isClassic public String processId( ); /** * The Usedid forof rack-awarethe assignmentgroup algorithmmember. */ public Map<String, String> clientTagsString memberId(); /** * The Cumulativeepoch of offsetsthe forgroup tasksmember. */ public List<TaskOffset>int taskOffsetsmemberEpoch(); /** * The Cumulativeid taskof changelogthe endinstance, offsetsused for tasks static membership, if available. */ public List<TaskOffset>Optional<String> taskEndOffsetsinstanceId(); /** * The current assignmentrack ID of the group member. */ public StreamsGroupMemberAssignmentOptional<String> assignmentrackId(); /** * The target assignment client id of the group member. */ public Optional<StreamsGroupMemberAssignment>String targetAssignmentclientId(); /** * The cumulativehost offsetof forthe onegroup taskmember. */ public static class TaskOffset { public TaskOffset(final String subtopology, final int partition, final long offsetString clientHost(); /** * The subtopologyepoch identifier. of the group member. */ public Stringint subtopologymemberEpoch(); /** * The partitionepoch of the current taskassignment. */ public int partitioncurrentAssignmentEpoch(); /** * The cumulative offset (sum of offsets in all input partitions). epoch of the topology present on the client. */ public longint offsettopologyEpoch(); } } |
StreamsGroupMemberAssignment
| Code Block | ||||||
|---|---|---|---|---|---|---|
| ||||||
/** * A description of the* assignmentsIdentity of athe specific streams groupinstance member. */ public class StreamsGroupMemberAssignment { that may have multiple clients. public StreamsGroupMemberAssignment(*/ public String processId(); final List<TaskIds> activeTasks,/** * User-defined endpoint finalfor List<TaskIds>Interactive standbyTasks,Queries. */ final public List<TaskIds>Optional<Endpoint> warmupTasksuserEndpoint(); /** * ActiveUsed tasksfor forrack-aware thisassignment clientalgorithm. */ public List<TaskIds> activeTasksMap<String, String> clientTags(); /** * StandbyCumulative tasksoffsets for this clienttasks. */ public List<TaskIds>List<TaskOffset> standbyTaskstaskOffsets(); /** * Warmup tasks Cumulative task changelog end offsets for this clienttasks. */ public List<TaskIds>List<TaskOffset> warmupTaskstaskEndOffsets(); /** * AllThe taskscurrent forassignment. one subtopology of a member.*/ public */StreamsGroupMemberAssignment assignment(); /** public static* classThe TaskIdstarget {assignment. */ public TaskIds(final String subtopology, final List<Integer> partitions); StreamsGroupMemberAssignment targetAssignment(); /** * The flag indicating whether *a Themember sub-topologyis identifierclassic. */ public Stringboolean subtopologyisClassic(); /** /** The cumulative offset for one task. * The partitions*/ of the input topicspublic processedstatic byclass thisTaskOffset member.{ */ public List<Integer> partitions(); } } |
StreamsGroupSubtopologyDescription
| Code Block | ||||||
|---|---|---|---|---|---|---|
| ||||||
/** * A detailed description of a single subtopology */ public class StreamsGroupSubtopologyDescription { public StreamsGroupSubtopologyDescription(public TaskOffset(final String subtopologyId, final int partition, final long offset); /** * The subtopology identifier. */ finalpublic String subtopology,subtopologyId(); final List<String> sourceTopics, /** final* StringThe sourceTopicRegex,partition finalof List<String>the repartitionSinkTopics,task. final Map<String, TopicInfo> stateChangelogTopics, */ finalpublic Map<String, TopicInfo> repartitionSourceTopicsint partition(); /** * String to uniquely identify the subtopology The cumulative offset (sum of offsets in all input partitions). */ public Stringlong subtopologyoffset(); } } |
StreamsGroupMemberAssignment
| Code Block | ||||||
|---|---|---|---|---|---|---|
| ||||||
/** * A description of *the assignments Theof topicsa thespecific topologystreams readsgroup frommember. */ public class StreamsGroupMemberAssignment */{ public List<String> sourceTopicsStreamsGroupMemberAssignment(); /** final *List<TaskIds> activeTasks, The regular expressions identifying topics the topology readsfinal from. null if not provided. List<TaskIds> standbyTasks, */ final List<TaskIds> warmupTasks public String sourceTopicRegex(); /** * TheActive repartitiontasks topicsfor the topology writes tothis client. */ public List<String>List<TaskIds> repartitionSinkTopicsactiveTasks(); /** * The set of state changelog* topicsStandby associatedtasks withfor this sub-topologyclient. */ public Map<String, TopicInfo> stateChangelogTopicsList<TaskIds> standbyTasks(); /** * TheWarmup settasks offor source topics that are internally created repartition topicsthis client. */ public Map<String, TopicInfo> repartitionSourceTopicsList<TaskIds> warmupTasks(); /** * Information aboutAll tasks for one subtopology of a topicmember. */ public static class TopicInfoTaskIds { public TopicInfoTaskIds(final intString partitionssubtopologyId, final Map<String, String> topicConfigsList<Integer> partitions); /** * The number of partitions in the topicsubtopology identifier. */ public intString partitionssubtopologyId(); /** * ConfigurationsThe partitions of the topicinput topics processed by this member. */ public Map<String, String> topicConfigsList<Integer> partitions(); } } |
...
StreamsGroupSubtopologyDescription
| Code Block | ||||||
|---|---|---|---|---|---|---|
| ||||||
package org.apache.kafka.client.admin; /** * A detailed Optionsdescription forof {@link Admin#describeStreamsGroups(Collection<String>, DescribeStreamsGroupsOptions)}. * * The API of this class is evolving, see {@link Admin} for details. */ @InterfaceStability.Evolving public class DescribeStreamsGroupsOptions extends AbstractOptions<DescribeStreamsGroupsOptions> { public DescribeStreamsGroupsOptions includeAuthorizedOperations(boolean includeAuthorizedOperations); public boolean includeAuthorizedOperations(); } |
ListStreamsGroupOffsetsResult
| Code Block | ||||||
|---|---|---|---|---|---|---|
| ||||||
package org.apache.kafka.clients.admin; /** * The result of the {@link Admin#listStreamsGroupOffsets(Map<String, ListStreamsGroupOffsetsSpec>, ListStreamsGroupOffsetsOptions)} call. * <p> * The API of this class is evolving, see {@link Admin} for details. */ @InterfaceStability.Evolving public class ListStreamsGroupOffsetsResult {a single subtopology */ public class StreamsGroupSubtopologyDescription { public StreamsGroupSubtopologyDescription( final String subtopologyId, final List<String> sourceTopics, final List<String> repartitionSinkTopics, final Map<String, TopicInfo> stateChangelogTopics, final Map<String, TopicInfo> repartitionSourceTopics); /** * String to uniquely identify the subtopology. */ public String subtopologyId(); /** * ReturnThe atopics futurethe whichtopology yields all Map<String, Map<TopicPartition, Long> objects, if requests for all the groups succeedreads from. */ public KafkaFuture<Map<String, Map<TopicPartition, Long>>> allList<String> sourceTopics() { }; /** * ReturnThe arepartition futuretopics whichthe yieldstopology a map of topic partitions to offsets for the specified groupwrites to. */ public KafkaFuture<Map<TopicPartition, Long>> partitionsToOffset(String groupId) { } } |
ListStreamsGroupOffsetsOptions
| Code Block | ||||||
|---|---|---|---|---|---|---|
| ||||||
package org.apache.kafka.client.admin; List<String> repartitionSinkTopics(); /** * Options for {@link Admin#listStreamsGroupOffsets(Map<String, ListStreamsGroupOffsetsSpec>, ListStreamsGroupOffsetsOptions)}. * <p> * The API of this class is evolving, see {@link Admin} for details. */ @InterfaceStability.Evolving public class ListStreamsGroupOffsetsOptions extends AbstractOptions<ListStreamsGroupOffsetsOptions> { } |
ListStreamsGroupOffsetsSpec
| Code Block | ||||||
|---|---|---|---|---|---|---|
| ||||||
package org.apache.kafka.client.admin; /** * Specification of Streams group offsets to list using {@link Admin#listStreamsGroupOffsets(Map<String, ListStreamsGroupOffsetsSpec>, ListStreamsGroupOffsetsOptions)}. * <p> * The API of this class is evolving, see {@link Admin} for details. */ @InterfaceStability.Evolving public class ListStreamsGroupOffsetsSpec { public ListStreamsGroupOffsetsSpec(); /** * Set the topic partitions whose offsets are to be listed for a Streams group. * The set of state changelog topics associated with this subtopology. */ public Map<String, TopicInfo> stateChangelogTopics(); /** * The set of source topics that are internally created repartition topics. */ public Map<String, TopicInfo> repartitionSourceTopics(); /** * Information about a topic. */ public static class TopicInfo { public TopicInfo(final int partitions, final Map<String, String> topicConfigs); /** * The number of partitions in the topic. */ ListStreamsGroupOffsetsSpec topicPartitions(Collection<TopicPartition> topicPartitions); /** public int partitions(); /** * Configurations of the topic. * Returns the topic partitions whose offsets*/ are to be listed for a Streams group. public Map<String, */String> topicConfigs(); Collection<TopicPartition> topicPartitions(); } } |
...
DescribeStreamsGroupsOptions
| Code Block | ||||||
|---|---|---|---|---|---|---|
| ||||||
package org.apache.kafka.clientsclient.admin; /** * TheOptions result offor the {@link Admin#listStreamsGroups(ListStreamsGroupsOptionsAdmin#describeStreamsGroups(Collection<String>, DescribeStreamsGroupsOptions)} call. * <p> * The API of this class is evolving, see {@link Admin} for details. */ @InterfaceStability.Evolving public class ListStreamsGroupsResultDescribeStreamsGroupsOptions extends AbstractOptions<DescribeStreamsGroupsOptions> { public DescribeStreamsGroupsOptions /**includeAuthorizedOperations(boolean includeAuthorizedOperations); *public boolean includeAuthorizedOperations(); } |
ListStreamsGroupOffsetsResult
| Code Block | ||||||
|---|---|---|---|---|---|---|
| ||||||
package org.apache.kafka.clients.admin; /** * The result of the {@link Admin#listStreamsGroupOffsets(Map<String, ListStreamsGroupOffsetsSpec>, ListStreamsGroupOffsetsOptions)} call. * <p> * The API of this class is evolving, see {@link Admin} for details. */ @InterfaceStability.Evolving public class ListStreamsGroupOffsetsResult {Returns a future that yields either an exception, or the full set of Streams group listings. */ public KafkaFuture<Collection<StreamsGroupListing>> all() { } /** * ReturnsReturn a future which yields just all Map<String, Map<TopicPartition, Long> objects, if requests for all the validgroups listingssucceed. */ public KafkaFuture<Collection<StreamsGroupListing>> valid KafkaFuture<Map<String, Map<TopicPartition, Long>>> all() { } /** * ReturnsReturn a future which yields just a map of topic partitions to offsets for the errorsspecified which occurredgroup. */ public KafkaFuture<Collection<Throwable>> errors(KafkaFuture<Map<TopicPartition, Long>> partitionsToOffset(String groupId) { } } |
...
ListStreamsGroupOffsetsOptions
| Code Block | ||||||
|---|---|---|---|---|---|---|
| ||||||
package org.apache.kafka.client.admin; import org.apache.kafka.common.StreamsGroupState; /** * A listing of a Streams group in the cluster. * <p> * The API of this class is evolving, see {@link Admin} for details. */ @InterfaceStability.Evolving public class StreamsGroupListing { public StreamsGroupListing(String groupId); public StreamsGroupListing(String groupId, Optional<StreamsGroupState> state); package org.apache.kafka.client.admin; /** * TheOptions idfor of the Streams group{@link Admin#listStreamsGroupOffsets(Map<String, ListStreamsGroupOffsetsSpec>, ListStreamsGroupOffsetsOptions)}. * <p> */ The publicAPI String groupId(); /** * The Streams group state. */ public Optional<StreamsGroupState> state(); } |
...
of this class is evolving, see {@link Admin} for details.
*/
@InterfaceStability.Evolving
public class ListStreamsGroupOffsetsOptions extends AbstractOptions<ListStreamsGroupOffsetsOptions> {
} |
ListStreamsGroupOffsetsSpec
| Code Block | ||||||
|---|---|---|---|---|---|---|
| ||||||
package org.apache.kafka.client.admin; import org.apache.kafka.common.StreamsGroupState; /** * Options for Specification of Streams group offsets to list using {@link Admin#listStreamsGroups(ListStreamsGroupsOptionsAdmin#listStreamsGroupOffsets(Map<String, ListStreamsGroupOffsetsSpec>, ListStreamsGroupOffsetsOptions)}. * <p> * The API of this class is evolving, see {@link Admin} for details. */ @InterfaceStability.Evolving public class ListStreamsGroupOffsetsSpec ListStreamsGroupsOptions{ extends AbstractOptions<ListStreamsGroupsOptions> {public ListStreamsGroupOffsetsSpec(); /** * IfSet statesthe istopic set,partitions onlywhose groupsoffsets inare these statesto will be returned.listed Otherwise,for alla groupsStreams are returnedgroup. */ public ListStreamsGroupsOptionsListStreamsGroupOffsetsSpec inStatestopicPartitions(Set<StreamsGroupState>Collection<TopicPartition> statestopicPartitions); /** * ReturnReturns the listtopic ofpartitions Stateswhose thatoffsets are requestedto orbe emptylisted iffor noa states have been specifiedStreams group. */ public Set<StreamsGroupState> statesCollection<TopicPartition> topicPartitions(); } |
GroupType
Another case is added to the org.apache.kafka.common.GroupType enum:
Enum constant | Description |
|---|---|
StreamsSTREAMS("Streams") | Streams group |
StreamsGroupState
GroupState
Another case is added to theA new enum org.apache.kafka.common.StreamsGroupStateGroupState is addedenum:
Enum constant |
|---|
|
|
|
|
|
|
NOT_READY |
Exceptions
The following new exceptions are added to the org.apache.kafka.common.errors package, corresponding to the new error codes in the Kafka protocol.
StreamsInvalidTopologyStreamsInvalidTopologyException- The supplied topology is invalid. Returned if the client sends a topology that does not fulfill the expected invariants.StreamsMissingSourceTopics- There are source topics missing for a topology that is supposed to be initialized. Also returned if the source topic regular expression matched no topics.StreamsInconsistentInternalTopics- There are internal topics present on the broker that are not consistent with the internal topic requirements of the provided topology.
StreamsInvalidTopology is fatal, StreamsMissingSourceTopics and StreamsInconsistentInternalTopics are all subclasses of RetriableException.
Command-line tools
StreamsInvalidTopologyEpochException - The client provided a invalid topology epoch with respect to the stream group state, for example, the topology was changed by the epoch not bumped.StreamsTopologyFencedException - When a client attempts to join with an outdated topology epoch.
Command-line tools
kafka-groups.sh
We add an option --streams to the above commad-line tool, which filter the groups to show share groups. Furthermore streams becomes one of the possible values for --group-type .
kafka-streams-groups.sh
A new tool called kafka-streams-groups.sh is added for working with streams groups. It has the following options:
Option | Description |
|---|---|
--version | Display Kafka version. |
--verbose | Use with Use with Use with |
--all-all-input-topics | Use with --reset-offsets or --delete-offsets. If specified, includes all input topics of the streams group, as stored by the topology metadata on the broker. |
--input-topics topic <String: topics>topic> | Use with --reset-offsets or --delete-offsets. Comma-separated list of user input Defines a user input topic to be modified. Multiple such options can be used to define multiple topics. For these topics, the tool by default will reset the offset to the earliest available offset, or delete the offsets. Reset to other offset position by appending other reset offset option, ex: --input-topics topic foo --shift-by 5. |
--internal-topics <String: topics> | Use with --delete. Comma-separated list of internal topics to delete. Must be a subset of the internal topics marked for deletion by the default behaviour (do a dry-run without this option to view these topics). |
--to-offset <Long: offset> | Reset input topic offsets to a specific offset |
--to-latest | Reset input topic offsets to latest offset. |
--to-earliest | Reset input topic offsets to earliest offset. |
--by-duration <String: duration> | Reset input topic offsets to offset by duration from current timestamp. Format: 'PnDTnHnMnS' |
--to-datetime <String: datetime> | Reset input topic offsets to offset from datetime. Format: 'YYYY-MM-DDTHH:mm:SS.sss'. |
--from-file | Reset input topic offsets to values defined in CSV file. |
--shift-by <Long: n> | Reset input topic offsets shifting current offset by 'n', where 'n' can be positive or negative. |
--timeout <Long: timeout (ms)> | The timeout that can be set for some use cases. For example, it can be used when describing the group to specify the maximum amount of time in milliseconds to wait before the group stabilizes (when the group is just created, or is going through some changes). (default: 5000) |
--state [String] | When specified with '--describe', includes the state of the group. When specified with '--list', it displays the state of all groups. It can also be used to list groups with specific states. The valid values are 'Empty', 'InitializingNot Ready', 'Reconciling', 'Assigning', 'Stable' and 'Dead'. |
--reset-offsets | Reset input topic offsets of streams group. Supports one streams group at a time, and instances should be inactive. You must choose one of the following reset specifications: --to-datetime, --by-duration, --to-earliest, --to-latest, --shift-by, --from-file, --to-current, --to-offset. To define the scope use --all-input-topics or --input-topics. One scope must be specified unless you use '--from-file'. Fails if neither '--dry-run' nor '–execute--execute' is specified. |
--offsets | Describe the group and list all input topic partitions in the group along with their offset lag. This is the default sub-action of --describe and may be used with the '--describe' option only. |
--members | Describe members of the group. This option may be used with the '--describe' option only. |
--list | List all streams groups. |
--help | Print usage information. |
--group <String: streams group ID> | The group ID (application ID) of the streams ID we wish to act on. |
--all-groups | To act on all groups. Only allowed with --delete |
--execute | Execute operation. Supported operations: reset-offsets. |
--dry-run | Only show results without executing changes on streams groups. Supported operations: reset-offsets. |
--describe | Describe streams group and list offset lag (number of records not yet processed) related to given group. |
--delete-offsets | Delete offsets of streams group. Supports one streams group at the time. To define the scope use --all-input-topics or --input-topics. One scope must be specified unless you use '--from-file'. |
--delete | Pass in a group to delete entire streams group. For instance --group g1. Deletes offsets, internal topics of the streams group and and topology and ownership information on the broker. Instances should be inactive. |
--command-config <String: command config property file> | Property file containing configs to be passed to Admin Client. |
--bootstrap-server <String: server to connect to> | REQUIRED: The server(s) to connect to. |
...
KIP-848 originally envisioned that Kafka Streams continues to using a byte-array metadata protocol on top of regular consumer group RPCs, and use a client-side assignor, and provided a rough proposal how to do so. The described approach was never implemented. In this KIP, we propose to use broker-side assignment by default for several reasons (mostly already mentioned in the motivation section):
Client-side assignment makes it hard to debug and tune the assignment logic, where a simple parameter change requires redeploying of all streams clients.
Using opaque byte-arrays to exchange the required metadata makes it hard to understand the state of a streams group on the protocol level. One has to discover the information from logs spread across all client machines. Central mechanisms of the Kafka protocol, such as versioning of RPCs, needs to be reimplemented on the level of RPCs.
One could argue that the Kafka protocol is simpler without Kafka Streams specific RPCs, but we think the opposite is true. The KIP-848 consumer group protocol was extended with client-side assignment, byte-array metadata and metadata versioning just for Kafka Streams. Having the concerns of Kafka Streams dealt with in separate RPCs mainly introduces a clearer separation and gives the Kafka community the ability to simplify the upcoming consumer protocol.
Instead of using a separate initialize RPCthe heartbeat RPC during joining to initialize the topology, we considered just using the heartbeat with
memberEpoch=0to initialize the Streams group and initiate the creation of all topics. This would have a number of downsides, such as that every member needs to send the initialization data every time they start (and the initialization data may be large already in the current schema and may grow larger in the future), and the heartbeat requiring the ACL for creating topics. Furthermore, since the initialization may take a certain amount of time, we’d likely still have to respond to the initial heartbeat without having fully initialized the group, leading to temporary “initializing” state for the group that we also get in this proposala dedicated group intialization RPC. Using the heartbeat RPC for initialization turned out to be simpler and we realized that the drawbacks that we wanted to avoid with the dedicated initialization RPC where not that significant. For example, we thought that we could save on data sent for intitialization with a dedicated intialization call. However, sending the topology metadata in the heartbeat when joining does not seem to be too much and we can ensure all clients use the same topology metadata. Also with two different calls we had the overhead to coordinate the initialization and the heartbeat requests.An earlier draft of this KIP proposed introducing optional client-side task assignment, that would allow customization of the task assignment similar to KIP-924. We decided to remove it from this KIP, to limit the scope of the KIP and not introduce features in the protocol whose use we cannot fully envision yet. The RPCs defined in this KIP are, however, defined in a way that they could easily be extended with client-side assignment in a follow-up KIP, possibly together with a public interface for adding custom task assignors on the client side.
...
Topology updates
- Validate topology compatibility broker-sideIntroduce manually bumped topology versioning in addition to automatically managed topology IDs
Automatically drain repartition topics on a topology update
- In addition to the existing shutdown-flag, a global pause/resume functionality could be built on top of the protocol
There is an opportunity to improve EOSv2 in the new protocol. One may add the current transaction.id to the heartbeat request and a list of closing transactions.id that the client should fence in the heartbeat response to improve EOSv2 and avoid the need to rely on a low
transaction.timeout.msconfig.
...