Search in sources :

Example 1 with Dispatcher

use of org.apache.pulsar.broker.service.Dispatcher in project incubator-pulsar by apache.

the class PersistentSubscription method getStats.

public SubscriptionStats getStats() {
    SubscriptionStats subStats = new SubscriptionStats();
    Dispatcher dispatcher = this.dispatcher;
    if (dispatcher != null) {
        dispatcher.getConsumers().forEach(consumer -> {
            ConsumerStats consumerStats = consumer.getStats();
            subStats.consumers.add(consumerStats);
            subStats.msgRateOut += consumerStats.msgRateOut;
            subStats.msgThroughputOut += consumerStats.msgThroughputOut;
            subStats.msgRateRedeliver += consumerStats.msgRateRedeliver;
            subStats.unackedMessages += consumerStats.unackedMessages;
        });
    }
    subStats.type = getType();
    if (SubType.Shared.equals(subStats.type)) {
        if (dispatcher instanceof PersistentDispatcherMultipleConsumers) {
            subStats.unackedMessages = ((PersistentDispatcherMultipleConsumers) dispatcher).getTotalUnackedMessages();
            subStats.blockedSubscriptionOnUnackedMsgs = ((PersistentDispatcherMultipleConsumers) dispatcher).isBlockedDispatcherOnUnackedMsgs();
        }
    }
    subStats.msgBacklog = getNumberOfEntriesInBacklog();
    subStats.msgRateExpired = expiryMonitor.getMessageExpiryRate();
    return subStats;
}
Also used : SubscriptionStats(org.apache.pulsar.common.policies.data.SubscriptionStats) ConsumerStats(org.apache.pulsar.common.policies.data.ConsumerStats) Dispatcher(org.apache.pulsar.broker.service.Dispatcher)

Aggregations

Dispatcher (org.apache.pulsar.broker.service.Dispatcher)1 ConsumerStats (org.apache.pulsar.common.policies.data.ConsumerStats)1 SubscriptionStats (org.apache.pulsar.common.policies.data.SubscriptionStats)1