chia7712 commented on code in PR #19630:
URL: https://github.com/apache/kafka/pull/19630#discussion_r2073124996


##########
server/src/main/java/org/apache/kafka/server/PartitionFetchState.java:
##########
@@ -0,0 +1,133 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+package org.apache.kafka.server;
+
+import org.apache.kafka.common.Uuid;
+import org.apache.kafka.common.utils.Time;
+
+import java.util.Optional;
+
+/**
+ * Class to keep partition offset and its state (truncatingLog, delayed)
+ * This represents a partition as being either:
+ * (1) Truncating its log, for example, having recently become a follower
+ * (2) Delayed, for example, due to an error, where we subsequently back off a 
bit
+ * (3) ReadyForFetch, the active state where the thread is actively fetching 
data.
+ */
+public class PartitionFetchState {
+    private final Optional<Uuid> topicId;
+    private final long fetchOffset;
+    private final Optional<Long> lag;
+    private final int currentLeaderEpoch;
+    private final Optional<Long> delay;
+    private final ReplicaState state;
+    private final Optional<Integer> lastFetchedEpoch;
+    private final Optional<Long> dueMs;
+
+
+    public static PartitionFetchState create(Optional<Uuid> topicId,

Review Comment:
   If we don't have specific naming for this creator, maybe we can convert it 
to be a constructor instead.



##########
core/src/main/java/kafka/server/TierStateMachine.java:
##########
@@ -95,7 +95,7 @@ public TierStateMachine(LeaderEndPoint leader,
     PartitionFetchState start(TopicPartition topicPartition,
                               PartitionFetchState currentFetchState,
                               PartitionData fetchPartitionData) throws 
Exception {
-        OffsetAndEpoch epochAndLeaderLocalStartOffset = 
leader.fetchEarliestLocalOffset(topicPartition, 
currentFetchState.currentLeaderEpoch());
+        OffsetAndEpoch epochAndLeaderLocalStartOffset = 
leader.fetchEarliestLocalOffset(topicPartition, 
currentFetchState.getCurrentLeaderEpoch());

Review Comment:
   Could you please consider using `currentLeaderEpoch`? it is more readable 
and it can reduce the changes?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to