[improve][stats] Add ownerBroker field to topic stats #17136
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
Add a new field named
ownerBrokerto topic stats. This is the hostname and port of the broker owning the topic, separated by a colon. This is the same name as the ephemeral node registered under/loadbalance/brokers/on ZooKeeper.{ "msgRateIn" : 0.0, "msgThroughputIn" : 0.0, "msgRateOut" : 0.0, "msgThroughputOut" : 0.0, ... "compaction" : { "lastCompactionRemovedEventCount" : 0, "lastCompactionSucceedTimestamp" : 0, "lastCompactionFailedTimestamp" : 0, "lastCompactionDurationTimeInMills" : 0 }, "ownerBroker" : "localhost:8080" }This is useful to know which broker owns the topic.
Modifications
Added a method
getLookupServiceAddress()to thePulsarServiceclass. This method returns a string consisting of the advertised address and web service port separated by a colon. TheasyncGetStats()method ofPersistentTopicandNonPersistentTopicsets the string returned fromPulsarService#getLookupServiceAddress()to stats.Verifying this change
Documentation
doc