|
16 | 16 | */
|
17 | 17 | package kafka.log.remote;
|
18 | 18 |
|
19 |
| -import kafka.cluster.Partition; |
20 | 19 | import kafka.server.KafkaConfig;
|
21 | 20 |
|
22 | 21 | import org.apache.kafka.common.Endpoint;
|
|
40 | 39 | import org.apache.kafka.server.common.OffsetAndEpoch;
|
41 | 40 | import org.apache.kafka.server.common.StopPartition;
|
42 | 41 | import org.apache.kafka.server.config.ServerConfigs;
|
| 42 | +import org.apache.kafka.server.log.remote.TopicPartitionLog; |
43 | 43 | import org.apache.kafka.server.log.remote.quota.RLMQuotaManager;
|
44 | 44 | import org.apache.kafka.server.log.remote.quota.RLMQuotaManagerConfig;
|
45 | 45 | import org.apache.kafka.server.log.remote.storage.ClassLoaderAwareRemoteStorageManager;
|
|
131 | 131 | import java.util.function.Supplier;
|
132 | 132 | import java.util.stream.Collectors;
|
133 | 133 |
|
134 |
| -import scala.Option; |
135 |
| - |
136 | 134 | import static kafka.log.remote.RemoteLogManager.isRemoteSegmentWithinLeaderEpochs;
|
137 | 135 | import static org.apache.kafka.common.record.TimestampType.CREATE_TIME;
|
138 | 136 | import static org.apache.kafka.server.log.remote.metadata.storage.TopicBasedRemoteLogMetadataManagerConfig.REMOTE_LOG_METADATA_COMMON_CLIENT_PREFIX;
|
@@ -857,8 +855,8 @@ void testRemoteLogManagerTasksAvgIdlePercentAndMetadataCountMetrics() throws Exc
|
857 | 855 | return null;
|
858 | 856 | }).when(remoteStorageManager).deleteLogSegmentData(any(RemoteLogSegmentMetadata.class));
|
859 | 857 |
|
860 |
| - Partition mockLeaderPartition = mockPartition(leaderTopicIdPartition); |
861 |
| - Partition mockFollowerPartition = mockPartition(followerTopicIdPartition); |
| 858 | + TopicPartitionLog mockLeaderPartition = mockPartition(leaderTopicIdPartition); |
| 859 | + TopicPartitionLog mockFollowerPartition = mockPartition(followerTopicIdPartition); |
862 | 860 | List<RemoteLogSegmentMetadata> list = listRemoteLogSegmentMetadata(leaderTopicIdPartition, segmentCount, 100, 1024, RemoteLogSegmentState.COPY_SEGMENT_FINISHED);
|
863 | 861 | // return the metadataList 3 times, then return empty list to simulate all segments are deleted
|
864 | 862 | when(remoteLogMetadataManager.listRemoteLogSegments(leaderTopicIdPartition)).thenReturn(list.iterator()).thenReturn(Collections.emptyIterator());
|
@@ -973,7 +971,7 @@ void testRemoteLogTaskUpdateRemoteLogSegmentMetadataAfterLogDirChanged() throws
|
973 | 971 | }).when(remoteStorageManager).copyLogSegmentData(any(RemoteLogSegmentMetadata.class), any(LogSegmentData.class));
|
974 | 972 | when(rlmCopyQuotaManager.getThrottleTimeMs()).thenReturn(quotaAvailableThrottleTime);
|
975 | 973 |
|
976 |
| - Partition mockLeaderPartition = mockPartition(leaderTopicIdPartition); |
| 974 | + TopicPartitionLog mockLeaderPartition = mockPartition(leaderTopicIdPartition); |
977 | 975 | List<RemoteLogSegmentMetadata> metadataList = listRemoteLogSegmentMetadata(leaderTopicIdPartition, segmentCount, 100, 1024, RemoteLogSegmentState.COPY_SEGMENT_FINISHED);
|
978 | 976 | when(remoteLogMetadataManager.listRemoteLogSegments(leaderTopicIdPartition)).thenReturn(metadataList.iterator());
|
979 | 977 | when(remoteLogMetadataManager.listRemoteLogSegments(leaderTopicIdPartition, 0)).thenReturn(metadataList.iterator()).thenReturn(metadataList.iterator());
|
@@ -1117,7 +1115,7 @@ void testRemoteLogManagerRemoteMetrics() throws Exception {
|
1117 | 1115 | }).when(remoteStorageManager).copyLogSegmentData(any(RemoteLogSegmentMetadata.class), any(LogSegmentData.class));
|
1118 | 1116 | when(rlmCopyQuotaManager.getThrottleTimeMs()).thenReturn(quotaAvailableThrottleTime);
|
1119 | 1117 |
|
1120 |
| - Partition mockLeaderPartition = mockPartition(leaderTopicIdPartition); |
| 1118 | + TopicPartitionLog mockLeaderPartition = mockPartition(leaderTopicIdPartition); |
1121 | 1119 |
|
1122 | 1120 | // This method is called by both Copy and Expiration task. On the first call, both tasks should see 175 bytes as
|
1123 | 1121 | // the local log segments size
|
@@ -1385,8 +1383,8 @@ private void verifyNotInCache(TopicIdPartition... topicIdPartitions) {
|
1385 | 1383 | @Test
|
1386 | 1384 | void testTopicIdCacheUpdates() throws RemoteStorageException {
|
1387 | 1385 | remoteLogManager.startup();
|
1388 |
| - Partition mockLeaderPartition = mockPartition(leaderTopicIdPartition); |
1389 |
| - Partition mockFollowerPartition = mockPartition(followerTopicIdPartition); |
| 1386 | + TopicPartitionLog mockLeaderPartition = mockPartition(leaderTopicIdPartition); |
| 1387 | + TopicPartitionLog mockFollowerPartition = mockPartition(followerTopicIdPartition); |
1390 | 1388 |
|
1391 | 1389 | when(remoteLogMetadataManager.remoteLogSegmentMetadata(any(TopicIdPartition.class), anyInt(), anyLong()))
|
1392 | 1390 | .thenReturn(Optional.empty());
|
@@ -1721,7 +1719,7 @@ void testFetchOffsetByTimestampWithTieredStorageDoesNotFetchIndexWhenExistsLocal
|
1721 | 1719 | // 9999 -> refers to read from local, 999 -> refers to read from remote
|
1722 | 1720 | FileRecords.TimestampAndOffset expectedLocalResult = new FileRecords.TimestampAndOffset(timestamp + 9999, 9999, Optional.of(Integer.MAX_VALUE));
|
1723 | 1721 | FileRecords.TimestampAndOffset expectedRemoteResult = new FileRecords.TimestampAndOffset(timestamp + 999, 999, Optional.of(Integer.MAX_VALUE));
|
1724 |
| - Partition mockFollowerPartition = mockPartition(tpId); |
| 1722 | + TopicPartitionLog mockFollowerPartition = mockPartition(tpId); |
1725 | 1723 |
|
1726 | 1724 | LogSegment logSegmentBaseOffset50 = mockLogSegment(50L, timestamp, null);
|
1727 | 1725 | LogSegment logSegmentBaseOffset100 = mockLogSegment(100L, timestamp + 1, expectedLocalResult);
|
@@ -3760,14 +3758,13 @@ private void appendRecordsToFile(File file, int nRecords, int nRecordsPerBatch)
|
3760 | 3758 | }
|
3761 | 3759 | }
|
3762 | 3760 |
|
3763 |
| - private Partition mockPartition(TopicIdPartition topicIdPartition) { |
| 3761 | + private TopicPartitionLog mockPartition(TopicIdPartition topicIdPartition) { |
3764 | 3762 | TopicPartition tp = topicIdPartition.topicPartition();
|
3765 |
| - Partition partition = mock(Partition.class); |
| 3763 | + TopicPartitionLog partition = mock(TopicPartitionLog.class); |
3766 | 3764 | UnifiedLog log = mock(UnifiedLog.class);
|
3767 | 3765 | when(partition.topicPartition()).thenReturn(tp);
|
3768 |
| - when(partition.topic()).thenReturn(tp.topic()); |
3769 | 3766 | when(log.remoteLogEnabled()).thenReturn(true);
|
3770 |
| - when(partition.log()).thenReturn(Option.apply(log)); |
| 3767 | + when(partition.unifiedLog()).thenReturn(Optional.of(log)); |
3771 | 3768 | when(log.config()).thenReturn(new LogConfig(new Properties()));
|
3772 | 3769 | return partition;
|
3773 | 3770 | }
|
|
0 commit comments