Skip to content

Commit c09095b

Browse files
committed
Remove topicId argument from isStrayReplica
1 parent ea2246a commit c09095b

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

core/src/main/scala/kafka/server/metadata/BrokerMetadataPublisher.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ class BrokerMetadataPublisher(
351351
true
352352
} else {
353353
val replicas = newImage.topics.partitionReplicas(log.topicId.get, log.topicPartition.partition)
354-
JLogManager.isStrayReplica(replicas, brokerId, log.topicId.get, log)
354+
JLogManager.isStrayReplica(replicas, brokerId, log)
355355
}
356356
}
357357
)

storage/src/main/java/org/apache/kafka/storage/internals/log/LogManager.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
*/
1717
package org.apache.kafka.storage.internals.log;
1818

19-
import org.apache.kafka.common.Uuid;
20-
2119
import org.slf4j.Logger;
2220
import org.slf4j.LoggerFactory;
2321

@@ -62,9 +60,9 @@ public static boolean waitForAllToComplete(List<Future<?>> jobs, Consumer<Throwa
6260
* @param log The log object to check
6361
* @return true if the log should not exist on the broker, false otherwise.
6462
*/
65-
public static boolean isStrayReplica(List<Integer> replicas, int brokerId, Uuid topicId, UnifiedLog log) {
63+
public static boolean isStrayReplica(List<Integer> replicas, int brokerId, UnifiedLog log) {
6664
if (replicas.isEmpty()) {
67-
LOG.info("Found stray log dir {}: the topicId {} does not exist in the metadata image.", log, topicId);
65+
LOG.info("Found stray log dir {}: the topicId {} does not exist in the metadata image.", log, log.topicId().get());
6866
return true;
6967
}
7068
if (!replicas.contains(brokerId)) {

storage/src/test/java/org/apache/kafka/storage/internals/log/LogManagerTest.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import org.junit.jupiter.api.Test;
2222

2323
import java.util.List;
24+
import java.util.Optional;
2425
import java.util.concurrent.ExecutionException;
2526
import java.util.concurrent.Future;
2627
import java.util.concurrent.atomic.AtomicInteger;
@@ -67,8 +68,9 @@ public void testWaitForAllToComplete() throws ExecutionException, InterruptedExc
6768
@Test
6869
public void testIsStrayReplica() {
6970
UnifiedLog log = mock(UnifiedLog.class);
70-
assertTrue(LogManager.isStrayReplica(List.of(), 0, Uuid.ONE_UUID, log));
71-
assertTrue(LogManager.isStrayReplica(List.of(1, 2, 3), 0, Uuid.ONE_UUID, log));
72-
assertFalse(LogManager.isStrayReplica(List.of(0, 1, 2), 0, Uuid.ONE_UUID, log));
71+
when(log.topicId()).thenReturn(Optional.of(Uuid.ONE_UUID));
72+
assertTrue(LogManager.isStrayReplica(List.of(), 0, log));
73+
assertTrue(LogManager.isStrayReplica(List.of(1, 2, 3), 0, log));
74+
assertFalse(LogManager.isStrayReplica(List.of(0, 1, 2), 0, log));
7375
}
7476
}

0 commit comments

Comments
 (0)