use of org.apache.pulsar.common.policies.data.NonPersistentReplicatorStats in project incubator-pulsar by apache.
the class NonPersistentTopic method getStats.
public NonPersistentTopicStats getStats() {
NonPersistentTopicStats stats = new NonPersistentTopicStats();
ObjectObjectHashMap<String, PublisherStats> remotePublishersStats = new ObjectObjectHashMap<String, PublisherStats>();
producers.forEach(producer -> {
NonPersistentPublisherStats publisherStats = (NonPersistentPublisherStats) producer.getStats();
stats.msgRateIn += publisherStats.msgRateIn;
stats.msgThroughputIn += publisherStats.msgThroughputIn;
if (producer.isRemote()) {
remotePublishersStats.put(producer.getRemoteCluster(), publisherStats);
} else {
stats.getPublishers().add(publisherStats);
}
});
stats.averageMsgSize = stats.msgRateIn == 0.0 ? 0.0 : (stats.msgThroughputIn / stats.msgRateIn);
subscriptions.forEach((name, subscription) -> {
NonPersistentSubscriptionStats subStats = subscription.getStats();
stats.msgRateOut += subStats.msgRateOut;
stats.msgThroughputOut += subStats.msgThroughputOut;
stats.getSubscriptions().put(name, subStats);
});
replicators.forEach((cluster, replicator) -> {
NonPersistentReplicatorStats ReplicatorStats = replicator.getStats();
// Add incoming msg rates
PublisherStats pubStats = remotePublishersStats.get(replicator.getRemoteCluster());
if (pubStats != null) {
ReplicatorStats.msgRateIn = pubStats.msgRateIn;
ReplicatorStats.msgThroughputIn = pubStats.msgThroughputIn;
ReplicatorStats.inboundConnection = pubStats.address;
ReplicatorStats.inboundConnectedSince = pubStats.connectedSince;
}
stats.msgRateOut += ReplicatorStats.msgRateOut;
stats.msgThroughputOut += ReplicatorStats.msgThroughputOut;
stats.getReplication().put(replicator.getRemoteCluster(), ReplicatorStats);
});
return stats;
}
Aggregations