Java Code Examples for org.apache.pulsar.common.policies.data.TopicStats#add()
The following examples show how to use
org.apache.pulsar.common.policies.data.TopicStats#add() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PersistentTopicStatsTest.java From pulsar with Apache License 2.0 | 5 votes |
@Test public void testPersistentTopicStats() { TopicStats topicStats = new TopicStats(); topicStats.msgRateIn = 1; topicStats.msgThroughputIn = 1; topicStats.msgRateOut = 1; topicStats.msgThroughputOut = 1; topicStats.averageMsgSize = 1; topicStats.storageSize = 1; topicStats.publishers.add(new PublisherStats()); topicStats.subscriptions.put("test_ns", new SubscriptionStats()); topicStats.replication.put("test_ns", new ReplicatorStats()); TopicStats target = new TopicStats(); target.add(topicStats); assertEquals(topicStats.msgRateIn, 1.0); assertEquals(topicStats.msgThroughputIn, 1.0); assertEquals(topicStats.msgRateOut, 1.0); assertEquals(topicStats.msgThroughputOut, 1.0); assertEquals(topicStats.averageMsgSize, 1.0); assertEquals(topicStats.storageSize, 1); assertEquals(topicStats.publishers.size(), 1); assertEquals(topicStats.subscriptions.size(), 1); assertEquals(topicStats.replication.size(), 1); topicStats.reset(); assertEquals(topicStats.msgRateIn, 0.0); assertEquals(topicStats.msgThroughputIn, 0.0); assertEquals(topicStats.msgRateOut, 0.0); assertEquals(topicStats.msgThroughputOut, 0.0); assertEquals(topicStats.averageMsgSize, 0.0); assertEquals(topicStats.storageSize, 0); assertEquals(topicStats.publishers.size(), 0); assertEquals(topicStats.subscriptions.size(), 0); assertEquals(topicStats.replication.size(), 0); }
Example 2
Source File: PersistentTopicStatsTest.java From pulsar with Apache License 2.0 | 5 votes |
@Test public void testPersistentTopicStatsAggregation() { TopicStats topicStats1 = new TopicStats(); topicStats1.msgRateIn = 1; topicStats1.msgThroughputIn = 1; topicStats1.msgRateOut = 1; topicStats1.msgThroughputOut = 1; topicStats1.averageMsgSize = 1; topicStats1.storageSize = 1; topicStats1.publishers.add(new PublisherStats()); topicStats1.subscriptions.put("test_ns", new SubscriptionStats()); topicStats1.replication.put("test_ns", new ReplicatorStats()); TopicStats topicStats2 = new TopicStats(); topicStats2.msgRateIn = 1; topicStats2.msgThroughputIn = 2; topicStats2.msgRateOut = 3; topicStats2.msgThroughputOut = 4; topicStats2.averageMsgSize = 5; topicStats2.storageSize = 6; topicStats2.publishers.add(new PublisherStats()); topicStats2.subscriptions.put("test_ns", new SubscriptionStats()); topicStats2.replication.put("test_ns", new ReplicatorStats()); TopicStats target = new TopicStats(); target.add(topicStats1); target.add(topicStats2); assertEquals(target.msgRateIn, 2.0); assertEquals(target.msgThroughputIn, 3.0); assertEquals(target.msgRateOut, 4.0); assertEquals(target.msgThroughputOut, 5.0); assertEquals(target.averageMsgSize, 3.0); assertEquals(target.storageSize, 7); assertEquals(target.publishers.size(), 1); assertEquals(target.subscriptions.size(), 1); assertEquals(target.replication.size(), 1); }