@@ -67,7 +67,7 @@ import org.junit.jupiter.params.ParameterizedTest
67
67
import org .junit .jupiter .params .provider .{EnumSource , ValueSource }
68
68
import com .yammer .metrics .core .Gauge
69
69
import kafka .log .remote .RemoteLogManager
70
- import org .apache .kafka .common .config .AbstractConfig
70
+ import org .apache .kafka .common .config .{ AbstractConfig , TopicConfig }
71
71
import org .apache .kafka .raft .RaftConfig
72
72
import org .apache .kafka .server .log .remote .storage .{NoOpRemoteLogMetadataManager , NoOpRemoteStorageManager , RemoteLogManagerConfig }
73
73
import org .apache .kafka .server .util .timer .MockTimer
@@ -3118,7 +3118,8 @@ class ReplicaManagerTest {
3118
3118
isShuttingDown : AtomicBoolean = new AtomicBoolean (false ),
3119
3119
enableRemoteStorage : Boolean = false ,
3120
3120
shouldMockLog : Boolean = false ,
3121
- remoteLogManager : Option [RemoteLogManager ] = None
3121
+ remoteLogManager : Option [RemoteLogManager ] = None ,
3122
+ defaultTopicRemoteLogStorageEnable : Boolean = true
3122
3123
): ReplicaManager = {
3123
3124
val props = TestUtils .createBrokerConfig(brokerId, TestUtils .MockZkConnect )
3124
3125
val path1 = TestUtils .tempRelativeDir(" data" ).getAbsolutePath
@@ -3127,8 +3128,11 @@ class ReplicaManagerTest {
3127
3128
propsModifier.apply(props)
3128
3129
val config = KafkaConfig .fromProps(props)
3129
3130
val logProps = new Properties ()
3131
+ if (enableRemoteStorage && defaultTopicRemoteLogStorageEnable) {
3132
+ logProps.put(TopicConfig .REMOTE_LOG_STORAGE_ENABLE_CONFIG , " true" )
3133
+ }
3130
3134
val mockLog = setupMockLog(path1)
3131
- val mockLogMgr = TestUtils .createLogManager(config.logDirs.map(new File (_)), new LogConfig (logProps), log = if (shouldMockLog) Some (mockLog) else None )
3135
+ val mockLogMgr = TestUtils .createLogManager(config.logDirs.map(new File (_)), new LogConfig (logProps), log = if (shouldMockLog) Some (mockLog) else None , remoteStorageSystemEnable = enableRemoteStorage )
3132
3136
val aliveBrokers = aliveBrokerIds.map(brokerId => new Node (brokerId, s " host $brokerId" , brokerId))
3133
3137
3134
3138
val metadataCache : MetadataCache = mock(classOf [MetadataCache ])
@@ -5668,6 +5672,44 @@ class ReplicaManagerTest {
5668
5672
5669
5673
verify(spyRm).checkpointHighWatermarks()
5670
5674
}
5675
+
5676
+ @ Test
5677
+ def testNotCallStopPartitionsForNonTieredTopics (): Unit = {
5678
+ val mockTimer = new MockTimer (time)
5679
+ val replicaManager = setupReplicaManagerWithMockedPurgatories(mockTimer, aliveBrokerIds = Seq (0 , 1 ),
5680
+ enableRemoteStorage = true , defaultTopicRemoteLogStorageEnable = false )
5681
+
5682
+ try {
5683
+ val tp0 = new TopicPartition (topic, 0 )
5684
+ val offsetCheckpoints = new LazyOffsetCheckpoints (replicaManager.highWatermarkCheckpoints)
5685
+ val partition = replicaManager.createPartition(tp0)
5686
+ // The unified log created is not tiered because `defaultTopicRemoteLogStorageEnable` is set to false
5687
+ partition.createLogIfNotExists(isNew = false , isFutureReplica = false , offsetCheckpoints, None )
5688
+
5689
+ val leaderAndIsr = LeaderAndIsr (0 , 1 , List (0 , 1 ), LeaderRecoveryState .RECOVERED , LeaderAndIsr .InitialPartitionEpoch )
5690
+ val becomeLeaderRequest = makeLeaderAndIsrRequest(topicIds(tp0.topic), tp0, Seq (0 , 1 ), leaderAndIsr)
5691
+
5692
+ replicaManager.becomeLeaderOrFollower(1 , becomeLeaderRequest, (_, _) => ())
5693
+ verifyRLMOnLeadershipChange(Collections .singleton(partition), Collections .emptySet())
5694
+
5695
+ val requestLeaderEpoch = 1
5696
+ val deleteLocalLog = true
5697
+ val partitionStates = Map (tp0 -> new StopReplicaPartitionState ()
5698
+ .setPartitionIndex(tp0.partition)
5699
+ .setLeaderEpoch(requestLeaderEpoch)
5700
+ .setDeletePartition(deleteLocalLog)
5701
+ )
5702
+
5703
+ val (result, error) = replicaManager.stopReplicas(1 , 0 , 0 , partitionStates)
5704
+
5705
+ assertEquals(Errors .NONE , error)
5706
+ assertEquals(Map (tp0 -> Errors .NONE ), result)
5707
+ assertEquals(HostedPartition .None , replicaManager.getPartition(tp0))
5708
+ verifyNoMoreInteractions(mockRemoteLogManager)
5709
+ } finally {
5710
+ replicaManager.shutdown(checkpointHW = false )
5711
+ }
5712
+ }
5671
5713
}
5672
5714
5673
5715
class MockReplicaSelector extends ReplicaSelector {
0 commit comments