Skip to content

Commit 1de8a26

Browse files
committed
[#1984] Refactor use of deprecated StatsImpl.addStatistic to use addStatistics(Set.of(..))
1 parent 9d6ab80 commit 1de8a26

9 files changed

Lines changed: 27 additions & 42 deletions

File tree

activemq-broker/src/main/java/org/apache/activemq/broker/region/ConnectionStatistics.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
1616
*/
17-
1817
package org.apache.activemq.broker.region;
1918

2019
import org.apache.activemq.management.CountStatisticImpl;
2120
import org.apache.activemq.management.StatsImpl;
2221

22+
import java.util.Set;
23+
2324
/**
2425
* The J2EE Statistics for the Connection.
2526
*
@@ -35,8 +36,7 @@ public ConnectionStatistics() {
3536
enqueues = new CountStatisticImpl("enqueues", "The number of messages that have been sent to the connection");
3637
dequeues = new CountStatisticImpl("dequeues", "The number of messages that have been dispatched from the connection");
3738

38-
addStatistic("enqueues", enqueues);
39-
addStatistic("dequeues", dequeues);
39+
addStatistics(Set.of(enqueues, dequeues));
4040
}
4141

4242
public CountStatisticImpl getEnqueues() {

activemq-broker/src/main/java/org/apache/activemq/broker/region/ConnectorStatistics.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,14 @@
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
1616
*/
17-
1817
package org.apache.activemq.broker.region;
1918

2019
import org.apache.activemq.management.CountStatisticImpl;
2120
import org.apache.activemq.management.PollCountStatisticImpl;
2221
import org.apache.activemq.management.StatsImpl;
2322

23+
import java.util.Set;
24+
2425
/**
2526
* The J2EE Statistics for the a Destination.
2627
*
@@ -42,11 +43,7 @@ public ConnectorStatistics() {
4243
messages = new CountStatisticImpl("messages", "The number of messages that that are being held by the destination");
4344
messagesCached = new PollCountStatisticImpl("messagesCached", "The number of messages that are held in the destination's memory cache");
4445

45-
addStatistic("enqueues", enqueues);
46-
addStatistic("dequeues", dequeues);
47-
addStatistic("consumers", consumers);
48-
addStatistic("messages", messages);
49-
addStatistic("messagesCached", messagesCached);
46+
addStatistics(Set.of(enqueues, dequeues, consumers, messages, messagesCached));
5047
}
5148

5249
public CountStatisticImpl getEnqueues() {

activemq-broker/src/main/java/org/apache/activemq/broker/region/RegionStatistics.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
1616
*/
17-
1817
package org.apache.activemq.broker.region;
1918

2019
import org.apache.activemq.management.CountStatisticImpl;
2120
import org.apache.activemq.management.StatsImpl;
2221

22+
import java.util.Set;
23+
2324
/**
2425
* The J2EE Statistics for the Connection.
2526
*
@@ -41,10 +42,7 @@ public RegionStatistics(boolean enabled) {
4142
destinations = new CountStatisticImpl("destinations", "The number of regular (non-adivsory) destinations in the region");
4243
allDestinations = new CountStatisticImpl("allDestinations", "The total number of destinations, including advisory destinations, in the region");
4344

44-
addStatistic("advisoryDestinations", advisoryDestinations);
45-
addStatistic("destinations", destinations);
46-
addStatistic("allDestinations", allDestinations);
47-
45+
addStatistics(Set.of(advisoryDestinations, destinations, allDestinations));
4846
this.setEnabled(enabled);
4947
}
5048

activemq-broker/src/main/java/org/apache/activemq/broker/region/SubscriptionStatistics.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,14 @@
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
1616
*/
17-
1817
package org.apache.activemq.broker.region;
1918

2019
import org.apache.activemq.management.CountStatisticImpl;
2120
import org.apache.activemq.management.SizeStatisticImpl;
2221
import org.apache.activemq.management.StatsImpl;
2322

23+
import java.util.Set;
24+
2425
/**
2526
* The J2EE Statistics for a Subsription.
2627
*/
@@ -32,7 +33,6 @@ public class SubscriptionStatistics extends StatsImpl {
3233
protected CountStatisticImpl dispatched;
3334
protected SizeStatisticImpl inflightMessageSize;
3435

35-
3636
public SubscriptionStatistics() {
3737
this(true);
3838
}
@@ -45,12 +45,7 @@ public SubscriptionStatistics(boolean enabled) {
4545
dequeues = new CountStatisticImpl("dequeues", "The number of messages that have been acknowledged from the subscription");
4646
inflightMessageSize = new SizeStatisticImpl("inflightMessageSize", "The size in bytes of messages dispatched but awaiting acknowledgement");
4747

48-
addStatistic("consumedCount", consumedCount);
49-
addStatistic("enqueues", enqueues);
50-
addStatistic("dispatched", dispatched);
51-
addStatistic("dequeues", dequeues);
52-
addStatistic("inflightMessageSize", inflightMessageSize);
53-
48+
addStatistics(Set.of(consumedCount, enqueues, dispatched, dequeues, inflightMessageSize));
5449
this.setEnabled(enabled);
5550
}
5651

activemq-broker/src/main/java/org/apache/activemq/network/NetworkBridgeStatistics.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
1616
*/
17-
1817
package org.apache.activemq.network;
1918

2019
import org.apache.activemq.management.CountStatisticImpl;
2120
import org.apache.activemq.management.StatsImpl;
2221

22+
import java.util.Set;
23+
2324
/**
2425
* The Statistics for a NetworkBridge.
2526
*/
@@ -34,9 +35,7 @@ public NetworkBridgeStatistics() {
3435
dequeues = new CountStatisticImpl("dequeues", "The current number of dequeues this bridge has, which is the number of messages received by the remote broker.");
3536
receivedCount = new CountStatisticImpl("receivedCount", "The number of messages that have been received by the NetworkBridge from the remote broker. Only applies for Duplex bridges.");
3637

37-
addStatistic("enqueues", enqueues);
38-
addStatistic("dequeues", dequeues);
39-
addStatistic("receivedCount", receivedCount);
38+
addStatistics(Set.of(enqueues, dequeues, receivedCount));
4039
}
4140

4241
/**

activemq-broker/src/main/java/org/apache/activemq/store/AbstractMessageStoreStatistics.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,14 @@
2121
import org.apache.activemq.management.SizeStatisticImpl;
2222
import org.apache.activemq.management.StatsImpl;
2323

24+
import java.util.Set;
25+
2426

2527
public abstract class AbstractMessageStoreStatistics extends StatsImpl {
2628

2729
protected final CountStatisticImpl messageCount;
2830
protected final SizeStatisticImpl messageSize;
2931

30-
3132
protected AbstractMessageStoreStatistics(String countDescription, String sizeDescription) {
3233
this(true, countDescription, sizeDescription);
3334
}
@@ -37,9 +38,7 @@ protected AbstractMessageStoreStatistics(boolean enabled, String countDescriptio
3738
messageCount = new CountStatisticImpl("messageCount", countDescription);
3839
messageSize = new SizeStatisticImpl("messageSize", sizeDescription);
3940

40-
addStatistic("messageCount", messageCount);
41-
addStatistic("messageSize", messageSize);
42-
41+
addStatistics(Set.of(messageCount, messageSize));
4342
this.setEnabled(enabled);
4443
}
4544

activemq-broker/src/main/java/org/apache/activemq/store/MessageStoreStatistics.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,14 @@
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
1616
*/
17-
1817
package org.apache.activemq.store;
1918

2019
import org.apache.activemq.management.CountStatisticImpl;
2120
import org.apache.activemq.management.SizeStatisticImpl;
2221
import org.apache.activemq.management.StatsImpl;
2322

23+
import java.util.Set;
24+
2425
/**
2526
* The J2EE Statistics for a Message Sore
2627
*/
@@ -39,9 +40,7 @@ public MessageStoreStatistics(boolean enabled) {
3940
messageCount = new CountStatisticImpl("messageCount", "The number of messages in the store passing through the destination");
4041
messageSize = new SizeStatisticImpl("messageSize","Size of messages in the store passing through the destination");
4142

42-
addStatistic("messageCount", messageCount);
43-
addStatistic("messageSize", messageSize);
44-
43+
addStatistics(Set.of(messageCount, messageSize));
4544
this.setEnabled(enabled);
4645
}
4746

activemq-broker/src/main/java/org/apache/activemq/store/PersistenceAdapterStatistics.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
*/
1717
package org.apache.activemq.store;
1818

19+
import java.util.Set;
1920
import org.apache.activemq.management.StatsImpl;
2021
import org.apache.activemq.management.TimeStatisticImpl;
2122

@@ -31,14 +32,11 @@ public PersistenceAdapterStatistics() {
3132
slowCleanupTime = new TimeStatisticImpl("slowCleanupTime", "Slow time to cleanup data in the PersistentAdapter.");
3233
slowWriteTime = new TimeStatisticImpl("slowWriteTime", "Slow time to write data to the PersistentAdapter.");
3334
slowReadTime = new TimeStatisticImpl("slowReadTime", "Slow time to read data from the PersistentAdapter.");
34-
addStatistic("slowCleanupTime", slowCleanupTime);
35-
addStatistic("slowWriteTime", slowWriteTime);
36-
addStatistic("slowReadTime", slowReadTime);
37-
35+
3836
writeTime = new TimeStatisticImpl("writeTime", "Time to write data to the PersistentAdapter.");
3937
readTime = new TimeStatisticImpl("readTime", "Time to read data from the PersistentAdapter.");
40-
addStatistic("writeTime", writeTime);
41-
addStatistic("readTime", readTime);
38+
39+
addStatistics(Set.of(slowCleanupTime, slowWriteTime, slowReadTime, writeTime, readTime));
4240
}
4341

4442
public void addSlowCleanupTime(final long time) {

activemq-client/src/main/java/org/apache/activemq/management/StatsImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@ protected synchronized void addStatistic(String name, StatisticImpl statistic) {
5959
this.set.add(statistic);
6060
}
6161

62-
protected void addStatistics(Collection<StatisticImpl> statistics) {
62+
protected void addStatistics(final Collection<StatisticImpl> statistics) {
6363
this.set.addAll(statistics);
6464
}
6565

66-
protected void removeStatistics(Collection<StatisticImpl> statistics) {
66+
protected void removeStatistics(final Collection<StatisticImpl> statistics) {
6767
this.set.removeAll(statistics);
6868
}
6969
}

0 commit comments

Comments
 (0)