Search in sources :

Example 1 with PublisherStats

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

the class PartitionedTopicStatsTest method testPartitionedTopicStats.

@Test
public void testPartitionedTopicStats() {
    PartitionedTopicStats partitionedTopicStats = new PartitionedTopicStats();
    partitionedTopicStats.msgRateIn = 1;
    partitionedTopicStats.msgThroughputIn = 1;
    partitionedTopicStats.msgRateOut = 1;
    partitionedTopicStats.msgThroughputOut = 1;
    partitionedTopicStats.averageMsgSize = 1;
    partitionedTopicStats.storageSize = 1;
    partitionedTopicStats.publishers.add(new PublisherStats());
    partitionedTopicStats.subscriptions.put("test_ns", new SubscriptionStats());
    partitionedTopicStats.replication.put("test_ns", new ReplicatorStats());
    partitionedTopicStats.metadata.partitions = 1;
    partitionedTopicStats.partitions.put("test", partitionedTopicStats);
    partitionedTopicStats.reset();
    assertEquals(partitionedTopicStats.msgRateIn, 0.0);
    assertEquals(partitionedTopicStats.msgThroughputIn, 0.0);
    assertEquals(partitionedTopicStats.msgRateOut, 0.0);
    assertEquals(partitionedTopicStats.msgThroughputOut, 0.0);
    assertEquals(partitionedTopicStats.averageMsgSize, 0.0);
    assertEquals(partitionedTopicStats.storageSize, 0);
    assertEquals(partitionedTopicStats.publishers.size(), 0);
    assertEquals(partitionedTopicStats.subscriptions.size(), 0);
    assertEquals(partitionedTopicStats.replication.size(), 0);
    assertEquals(partitionedTopicStats.metadata.partitions, 0);
    assertEquals(partitionedTopicStats.partitions.size(), 0);
}
Also used : SubscriptionStats(org.apache.pulsar.common.policies.data.SubscriptionStats) PartitionedTopicStats(org.apache.pulsar.common.policies.data.PartitionedTopicStats) PublisherStats(org.apache.pulsar.common.policies.data.PublisherStats) ReplicatorStats(org.apache.pulsar.common.policies.data.ReplicatorStats) Test(org.testng.annotations.Test)

Example 2 with PublisherStats

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

the class PersistentTopic method updateRates.

public void updateRates(NamespaceStats nsStats, NamespaceBundleStats bundleStats, StatsOutputStream topicStatsStream, ClusterReplicationMetrics replStats, String namespace) {
    TopicStats topicStats = threadLocalTopicStats.get();
    topicStats.reset();
    replicators.forEach((region, replicator) -> replicator.updateRates());
    nsStats.producerCount += producers.size();
    bundleStats.producerCount += producers.size();
    topicStatsStream.startObject(topic);
    producers.forEach(producer -> {
        producer.updateRates();
        PublisherStats publisherStats = producer.getStats();
        topicStats.aggMsgRateIn += publisherStats.msgRateIn;
        topicStats.aggMsgThroughputIn += publisherStats.msgThroughputIn;
        if (producer.isRemote()) {
            topicStats.remotePublishersStats.put(producer.getRemoteCluster(), publisherStats);
        }
    });
    // Creating publishers object for backward compatibility
    topicStatsStream.startList("publishers");
    topicStatsStream.endList();
    // Start replicator stats
    topicStatsStream.startObject("replication");
    nsStats.replicatorCount += topicStats.remotePublishersStats.size();
    replicators.forEach((cluster, replicator) -> {
        // Update replicator cursor state
        ((PersistentReplicator) replicator).updateCursorState();
        // Update replicator stats
        ReplicatorStats rStat = replicator.getStats();
        // Add incoming msg rates
        PublisherStats pubStats = topicStats.remotePublishersStats.get(replicator.getRemoteCluster());
        if (pubStats != null) {
            rStat.msgRateIn = pubStats.msgRateIn;
            rStat.msgThroughputIn = pubStats.msgThroughputIn;
            rStat.inboundConnection = pubStats.address;
            rStat.inboundConnectedSince = pubStats.connectedSince;
        }
        topicStats.aggMsgRateOut += rStat.msgRateOut;
        topicStats.aggMsgThroughputOut += rStat.msgThroughputOut;
        // Populate replicator specific stats here
        topicStatsStream.startObject(cluster);
        topicStatsStream.writePair("connected", rStat.connected);
        topicStatsStream.writePair("msgRateExpired", rStat.msgRateExpired);
        topicStatsStream.writePair("msgRateIn", rStat.msgRateIn);
        topicStatsStream.writePair("msgRateOut", rStat.msgRateOut);
        topicStatsStream.writePair("msgThroughputIn", rStat.msgThroughputIn);
        topicStatsStream.writePair("msgThroughputOut", rStat.msgThroughputOut);
        topicStatsStream.writePair("replicationBacklog", rStat.replicationBacklog);
        topicStatsStream.writePair("replicationDelayInSeconds", rStat.replicationDelayInSeconds);
        topicStatsStream.writePair("inboundConnection", rStat.inboundConnection);
        topicStatsStream.writePair("inboundConnectedSince", rStat.inboundConnectedSince);
        topicStatsStream.writePair("outboundConnection", rStat.outboundConnection);
        topicStatsStream.writePair("outboundConnectedSince", rStat.outboundConnectedSince);
        topicStatsStream.endObject();
        nsStats.msgReplBacklog += rStat.replicationBacklog;
        if (replStats.isMetricsEnabled()) {
            String namespaceClusterKey = replStats.getKeyName(namespace, cluster);
            ReplicationMetrics replicationMetrics = replStats.get(namespaceClusterKey);
            boolean update = false;
            if (replicationMetrics == null) {
                replicationMetrics = ReplicationMetrics.get();
                update = true;
            }
            replicationMetrics.connected += rStat.connected ? 1 : 0;
            replicationMetrics.msgRateOut += rStat.msgRateOut;
            replicationMetrics.msgThroughputOut += rStat.msgThroughputOut;
            replicationMetrics.msgReplBacklog += rStat.replicationBacklog;
            if (update) {
                replStats.put(namespaceClusterKey, replicationMetrics);
            }
        }
    });
    // Close replication
    topicStatsStream.endObject();
    // Start subscription stats
    topicStatsStream.startObject("subscriptions");
    nsStats.subsCount += subscriptions.size();
    subscriptions.forEach((subscriptionName, subscription) -> {
        double subMsgRateOut = 0;
        double subMsgThroughputOut = 0;
        double subMsgRateRedeliver = 0;
        // Start subscription name & consumers
        try {
            topicStatsStream.startObject(subscriptionName);
            Object[] consumers = subscription.getConsumers().array();
            nsStats.consumerCount += consumers.length;
            bundleStats.consumerCount += consumers.length;
            topicStatsStream.startList("consumers");
            for (Object consumerObj : consumers) {
                Consumer consumer = (Consumer) consumerObj;
                consumer.updateRates();
                ConsumerStats consumerStats = consumer.getStats();
                subMsgRateOut += consumerStats.msgRateOut;
                subMsgThroughputOut += consumerStats.msgThroughputOut;
                subMsgRateRedeliver += consumerStats.msgRateRedeliver;
                // Populate consumer specific stats here
                topicStatsStream.startObject();
                topicStatsStream.writePair("address", consumerStats.address);
                topicStatsStream.writePair("consumerName", consumerStats.consumerName);
                topicStatsStream.writePair("availablePermits", consumerStats.availablePermits);
                topicStatsStream.writePair("connectedSince", consumerStats.connectedSince);
                topicStatsStream.writePair("msgRateOut", consumerStats.msgRateOut);
                topicStatsStream.writePair("msgThroughputOut", consumerStats.msgThroughputOut);
                topicStatsStream.writePair("msgRateRedeliver", consumerStats.msgRateRedeliver);
                if (SubType.Shared.equals(subscription.getType())) {
                    topicStatsStream.writePair("unackedMessages", consumerStats.unackedMessages);
                    topicStatsStream.writePair("blockedConsumerOnUnackedMsgs", consumerStats.blockedConsumerOnUnackedMsgs);
                }
                if (consumerStats.clientVersion != null) {
                    topicStatsStream.writePair("clientVersion", consumerStats.clientVersion);
                }
                topicStatsStream.endObject();
            }
            // Close Consumer stats
            topicStatsStream.endList();
            // Populate subscription specific stats here
            topicStatsStream.writePair("msgBacklog", subscription.getNumberOfEntriesInBacklog());
            topicStatsStream.writePair("msgRateExpired", subscription.getExpiredMessageRate());
            topicStatsStream.writePair("msgRateOut", subMsgRateOut);
            topicStatsStream.writePair("msgThroughputOut", subMsgThroughputOut);
            topicStatsStream.writePair("msgRateRedeliver", subMsgRateRedeliver);
            topicStatsStream.writePair("numberOfEntriesSinceFirstNotAckedMessage", subscription.getNumberOfEntriesSinceFirstNotAckedMessage());
            topicStatsStream.writePair("totalNonContiguousDeletedMessagesRange", subscription.getTotalNonContiguousDeletedMessagesRange());
            topicStatsStream.writePair("type", subscription.getTypeString());
            if (SubType.Shared.equals(subscription.getType())) {
                if (subscription.getDispatcher() instanceof PersistentDispatcherMultipleConsumers) {
                    PersistentDispatcherMultipleConsumers dispatcher = (PersistentDispatcherMultipleConsumers) subscription.getDispatcher();
                    topicStatsStream.writePair("blockedSubscriptionOnUnackedMsgs", dispatcher.isBlockedDispatcherOnUnackedMsgs());
                    topicStatsStream.writePair("unackedMessages", dispatcher.getTotalUnackedMessages());
                }
            }
            // Close consumers
            topicStatsStream.endObject();
            topicStats.aggMsgRateOut += subMsgRateOut;
            topicStats.aggMsgThroughputOut += subMsgThroughputOut;
            nsStats.msgBacklog += subscription.getNumberOfEntriesInBacklog();
        } catch (Exception e) {
            log.error("Got exception when creating consumer stats for subscription {}: {}", subscriptionName, e.getMessage(), e);
        }
    });
    // Close subscription
    topicStatsStream.endObject();
    // Remaining dest stats.
    topicStats.averageMsgSize = topicStats.aggMsgRateIn == 0.0 ? 0.0 : (topicStats.aggMsgThroughputIn / topicStats.aggMsgRateIn);
    topicStatsStream.writePair("producerCount", producers.size());
    topicStatsStream.writePair("averageMsgSize", topicStats.averageMsgSize);
    topicStatsStream.writePair("msgRateIn", topicStats.aggMsgRateIn);
    topicStatsStream.writePair("msgRateOut", topicStats.aggMsgRateOut);
    topicStatsStream.writePair("msgThroughputIn", topicStats.aggMsgThroughputIn);
    topicStatsStream.writePair("msgThroughputOut", topicStats.aggMsgThroughputOut);
    topicStatsStream.writePair("storageSize", ledger.getEstimatedBacklogSize());
    topicStatsStream.writePair("pendingAddEntriesCount", ((ManagedLedgerImpl) ledger).getPendingAddEntriesCount());
    nsStats.msgRateIn += topicStats.aggMsgRateIn;
    nsStats.msgRateOut += topicStats.aggMsgRateOut;
    nsStats.msgThroughputIn += topicStats.aggMsgThroughputIn;
    nsStats.msgThroughputOut += topicStats.aggMsgThroughputOut;
    nsStats.storageSize += ledger.getEstimatedBacklogSize();
    bundleStats.msgRateIn += topicStats.aggMsgRateIn;
    bundleStats.msgRateOut += topicStats.aggMsgRateOut;
    bundleStats.msgThroughputIn += topicStats.aggMsgThroughputIn;
    bundleStats.msgThroughputOut += topicStats.aggMsgThroughputOut;
    bundleStats.cacheSize += ((ManagedLedgerImpl) ledger).getCacheSize();
    // Close topic object
    topicStatsStream.endObject();
}
Also used : ReplicationMetrics(org.apache.pulsar.broker.stats.ReplicationMetrics) ClusterReplicationMetrics(org.apache.pulsar.broker.stats.ClusterReplicationMetrics) PublisherStats(org.apache.pulsar.common.policies.data.PublisherStats) ConsumerStats(org.apache.pulsar.common.policies.data.ConsumerStats) NamingException(org.apache.pulsar.broker.service.BrokerServiceException.NamingException) NotAllowedException(org.apache.pulsar.broker.service.BrokerServiceException.NotAllowedException) UnsupportedVersionException(org.apache.pulsar.broker.service.BrokerServiceException.UnsupportedVersionException) ProducerBusyException(org.apache.pulsar.broker.service.BrokerServiceException.ProducerBusyException) ManagedLedgerAlreadyClosedException(org.apache.bookkeeper.mledger.ManagedLedgerException.ManagedLedgerAlreadyClosedException) ManagedLedgerException(org.apache.bookkeeper.mledger.ManagedLedgerException) SubscriptionBusyException(org.apache.pulsar.broker.service.BrokerServiceException.SubscriptionBusyException) ManagedLedgerFencedException(org.apache.bookkeeper.mledger.ManagedLedgerException.ManagedLedgerFencedException) TopicTerminatedException(org.apache.pulsar.broker.service.BrokerServiceException.TopicTerminatedException) ManagedLedgerTerminatedException(org.apache.bookkeeper.mledger.ManagedLedgerException.ManagedLedgerTerminatedException) TopicClosedException(org.apache.pulsar.broker.service.BrokerServiceException.TopicClosedException) ServerMetadataException(org.apache.pulsar.broker.service.BrokerServiceException.ServerMetadataException) KeeperException(org.apache.zookeeper.KeeperException) BrokerServiceException(org.apache.pulsar.broker.service.BrokerServiceException) PersistenceException(org.apache.pulsar.broker.service.BrokerServiceException.PersistenceException) TopicFencedException(org.apache.pulsar.broker.service.BrokerServiceException.TopicFencedException) TopicBusyException(org.apache.pulsar.broker.service.BrokerServiceException.TopicBusyException) ConsumerBusyException(org.apache.pulsar.broker.service.BrokerServiceException.ConsumerBusyException) Consumer(org.apache.pulsar.broker.service.Consumer) ReplicatorStats(org.apache.pulsar.common.policies.data.ReplicatorStats) PersistentTopicStats(org.apache.pulsar.common.policies.data.PersistentTopicStats)

Example 3 with PublisherStats

use of org.apache.pulsar.common.policies.data.PublisherStats 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)

Example 4 with PublisherStats

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

the class NonPersistentTopic method updateRates.

public void updateRates(NamespaceStats nsStats, NamespaceBundleStats bundleStats, StatsOutputStream topicStatsStream, ClusterReplicationMetrics replStats, String namespace) {
    TopicStats topicStats = threadLocalTopicStats.get();
    topicStats.reset();
    replicators.forEach((region, replicator) -> replicator.updateRates());
    nsStats.producerCount += producers.size();
    bundleStats.producerCount += producers.size();
    topicStatsStream.startObject(topic);
    producers.forEach(producer -> {
        producer.updateRates();
        PublisherStats PublisherStats = producer.getStats();
        topicStats.aggMsgRateIn += PublisherStats.msgRateIn;
        topicStats.aggMsgThroughputIn += PublisherStats.msgThroughputIn;
        if (producer.isRemote()) {
            topicStats.remotePublishersStats.put(producer.getRemoteCluster(), PublisherStats);
        }
    });
    // Creating publishers object for backward compatibility
    topicStatsStream.startList("publishers");
    topicStatsStream.endList();
    // Start replicator stats
    topicStatsStream.startObject("replication");
    nsStats.replicatorCount += topicStats.remotePublishersStats.size();
    // Close replication
    topicStatsStream.endObject();
    // Start subscription stats
    topicStatsStream.startObject("subscriptions");
    nsStats.subsCount += subscriptions.size();
    subscriptions.forEach((subscriptionName, subscription) -> {
        double subMsgRateOut = 0;
        double subMsgThroughputOut = 0;
        double subMsgRateRedeliver = 0;
        // Start subscription name & consumers
        try {
            topicStatsStream.startObject(subscriptionName);
            Object[] consumers = subscription.getConsumers().array();
            nsStats.consumerCount += consumers.length;
            bundleStats.consumerCount += consumers.length;
            topicStatsStream.startList("consumers");
            subscription.getDispatcher().getMesssageDropRate().calculateRate();
            for (Object consumerObj : consumers) {
                Consumer consumer = (Consumer) consumerObj;
                consumer.updateRates();
                ConsumerStats consumerStats = consumer.getStats();
                subMsgRateOut += consumerStats.msgRateOut;
                subMsgThroughputOut += consumerStats.msgThroughputOut;
                subMsgRateRedeliver += consumerStats.msgRateRedeliver;
                // Populate consumer specific stats here
                topicStatsStream.startObject();
                topicStatsStream.writePair("address", consumerStats.address);
                topicStatsStream.writePair("consumerName", consumerStats.consumerName);
                topicStatsStream.writePair("availablePermits", consumerStats.availablePermits);
                topicStatsStream.writePair("connectedSince", consumerStats.connectedSince);
                topicStatsStream.writePair("msgRateOut", consumerStats.msgRateOut);
                topicStatsStream.writePair("msgThroughputOut", consumerStats.msgThroughputOut);
                topicStatsStream.writePair("msgRateRedeliver", consumerStats.msgRateRedeliver);
                if (SubType.Shared.equals(subscription.getType())) {
                    topicStatsStream.writePair("unackedMessages", consumerStats.unackedMessages);
                    topicStatsStream.writePair("blockedConsumerOnUnackedMsgs", consumerStats.blockedConsumerOnUnackedMsgs);
                }
                if (consumerStats.clientVersion != null) {
                    topicStatsStream.writePair("clientVersion", consumerStats.clientVersion);
                }
                topicStatsStream.endObject();
            }
            // Close Consumer stats
            topicStatsStream.endList();
            // Populate subscription specific stats here
            topicStatsStream.writePair("msgBacklog", subscription.getNumberOfEntriesInBacklog());
            topicStatsStream.writePair("msgRateExpired", subscription.getExpiredMessageRate());
            topicStatsStream.writePair("msgRateOut", subMsgRateOut);
            topicStatsStream.writePair("msgThroughputOut", subMsgThroughputOut);
            topicStatsStream.writePair("msgRateRedeliver", subMsgRateRedeliver);
            topicStatsStream.writePair("type", subscription.getTypeString());
            if (subscription.getDispatcher() != null) {
                topicStatsStream.writePair("msgDropRate", subscription.getDispatcher().getMesssageDropRate().getRate());
            }
            // Close consumers
            topicStatsStream.endObject();
            topicStats.aggMsgRateOut += subMsgRateOut;
            topicStats.aggMsgThroughputOut += subMsgThroughputOut;
            nsStats.msgBacklog += subscription.getNumberOfEntriesInBacklog();
        } catch (Exception e) {
            log.error("Got exception when creating consumer stats for subscription {}: {}", subscriptionName, e.getMessage(), e);
        }
    });
    // Close subscription
    topicStatsStream.endObject();
    // Remaining dest stats.
    topicStats.averageMsgSize = topicStats.aggMsgRateIn == 0.0 ? 0.0 : (topicStats.aggMsgThroughputIn / topicStats.aggMsgRateIn);
    topicStatsStream.writePair("producerCount", producers.size());
    topicStatsStream.writePair("averageMsgSize", topicStats.averageMsgSize);
    topicStatsStream.writePair("msgRateIn", topicStats.aggMsgRateIn);
    topicStatsStream.writePair("msgRateOut", topicStats.aggMsgRateOut);
    topicStatsStream.writePair("msgThroughputIn", topicStats.aggMsgThroughputIn);
    topicStatsStream.writePair("msgThroughputOut", topicStats.aggMsgThroughputOut);
    nsStats.msgRateIn += topicStats.aggMsgRateIn;
    nsStats.msgRateOut += topicStats.aggMsgRateOut;
    nsStats.msgThroughputIn += topicStats.aggMsgThroughputIn;
    nsStats.msgThroughputOut += topicStats.aggMsgThroughputOut;
    bundleStats.msgRateIn += topicStats.aggMsgRateIn;
    bundleStats.msgRateOut += topicStats.aggMsgRateOut;
    bundleStats.msgThroughputIn += topicStats.aggMsgThroughputIn;
    bundleStats.msgThroughputOut += topicStats.aggMsgThroughputOut;
    // Close topic object
    topicStatsStream.endObject();
}
Also used : Consumer(org.apache.pulsar.broker.service.Consumer) NonPersistentPublisherStats(org.apache.pulsar.common.policies.data.NonPersistentPublisherStats) PublisherStats(org.apache.pulsar.common.policies.data.PublisherStats) ConsumerStats(org.apache.pulsar.common.policies.data.ConsumerStats) NonPersistentTopicStats(org.apache.pulsar.common.policies.data.NonPersistentTopicStats) NamingException(org.apache.pulsar.broker.service.BrokerServiceException.NamingException) NotAllowedException(org.apache.pulsar.broker.service.BrokerServiceException.NotAllowedException) UnsupportedVersionException(org.apache.pulsar.broker.service.BrokerServiceException.UnsupportedVersionException) ProducerBusyException(org.apache.pulsar.broker.service.BrokerServiceException.ProducerBusyException) SubscriptionBusyException(org.apache.pulsar.broker.service.BrokerServiceException.SubscriptionBusyException) ServerMetadataException(org.apache.pulsar.broker.service.BrokerServiceException.ServerMetadataException) KeeperException(org.apache.zookeeper.KeeperException) BrokerServiceException(org.apache.pulsar.broker.service.BrokerServiceException) TopicFencedException(org.apache.pulsar.broker.service.BrokerServiceException.TopicFencedException) TopicBusyException(org.apache.pulsar.broker.service.BrokerServiceException.TopicBusyException) ConsumerBusyException(org.apache.pulsar.broker.service.BrokerServiceException.ConsumerBusyException)

Example 5 with PublisherStats

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

the class PersistentTopicStatsTest method testPersistentTopicStats.

@Test
public void testPersistentTopicStats() {
    PersistentTopicStats persistentTopicStats = new PersistentTopicStats();
    persistentTopicStats.msgRateIn = 1;
    persistentTopicStats.msgThroughputIn = 1;
    persistentTopicStats.msgRateOut = 1;
    persistentTopicStats.msgThroughputOut = 1;
    persistentTopicStats.averageMsgSize = 1;
    persistentTopicStats.storageSize = 1;
    persistentTopicStats.publishers.add(new PublisherStats());
    persistentTopicStats.subscriptions.put("test_ns", new SubscriptionStats());
    persistentTopicStats.replication.put("test_ns", new ReplicatorStats());
    PersistentTopicStats target = new PersistentTopicStats();
    target.add(persistentTopicStats);
    assertEquals(persistentTopicStats.msgRateIn, 1.0);
    assertEquals(persistentTopicStats.msgThroughputIn, 1.0);
    assertEquals(persistentTopicStats.msgRateOut, 1.0);
    assertEquals(persistentTopicStats.msgThroughputOut, 1.0);
    assertEquals(persistentTopicStats.averageMsgSize, 1.0);
    assertEquals(persistentTopicStats.storageSize, 1);
    assertEquals(persistentTopicStats.publishers.size(), 1);
    assertEquals(persistentTopicStats.subscriptions.size(), 1);
    assertEquals(persistentTopicStats.replication.size(), 1);
    persistentTopicStats.reset();
    assertEquals(persistentTopicStats.msgRateIn, 0.0);
    assertEquals(persistentTopicStats.msgThroughputIn, 0.0);
    assertEquals(persistentTopicStats.msgRateOut, 0.0);
    assertEquals(persistentTopicStats.msgThroughputOut, 0.0);
    assertEquals(persistentTopicStats.averageMsgSize, 0.0);
    assertEquals(persistentTopicStats.storageSize, 0);
    assertEquals(persistentTopicStats.publishers.size(), 0);
    assertEquals(persistentTopicStats.subscriptions.size(), 0);
    assertEquals(persistentTopicStats.replication.size(), 0);
}
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) Test(org.testng.annotations.Test)

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