35
35
import org .apache .rocketmq .store .config .StorePathConfigHelper ;
36
36
import org .apache .rocketmq .store .logfile .MappedFile ;
37
37
import org .apache .rocketmq .store .queue .ConsumeQueueInterface ;
38
+ import org .apache .rocketmq .store .queue .ConsumeQueueStoreInterface ;
38
39
import org .apache .rocketmq .store .queue .CqUnit ;
39
40
import org .apache .rocketmq .store .queue .FileQueueLifeCycle ;
40
41
import org .apache .rocketmq .store .queue .MultiDispatchUtils ;
@@ -61,6 +62,7 @@ public class ConsumeQueue implements ConsumeQueueInterface, FileQueueLifeCycle {
61
62
private static final Logger LOG_ERROR = LoggerFactory .getLogger (LoggerName .STORE_ERROR_LOGGER_NAME );
62
63
63
64
private final MessageStore messageStore ;
65
+ private final ConsumeQueueStoreInterface consumeQueueStore ;
64
66
65
67
private final MappedFileQueue mappedFileQueue ;
66
68
private final String topic ;
@@ -83,9 +85,20 @@ public ConsumeQueue(
83
85
final String storePath ,
84
86
final int mappedFileSize ,
85
87
final MessageStore messageStore ) {
88
+ this (topic , queueId , storePath , mappedFileSize , messageStore , messageStore .getQueueStore ());
89
+ }
90
+
91
+ public ConsumeQueue (
92
+ final String topic ,
93
+ final int queueId ,
94
+ final String storePath ,
95
+ final int mappedFileSize ,
96
+ final MessageStore messageStore ,
97
+ final ConsumeQueueStoreInterface consumeQueueStore ) {
86
98
this .storePath = storePath ;
87
99
this .mappedFileSize = mappedFileSize ;
88
100
this .messageStore = messageStore ;
101
+ this .consumeQueueStore = consumeQueueStore ;
89
102
90
103
this .topic = topic ;
91
104
this .queueId = queueId ;
@@ -899,14 +912,14 @@ public CqUnit get(long offset) {
899
912
@ Override
900
913
public Pair <CqUnit , Long > getCqUnitAndStoreTime (long index ) {
901
914
CqUnit cqUnit = get (index );
902
- Long messageStoreTime = this .messageStore . getQueueStore () .getStoreTime (cqUnit );
915
+ Long messageStoreTime = this .consumeQueueStore .getStoreTime (cqUnit );
903
916
return new Pair <>(cqUnit , messageStoreTime );
904
917
}
905
918
906
919
@ Override
907
920
public Pair <CqUnit , Long > getEarliestUnitAndStoreTime () {
908
921
CqUnit cqUnit = getEarliestUnit ();
909
- Long messageStoreTime = this .messageStore . getQueueStore () .getStoreTime (cqUnit );
922
+ Long messageStoreTime = this .consumeQueueStore .getStoreTime (cqUnit );
910
923
return new Pair <>(cqUnit , messageStoreTime );
911
924
}
912
925
0 commit comments