Search in sources :

Example 6 with PublisherStats

use of org.apache.pulsar.common.policies.data.PublisherStats in project incubator-pulsar by apache.

the class PersistentTopic method getStats.

public PersistentTopicStats getStats() {
    PersistentTopicStats stats = new PersistentTopicStats();
    ObjectObjectHashMap<String, PublisherStats> remotePublishersStats = new ObjectObjectHashMap<String, PublisherStats>();
    producers.forEach(producer -> {
        PublisherStats publisherStats = producer.getStats();
        stats.msgRateIn += publisherStats.msgRateIn;
        stats.msgThroughputIn += publisherStats.msgThroughputIn;
        if (producer.isRemote()) {
            remotePublishersStats.put(producer.getRemoteCluster(), publisherStats);
        } else {
            stats.publishers.add(publisherStats);
        }
    });
    stats.averageMsgSize = stats.msgRateIn == 0.0 ? 0.0 : (stats.msgThroughputIn / stats.msgRateIn);
    subscriptions.forEach((name, subscription) -> {
        SubscriptionStats subStats = subscription.getStats();
        stats.msgRateOut += subStats.msgRateOut;
        stats.msgThroughputOut += subStats.msgThroughputOut;
        stats.subscriptions.put(name, subStats);
    });
    replicators.forEach((cluster, replicator) -> {
        ReplicatorStats 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.replication.put(replicator.getRemoteCluster(), replicatorStats);
    });
    stats.storageSize = ledger.getEstimatedBacklogSize();
    stats.deduplicationStatus = messageDeduplication.getStatus().toString();
    return stats;
}
Also used : SubscriptionStats(org.apache.pulsar.common.policies.data.SubscriptionStats) PublisherStats(org.apache.pulsar.common.policies.data.PublisherStats) ReplicatorStats(org.apache.pulsar.common.policies.data.ReplicatorStats) PersistentTopicStats(org.apache.pulsar.common.policies.data.PersistentTopicStats) ObjectObjectHashMap(com.carrotsearch.hppc.ObjectObjectHashMap)

Aggregations

PublisherStats (org.apache.pulsar.common.policies.data.PublisherStats)6 ReplicatorStats (org.apache.pulsar.common.policies.data.ReplicatorStats)4 PersistentTopicStats (org.apache.pulsar.common.policies.data.PersistentTopicStats)3 SubscriptionStats (org.apache.pulsar.common.policies.data.SubscriptionStats)3 ObjectObjectHashMap (com.carrotsearch.hppc.ObjectObjectHashMap)2 BrokerServiceException (org.apache.pulsar.broker.service.BrokerServiceException)2 ConsumerBusyException (org.apache.pulsar.broker.service.BrokerServiceException.ConsumerBusyException)2 NamingException (org.apache.pulsar.broker.service.BrokerServiceException.NamingException)2 NotAllowedException (org.apache.pulsar.broker.service.BrokerServiceException.NotAllowedException)2 ProducerBusyException (org.apache.pulsar.broker.service.BrokerServiceException.ProducerBusyException)2 ServerMetadataException (org.apache.pulsar.broker.service.BrokerServiceException.ServerMetadataException)2 SubscriptionBusyException (org.apache.pulsar.broker.service.BrokerServiceException.SubscriptionBusyException)2 TopicBusyException (org.apache.pulsar.broker.service.BrokerServiceException.TopicBusyException)2 TopicFencedException (org.apache.pulsar.broker.service.BrokerServiceException.TopicFencedException)2 UnsupportedVersionException (org.apache.pulsar.broker.service.BrokerServiceException.UnsupportedVersionException)2 Consumer (org.apache.pulsar.broker.service.Consumer)2 ConsumerStats (org.apache.pulsar.common.policies.data.ConsumerStats)2 NonPersistentPublisherStats (org.apache.pulsar.common.policies.data.NonPersistentPublisherStats)2 NonPersistentTopicStats (org.apache.pulsar.common.policies.data.NonPersistentTopicStats)2 KeeperException (org.apache.zookeeper.KeeperException)2