Search in sources :

Example 1 with NonPersistentReplicatorStats

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;
}
Also used : NonPersistentSubscriptionStats(org.apache.pulsar.common.policies.data.NonPersistentSubscriptionStats) NonPersistentReplicatorStats(org.apache.pulsar.common.policies.data.NonPersistentReplicatorStats) NonPersistentTopicStats(org.apache.pulsar.common.policies.data.NonPersistentTopicStats) NonPersistentPublisherStats(org.apache.pulsar.common.policies.data.NonPersistentPublisherStats) PublisherStats(org.apache.pulsar.common.policies.data.PublisherStats) NonPersistentPublisherStats(org.apache.pulsar.common.policies.data.NonPersistentPublisherStats) ObjectObjectHashMap(com.carrotsearch.hppc.ObjectObjectHashMap)

Aggregations

ObjectObjectHashMap (com.carrotsearch.hppc.ObjectObjectHashMap)1 NonPersistentPublisherStats (org.apache.pulsar.common.policies.data.NonPersistentPublisherStats)1 NonPersistentReplicatorStats (org.apache.pulsar.common.policies.data.NonPersistentReplicatorStats)1 NonPersistentSubscriptionStats (org.apache.pulsar.common.policies.data.NonPersistentSubscriptionStats)1 NonPersistentTopicStats (org.apache.pulsar.common.policies.data.NonPersistentTopicStats)1 PublisherStats (org.apache.pulsar.common.policies.data.PublisherStats)1