You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kafka.apache.org by da...@apache.org on 2021/02/12 15:39:57 UTC
[kafka] branch trunk updated: MINOR: Add FetchSnapshot API doc in
KafkaRaftClient (#10097)
This is an automated email from the ASF dual-hosted git repository.
davidarthur pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git
The following commit(s) were added to refs/heads/trunk by this push:
new 2c590de MINOR: Add FetchSnapshot API doc in KafkaRaftClient (#10097)
2c590de is described below
commit 2c590de54e626eda3be1bbbedf11126ec47cc450
Author: dengziming <sw...@163.com>
AuthorDate: Fri Feb 12 23:38:10 2021 +0800
MINOR: Add FetchSnapshot API doc in KafkaRaftClient (#10097)
---
.../main/java/org/apache/kafka/raft/KafkaRaftClient.java | 15 +++++++++++----
.../main/java/org/apache/kafka/raft/NetworkChannel.java | 7 +++----
.../main/java/org/apache/kafka/raft/ReplicatedLog.java | 2 +-
3 files changed, 15 insertions(+), 9 deletions(-)
diff --git a/raft/src/main/java/org/apache/kafka/raft/KafkaRaftClient.java b/raft/src/main/java/org/apache/kafka/raft/KafkaRaftClient.java
index 09f8672..9b6eb57 100644
--- a/raft/src/main/java/org/apache/kafka/raft/KafkaRaftClient.java
+++ b/raft/src/main/java/org/apache/kafka/raft/KafkaRaftClient.java
@@ -126,9 +126,16 @@ import static org.apache.kafka.raft.RaftUtil.hasValidTopicPartition;
* gracefully resign from the current epoch. This causes remaining voters to immediately
* begin a new election.
*
- * 4) {@link FetchRequestData}: This is the same as the usual Fetch API in Kafka, but we piggyback
- * some additional metadata on responses (i.e. current leader and epoch). Unlike partition replication,
- * we also piggyback truncation detection on this API rather than through a separate truncation state.
+ * 4) {@link FetchRequestData}: This is the same as the usual Fetch API in Kafka, but we add snapshot
+ * check before responding, and we also piggyback some additional metadata on responses (i.e. current
+ * leader and epoch). Unlike partition replication, we also piggyback truncation detection on this API
+ * rather than through a separate truncation state.
+ *
+ * 5) {@link FetchSnapshotRequestData}: Sent by the follower to the epoch leader in order to fetch a snapshot.
+ * This happens when a FetchResponse includes a snapshot ID due to the follower's log end offset being less
+ * than the leader's log start offset. This API is similar to the Fetch API since the snapshot is stored
+ * as FileRecords, but we use {@link UnalignedRecords} in FetchSnapshotResponse because the records
+ * are not necessarily offset-aligned.
*
*/
public class KafkaRaftClient<T> implements RaftClient<T> {
@@ -1359,7 +1366,7 @@ public class KafkaRaftClient<T> implements RaftClient<T> {
} else {
throw new IllegalStateException(
String.format(
- "Full log trunctation expected but didn't happen. Snapshot of %s, log end offset %s, last fetched %s",
+ "Full log truncation expected but didn't happen. Snapshot of %s, log end offset %s, last fetched %s",
snapshot.snapshotId(),
log.endOffset(),
log.lastFetchedEpoch()
diff --git a/raft/src/main/java/org/apache/kafka/raft/NetworkChannel.java b/raft/src/main/java/org/apache/kafka/raft/NetworkChannel.java
index b88241b..f023955 100644
--- a/raft/src/main/java/org/apache/kafka/raft/NetworkChannel.java
+++ b/raft/src/main/java/org/apache/kafka/raft/NetworkChannel.java
@@ -30,10 +30,9 @@ public interface NetworkChannel extends Closeable {
int newCorrelationId();
/**
- * Send an outbound message. This could be either an outbound request
- * (i.e. an instance of {@link org.apache.kafka.raft.RaftRequest.Outbound})
- * or a response to a request that was received through {@link #receive(long)}
- * (i.e. an instance of {@link org.apache.kafka.raft.RaftResponse.Outbound}).
+ * Send an outbound request message.
+ *
+ * @param request outbound request to send
*/
void send(RaftRequest.Outbound request);
diff --git a/raft/src/main/java/org/apache/kafka/raft/ReplicatedLog.java b/raft/src/main/java/org/apache/kafka/raft/ReplicatedLog.java
index 714135d..417b769 100644
--- a/raft/src/main/java/org/apache/kafka/raft/ReplicatedLog.java
+++ b/raft/src/main/java/org/apache/kafka/raft/ReplicatedLog.java
@@ -264,7 +264,7 @@ public interface ReplicatedLog extends Closeable {
Optional<OffsetAndEpoch> oldestSnapshotId();
/**
- * Notifies the replicted log when a new snapshot is available.
+ * Notifies the replicated log when a new snapshot is available.
*/
void onSnapshotFrozen(OffsetAndEpoch snapshotId);