You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2019/04/30 04:27:40 UTC

[GitHub] [pulsar] murong00 commented on a change in pull request #4168: [Issue 4167] [pulsar-broker] Support to get the number of current messages

murong00 commented on a change in pull request #4168: [Issue 4167] [pulsar-broker] Support to get the number of current messages
URL: https://github.com/apache/pulsar/pull/4168#discussion_r279610590
 
 

 ##########
 File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java
 ##########
 @@ -1522,4 +1525,38 @@ protected MessageId internalGetLastMessageId(boolean authoritative) {
 
         return messageId;
     }
+
+    protected long internalGetMessageCount(boolean authoritative) {
+        validateAdminOperationOnTopic(authoritative);
+
+        if (!(getTopicReference(topicName) instanceof PersistentTopic)) {
+            log.error("[{}] Not supported operation of non-persistent topic {}", clientAppId(), topicName);
+            throw new RestException(Status.METHOD_NOT_ALLOWED,
+                "GetMessageCount on a non-persistent topic is not allowed");
+        }
+
+        Reader<byte[]> reader = null;
+        final AtomicLong count = new AtomicLong();
+
+        try {
+            reader = pulsar().getClient().newReader()
 
 Review comment:
   hum, forgive my simplicity, thanks for pointing out this and the advise. I'll try to find some time to look into the message metadata structure, does this need a PIP?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services