LetLetMe commented on code in PR #8600:
URL: https://github.com/apache/rocketmq/pull/8600#discussion_r1751294150


##########
broker/src/main/java/org/apache/rocketmq/broker/processor/AdminBrokerProcessor.java:
##########
@@ -458,6 +464,79 @@ private RemotingCommand 
updateAndGetGroupForbidden(ChannelHandlerContext ctx, Re
         return response;
     }
 
+    private RemotingCommand diffConsumeQueue(ChannelHandlerContext ctx, 
RemotingCommand request) {
+        final RemotingCommand response = 
RemotingCommand.createResponseCommand(null);
+        response.setCode(ResponseCode.SUCCESS);
+        response.setBody(JSON.toJSONBytes(ImmutableMap.of("diffResult", "diff 
success, very good!")));
+
+        DefaultMessageStore messageStore = (DefaultMessageStore) 
brokerController.getMessageStore();
+        RocksDBMessageStore rocksDBMessageStore = 
messageStore.getRocksDBMessageStore();
+
+        if (!messageStore.getMessageStoreConfig().isRocksdbCQWriteEnable()) {
+            response.setBody(JSON.toJSONBytes(ImmutableMap.of("diffResult", 
"RocksdbCQWriteEnable is false, diffConsumeQueue is invalid")));
+            return response;
+        }
+
+        ConcurrentMap<String, ConcurrentMap<Integer, ConsumeQueueInterface>> 
cqTable = messageStore.getConsumeQueueTable();
+        Random random = new Random();
+        for (Map.Entry<String, ConcurrentMap<Integer, ConsumeQueueInterface>> 
topicToCqListEntry : cqTable.entrySet()) {
+            String topic = topicToCqListEntry.getKey();
+            ConcurrentMap<Integer, ConsumeQueueInterface> queueIdToCqMap = 
topicToCqListEntry.getValue();
+            for (Map.Entry<Integer, ConsumeQueueInterface> queueIdToCqEntry : 
queueIdToCqMap.entrySet()) {
+                Integer queueId = queueIdToCqEntry.getKey();
+
+                ConsumeQueueInterface jsonCq = queueIdToCqEntry.getValue();
+                ConsumeQueueInterface kvCq = 
rocksDBMessageStore.getConsumeQueue(topic, queueId);
+
+                CqUnit kvCqEarliestUnit = kvCq.getEarliestUnit();
+                CqUnit kvCqLatestUnit = kvCq.getLatestUnit();
+                CqUnit jsonCqEarliestUnit = jsonCq.getEarliestUnit();
+                CqUnit jsonCqLatestUnit = jsonCq.getLatestUnit();
+                LOGGER.info("diffConsumeQueue topic:{}, queue:{}, 
kvCqEarliestUnit:{}, jsonCqEarliestUnit:{}, kvCqLatestUnit:{}, 
jsonCqLatestUnit:{}",
+                    topic, queueId, kvCqEarliestUnit, jsonCqEarliestUnit, 
kvCqLatestUnit, jsonCqLatestUnit);
+
+                long jsonOffset = jsonCq.getMaxOffsetInQueue() - 1;
+                int sampleCount = 10;
+
+                Set<Long> sampledOffsets = new HashSet<>();
+
+                if (jsonOffset > 100) {

Review Comment:
   已改,现在是全量对比



-- 
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