kamalcph commented on code in PR #21153:
URL: https://github.com/apache/kafka/pull/21153#discussion_r2621871367


##########
core/src/test/scala/kafka/server/LocalLeaderEndPointRemoteTest.scala:
##########
@@ -0,0 +1,88 @@
+/*
+ * 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 kafka.server
+
+import kafka.log.LogManager
+import kafka.utils.TestUtils
+import org.apache.kafka.common.config.TopicConfig
+import org.apache.kafka.common.protocol.Errors
+import org.apache.kafka.server.common.OffsetAndEpoch
+import org.apache.kafka.storage.internals.log.LogConfig
+import org.junit.jupiter.api.Assertions._
+import org.junit.jupiter.api.Test
+
+import java.io.File
+import java.util.Properties
+import scala.collection.Map
+import scala.jdk.CollectionConverters._
+
+class LocalLeaderEndPointRemoteTest extends LocalLeaderEndPointTestBase {

Review Comment:
   Why do we have to split the test? Can they be part of the existing 
LocalLeaderEndPointTest itself?



##########
core/src/main/scala/kafka/server/LocalLeaderEndPoint.scala:
##########
@@ -135,6 +135,35 @@ class LocalLeaderEndPoint(sourceBroker: BrokerEndPoint,
     new OffsetAndEpoch(localLogStartOffset, epoch.orElse(0))
   }
 
+  override def fetchEarliestPendingUploadOffset(topicPartition: 
TopicPartition, currentLeaderEpoch: Int): OffsetAndEpoch = {
+    val partition = replicaManager.getPartitionOrException(topicPartition)
+    val log = partition.localLogOrException
+
+    if (!log.remoteLogEnabled())
+      return new OffsetAndEpoch(-1L, -1)
+
+    val highestRemoteOffset = log.highestOffsetInRemoteStorage()
+
+    if (highestRemoteOffset == -1L) {
+      val localLogStartOffset = fetchEarliestLocalOffset(topicPartition, 
currentLeaderEpoch)
+      val logStartOffset = fetchEarliestOffset(topicPartition, 
currentLeaderEpoch)
+
+      if (localLogStartOffset.offset() == logStartOffset.offset()) {
+        // No segments have been uploaded yet
+        return logStartOffset;

Review Comment:
   can we refactor the code to avoid using multiple return statements? 
   
   https://tpolecat.github.io/2014/05/09/return.html
   
   



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to