Implementation:Apache Kafka CoordinatorRuntime ScheduleWriteOperation
Appearance
| Knowledge Sources | |
|---|---|
| Domains | Distributed_Systems, State_Management |
| Last Updated | 2026-02-09 12:00 GMT |
Overview
Concrete tool for scheduling coordinator state mutations provided by the CoordinatorRuntime framework.
Description
The scheduleWriteOperation method creates a CoordinatorWriteEvent and enqueues it for processing. The event executes the write operation lambda, serializes the generated records, appends them to the partition via PartitionWriter, and completes the returned future when the records are committed.
Usage
Called by coordinator service implementations (e.g., GroupCoordinatorService, ShareCoordinatorService) to enqueue state mutations.
Code Reference
Source Location
- Repository: Apache Kafka
- File: coordinator-common/src/main/java/org/apache/kafka/coordinator/common/runtime/CoordinatorRuntime.java
- Lines: L2070-2080
Signature
public <T> CompletableFuture<T> scheduleWriteOperation(
String name,
TopicPartition tp,
CoordinatorWriteOperation<S, T, U> op
)
Import
import org.apache.kafka.coordinator.common.runtime.CoordinatorRuntime;
import org.apache.kafka.common.TopicPartition;
import java.util.concurrent.CompletableFuture;
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| name | String | Yes | Operation name for logging |
| tp | TopicPartition | Yes | The coordinator's topic-partition |
| op | CoordinatorWriteOperation<S, T, U> | Yes | Lambda that generates records from coordinator state |
Outputs
| Name | Type | Description |
|---|---|---|
| CompletableFuture<T> | future | Completes with operation result when records are committed |
Usage Examples
CompletableFuture<Void> future = coordinatorRuntime.scheduleWriteOperation(
"JoinGroup",
new TopicPartition("__consumer_offsets", 0),
(coordinator) -> {
// Generate records for group join
List<CoordinatorRecord> records = coordinator.handleJoinGroup(request);
return new CoordinatorResult<>(records, null);
}
);
Related Pages
Implements Principle
Page Connections
Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment