Implementation:Apache Kafka CoordinatorRuntime ScheduleLoadOperation
| Knowledge Sources | |
|---|---|
| Domains | Distributed_Systems, Coordinator_Framework |
| Last Updated | 2026-02-09 12:00 GMT |
Overview
Concrete tool for scheduling coordinator partition loading provided by the CoordinatorRuntime framework.
Description
The scheduleLoadOperation method on CoordinatorRuntime creates or reuses a CoordinatorContext for the given topic-partition and initiates state loading. It schedules an internal operation that checks the partition epoch, transitions the state to LOADING if appropriate, and triggers the CoordinatorLoaderImpl to replay records from the partition log.
Usage
Called by the Kafka server when a broker becomes the leader for a coordinator topic-partition (e.g., __consumer_offsets or __share_group_state).
Code Reference
Source Location
- Repository: Apache Kafka
- File: coordinator-common/src/main/java/org/apache/kafka/coordinator/common/runtime/CoordinatorRuntime.java
- Lines: L2267-2311
Signature
public void scheduleLoadOperation(
TopicPartition tp,
int partitionEpoch
)
Import
import org.apache.kafka.coordinator.common.runtime.CoordinatorRuntime;
import org.apache.kafka.common.TopicPartition;
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| tp | TopicPartition | Yes | The coordinator's topic-partition |
| partitionEpoch | int | Yes | The leader epoch of the partition |
Outputs
| Name | Type | Description |
|---|---|---|
| CoordinatorContext | internal | Created or reused context for the partition |
| State transition | void | Context transitions to LOADING state |
Usage Examples
// Called when broker becomes leader for __consumer_offsets-0
coordinatorRuntime.scheduleLoadOperation(
new TopicPartition("__consumer_offsets", 0),
42 // leader epoch
);