This is an automated email from the ASF dual-hosted git repository.
mattrpav pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/activemq.git
The following commit(s) were added to refs/heads/main by this push:
new 74ac6dabc4 [#1984] Refactor use of deprecated StatsImpl.addStatistic
to use addStatistics(Set.of(..))
74ac6dabc4 is described below
commit 74ac6dabc4e6b2ca0c4baf1dd2f6b73094f45eda
Author: Matt Pavlovich <[email protected]>
AuthorDate: Sat May 2 12:28:43 2026 -0500
[#1984] Refactor use of deprecated StatsImpl.addStatistic to use
addStatistics(Set.of(..))
---
.../apache/activemq/broker/region/ConnectionStatistics.java | 6 +++---
.../apache/activemq/broker/region/ConnectorStatistics.java | 9 +++------
.../org/apache/activemq/broker/region/RegionStatistics.java | 8 +++-----
.../apache/activemq/broker/region/SubscriptionStatistics.java | 11 +++--------
.../org/apache/activemq/network/NetworkBridgeStatistics.java | 7 +++----
.../apache/activemq/store/AbstractMessageStoreStatistics.java | 7 +++----
.../org/apache/activemq/store/MessageStoreStatistics.java | 7 +++----
.../apache/activemq/store/PersistenceAdapterStatistics.java | 10 ++++------
.../main/java/org/apache/activemq/management/StatsImpl.java | 4 ++--
9 files changed, 27 insertions(+), 42 deletions(-)
diff --git
a/activemq-broker/src/main/java/org/apache/activemq/broker/region/ConnectionStatistics.java
b/activemq-broker/src/main/java/org/apache/activemq/broker/region/ConnectionStatistics.java
index 38eddb96dd..9ff31ae5e4 100644
---
a/activemq-broker/src/main/java/org/apache/activemq/broker/region/ConnectionStatistics.java
+++
b/activemq-broker/src/main/java/org/apache/activemq/broker/region/ConnectionStatistics.java
@@ -14,12 +14,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.activemq.broker.region;
import org.apache.activemq.management.CountStatisticImpl;
import org.apache.activemq.management.StatsImpl;
+import java.util.Set;
+
/**
* The J2EE Statistics for the Connection.
*
@@ -35,8 +36,7 @@ public class ConnectionStatistics extends StatsImpl {
enqueues = new CountStatisticImpl("enqueues", "The number of messages
that have been sent to the connection");
dequeues = new CountStatisticImpl("dequeues", "The number of messages
that have been dispatched from the connection");
- addStatistic("enqueues", enqueues);
- addStatistic("dequeues", dequeues);
+ addStatistics(Set.of(enqueues, dequeues));
}
public CountStatisticImpl getEnqueues() {
diff --git
a/activemq-broker/src/main/java/org/apache/activemq/broker/region/ConnectorStatistics.java
b/activemq-broker/src/main/java/org/apache/activemq/broker/region/ConnectorStatistics.java
index 11a15358bd..1176e91a37 100644
---
a/activemq-broker/src/main/java/org/apache/activemq/broker/region/ConnectorStatistics.java
+++
b/activemq-broker/src/main/java/org/apache/activemq/broker/region/ConnectorStatistics.java
@@ -14,13 +14,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.activemq.broker.region;
import org.apache.activemq.management.CountStatisticImpl;
import org.apache.activemq.management.PollCountStatisticImpl;
import org.apache.activemq.management.StatsImpl;
+import java.util.Set;
+
/**
* The J2EE Statistics for the a Destination.
*
@@ -42,11 +43,7 @@ public class ConnectorStatistics extends StatsImpl {
messages = new CountStatisticImpl("messages", "The number of messages
that that are being held by the destination");
messagesCached = new PollCountStatisticImpl("messagesCached", "The
number of messages that are held in the destination's memory cache");
- addStatistic("enqueues", enqueues);
- addStatistic("dequeues", dequeues);
- addStatistic("consumers", consumers);
- addStatistic("messages", messages);
- addStatistic("messagesCached", messagesCached);
+ addStatistics(Set.of(enqueues, dequeues, consumers, messages,
messagesCached));
}
public CountStatisticImpl getEnqueues() {
diff --git
a/activemq-broker/src/main/java/org/apache/activemq/broker/region/RegionStatistics.java
b/activemq-broker/src/main/java/org/apache/activemq/broker/region/RegionStatistics.java
index d39a4f1214..db61e34a0a 100644
---
a/activemq-broker/src/main/java/org/apache/activemq/broker/region/RegionStatistics.java
+++
b/activemq-broker/src/main/java/org/apache/activemq/broker/region/RegionStatistics.java
@@ -14,12 +14,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.activemq.broker.region;
import org.apache.activemq.management.CountStatisticImpl;
import org.apache.activemq.management.StatsImpl;
+import java.util.Set;
+
/**
* The J2EE Statistics for the Connection.
*
@@ -41,10 +42,7 @@ public class RegionStatistics extends StatsImpl {
destinations = new CountStatisticImpl("destinations", "The number of
regular (non-adivsory) destinations in the region");
allDestinations = new CountStatisticImpl("allDestinations", "The total
number of destinations, including advisory destinations, in the region");
- addStatistic("advisoryDestinations", advisoryDestinations);
- addStatistic("destinations", destinations);
- addStatistic("allDestinations", allDestinations);
-
+ addStatistics(Set.of(advisoryDestinations, destinations,
allDestinations));
this.setEnabled(enabled);
}
diff --git
a/activemq-broker/src/main/java/org/apache/activemq/broker/region/SubscriptionStatistics.java
b/activemq-broker/src/main/java/org/apache/activemq/broker/region/SubscriptionStatistics.java
index d6a276e5d1..449ed997da 100644
---
a/activemq-broker/src/main/java/org/apache/activemq/broker/region/SubscriptionStatistics.java
+++
b/activemq-broker/src/main/java/org/apache/activemq/broker/region/SubscriptionStatistics.java
@@ -14,13 +14,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.activemq.broker.region;
import org.apache.activemq.management.CountStatisticImpl;
import org.apache.activemq.management.SizeStatisticImpl;
import org.apache.activemq.management.StatsImpl;
+import java.util.Set;
+
/**
* The J2EE Statistics for a Subsription.
*/
@@ -32,7 +33,6 @@ public class SubscriptionStatistics extends StatsImpl {
protected CountStatisticImpl dispatched;
protected SizeStatisticImpl inflightMessageSize;
-
public SubscriptionStatistics() {
this(true);
}
@@ -45,12 +45,7 @@ public class SubscriptionStatistics extends StatsImpl {
dequeues = new CountStatisticImpl("dequeues", "The number of messages
that have been acknowledged from the subscription");
inflightMessageSize = new SizeStatisticImpl("inflightMessageSize",
"The size in bytes of messages dispatched but awaiting acknowledgement");
- addStatistic("consumedCount", consumedCount);
- addStatistic("enqueues", enqueues);
- addStatistic("dispatched", dispatched);
- addStatistic("dequeues", dequeues);
- addStatistic("inflightMessageSize", inflightMessageSize);
-
+ addStatistics(Set.of(consumedCount, enqueues, dispatched, dequeues,
inflightMessageSize));
this.setEnabled(enabled);
}
diff --git
a/activemq-broker/src/main/java/org/apache/activemq/network/NetworkBridgeStatistics.java
b/activemq-broker/src/main/java/org/apache/activemq/network/NetworkBridgeStatistics.java
index 50c3951279..a9157dcbd1 100644
---
a/activemq-broker/src/main/java/org/apache/activemq/network/NetworkBridgeStatistics.java
+++
b/activemq-broker/src/main/java/org/apache/activemq/network/NetworkBridgeStatistics.java
@@ -14,12 +14,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.activemq.network;
import org.apache.activemq.management.CountStatisticImpl;
import org.apache.activemq.management.StatsImpl;
+import java.util.Set;
+
/**
* The Statistics for a NetworkBridge.
*/
@@ -34,9 +35,7 @@ public class NetworkBridgeStatistics extends StatsImpl {
dequeues = new CountStatisticImpl("dequeues", "The current number of
dequeues this bridge has, which is the number of messages received by the
remote broker.");
receivedCount = new CountStatisticImpl("receivedCount", "The number of
messages that have been received by the NetworkBridge from the remote broker.
Only applies for Duplex bridges.");
- addStatistic("enqueues", enqueues);
- addStatistic("dequeues", dequeues);
- addStatistic("receivedCount", receivedCount);
+ addStatistics(Set.of(enqueues, dequeues, receivedCount));
}
/**
diff --git
a/activemq-broker/src/main/java/org/apache/activemq/store/AbstractMessageStoreStatistics.java
b/activemq-broker/src/main/java/org/apache/activemq/store/AbstractMessageStoreStatistics.java
index 249b767285..08913eb8b8 100644
---
a/activemq-broker/src/main/java/org/apache/activemq/store/AbstractMessageStoreStatistics.java
+++
b/activemq-broker/src/main/java/org/apache/activemq/store/AbstractMessageStoreStatistics.java
@@ -21,13 +21,14 @@ import org.apache.activemq.management.CountStatisticImpl;
import org.apache.activemq.management.SizeStatisticImpl;
import org.apache.activemq.management.StatsImpl;
+import java.util.Set;
+
public abstract class AbstractMessageStoreStatistics extends StatsImpl {
protected final CountStatisticImpl messageCount;
protected final SizeStatisticImpl messageSize;
-
protected AbstractMessageStoreStatistics(String countDescription, String
sizeDescription) {
this(true, countDescription, sizeDescription);
}
@@ -37,9 +38,7 @@ public abstract class AbstractMessageStoreStatistics extends
StatsImpl {
messageCount = new CountStatisticImpl("messageCount",
countDescription);
messageSize = new SizeStatisticImpl("messageSize", sizeDescription);
- addStatistic("messageCount", messageCount);
- addStatistic("messageSize", messageSize);
-
+ addStatistics(Set.of(messageCount, messageSize));
this.setEnabled(enabled);
}
diff --git
a/activemq-broker/src/main/java/org/apache/activemq/store/MessageStoreStatistics.java
b/activemq-broker/src/main/java/org/apache/activemq/store/MessageStoreStatistics.java
index 0a2b021610..881625b499 100644
---
a/activemq-broker/src/main/java/org/apache/activemq/store/MessageStoreStatistics.java
+++
b/activemq-broker/src/main/java/org/apache/activemq/store/MessageStoreStatistics.java
@@ -14,13 +14,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.activemq.store;
import org.apache.activemq.management.CountStatisticImpl;
import org.apache.activemq.management.SizeStatisticImpl;
import org.apache.activemq.management.StatsImpl;
+import java.util.Set;
+
/**
* The J2EE Statistics for a Message Sore
*/
@@ -39,9 +40,7 @@ public class MessageStoreStatistics extends StatsImpl {
messageCount = new CountStatisticImpl("messageCount", "The number of
messages in the store passing through the destination");
messageSize = new SizeStatisticImpl("messageSize","Size of messages in
the store passing through the destination");
- addStatistic("messageCount", messageCount);
- addStatistic("messageSize", messageSize);
-
+ addStatistics(Set.of(messageCount, messageSize));
this.setEnabled(enabled);
}
diff --git
a/activemq-broker/src/main/java/org/apache/activemq/store/PersistenceAdapterStatistics.java
b/activemq-broker/src/main/java/org/apache/activemq/store/PersistenceAdapterStatistics.java
index 23a112cacf..8a5e1bb6f8 100644
---
a/activemq-broker/src/main/java/org/apache/activemq/store/PersistenceAdapterStatistics.java
+++
b/activemq-broker/src/main/java/org/apache/activemq/store/PersistenceAdapterStatistics.java
@@ -16,6 +16,7 @@
*/
package org.apache.activemq.store;
+import java.util.Set;
import org.apache.activemq.management.StatsImpl;
import org.apache.activemq.management.TimeStatisticImpl;
@@ -31,14 +32,11 @@ public class PersistenceAdapterStatistics extends StatsImpl
{
slowCleanupTime = new TimeStatisticImpl("slowCleanupTime", "Slow time
to cleanup data in the PersistentAdapter.");
slowWriteTime = new TimeStatisticImpl("slowWriteTime", "Slow time to
write data to the PersistentAdapter.");
slowReadTime = new TimeStatisticImpl("slowReadTime", "Slow time to
read data from the PersistentAdapter.");
- addStatistic("slowCleanupTime", slowCleanupTime);
- addStatistic("slowWriteTime", slowWriteTime);
- addStatistic("slowReadTime", slowReadTime);
-
+
writeTime = new TimeStatisticImpl("writeTime", "Time to write data to
the PersistentAdapter.");
readTime = new TimeStatisticImpl("readTime", "Time to read data from
the PersistentAdapter.");
- addStatistic("writeTime", writeTime);
- addStatistic("readTime", readTime);
+
+ addStatistics(Set.of(slowCleanupTime, slowWriteTime, slowReadTime,
writeTime, readTime));
}
public void addSlowCleanupTime(final long time) {
diff --git
a/activemq-client/src/main/java/org/apache/activemq/management/StatsImpl.java
b/activemq-client/src/main/java/org/apache/activemq/management/StatsImpl.java
index 46d24a685f..05f1d2ad8f 100644
---
a/activemq-client/src/main/java/org/apache/activemq/management/StatsImpl.java
+++
b/activemq-client/src/main/java/org/apache/activemq/management/StatsImpl.java
@@ -59,11 +59,11 @@ public class StatsImpl extends StatisticImpl implements
Stats, Resettable {
this.set.add(statistic);
}
- protected void addStatistics(Collection<StatisticImpl> statistics) {
+ protected void addStatistics(final Collection<StatisticImpl> statistics) {
this.set.addAll(statistics);
}
- protected void removeStatistics(Collection<StatisticImpl> statistics) {
+ protected void removeStatistics(final Collection<StatisticImpl>
statistics) {
this.set.removeAll(statistics);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact