Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
export broker bundles data
Browse files Browse the repository at this point in the history
gavingaozhangmin committed Oct 14, 2021

Verified

This commit was signed with the committer’s verified signature.
frostming Frost Ming
1 parent c1954e8 commit d9d54e5
Showing 1 changed file with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -916,6 +916,7 @@ public LocalBrokerData updateLocalBrokerData() {
final SystemResourceUsage systemResourceUsage = LoadManagerShared.getSystemResourceUsage(brokerHostUsage);
localData.update(systemResourceUsage, getBundleStats());
updateLoadBalancingMetrics(systemResourceUsage);
updateLoadBalancingBundlesMetrics(getBundleStats());
} catch (Exception e) {
log.warn("Error when attempting to update local broker data", e);
if (e instanceof ConcurrentModificationException) {
@@ -927,6 +928,33 @@ public LocalBrokerData updateLocalBrokerData() {
return localData;
}

/**
* As any broker, update its bundle metrics.
*
* @param bundlesData
*/
private void updateLoadBalancingBundlesMetrics(Map<String, NamespaceBundleStats> bundlesData) {
List<Metrics> metrics = Lists.newArrayList();
for (Map.Entry<String, NamespaceBundleStats> entry: bundlesData.entrySet()) {
final String bundle = entry.getKey();
final NamespaceBundleStats stats = entry.getValue();
Map<String, String> dimensions = new HashMap<>();
dimensions.put("broker", ServiceConfigurationUtils.getAppliedAdvertisedAddress(conf, true));
dimensions.put("bundle", bundle);
dimensions.put("metric", "loadBalancing");
Metrics m = Metrics.create(dimensions);
m.put("brk_bundle_msg_rate_in", stats.msgRateIn);
m.put("brk_bundle_msg_rate_out", stats.msgRateOut);
m.put("brk_bundle_topics_count", stats.topics);
m.put("brk_bundle_consumer_count", stats.consumerCount);
m.put("brk_bundle_producer_count", stats.producerCount);
m.put("brk_bundle_msg_throughput_in", stats.msgThroughputIn);
m.put("brk_bundle_msg_throughput_out", stats.msgThroughputOut);
metrics.add(m);
}
this.loadBalancingMetrics.set(metrics);
}

/**
* As any broker, update System Resource Usage Percentage.
*

0 comments on commit d9d54e5

Please sign in to comment.