[
https://issues.apache.org/jira/browse/AMQ-8463?focusedWorklogId=953477&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-953477
]
ASF GitHub Bot logged work on AMQ-8463:
---------------------------------------
Author: ASF GitHub Bot
Created on: 21/Jan/25 23:56
Start Date: 21/Jan/25 23:56
Worklog Time Spent: 10m
Work Description: mattrpav commented on code in PR #1329:
URL: https://github.com/apache/activemq/pull/1329#discussion_r1924507296
##########
activemq-client/src/main/java/org/apache/activemq/management/StatisticImpl.java:
##########
@@ -15,22 +15,19 @@
* limitations under the License.
*/
package org.apache.activemq.management;
-
/**
- * Base class for a Statistic implementation
- *
- *
+ * A thread-safe class for a Statistic implementation
*/
public class StatisticImpl implements Statistic, Resettable {
- protected boolean enabled;
+ protected volatile boolean enabled;
- private String name;
- private String unit;
- private String description;
- private long startTime;
- private long lastSampleTime;
- private boolean doReset = true;
+ protected final String name;
Review Comment:
Changes applied via commit c079d1bd03df5a2faf35f2ec9625e7e51b2a4973
##########
activemq-client/src/main/java/org/apache/activemq/management/StatsImpl.java:
##########
@@ -38,44 +35,35 @@ public StatsImpl(Set<StatisticImpl> set) {
this.set = set;
}
- public void reset() {
- Statistic[] stats = getStatistics();
- int size = stats.length;
- for (int i = 0; i < size; i++) {
- Statistic stat = stats[i];
- if (stat instanceof Resettable) {
- Resettable r = (Resettable) stat;
- r.reset();
- }
- }
+ public synchronized void reset() {
+ this.set.stream()
+ .filter(Resettable.class::isInstance)
+ .map(Resettable.class::cast)
+ .forEach(resetStat -> resetStat.reset());
}
- public Statistic getStatistic(String name) {
- for (StatisticImpl stat : this.set) {
- if (stat.getName() != null && stat.getName().equals(name)) {
- return stat;
- }
- }
- return null;
+ public synchronized Statistic getStatistic(String name) {
+ return this.set.stream().filter(s ->
s.getName().equals(name)).findFirst().orElse(null);
}
- public String[] getStatisticNames() {
- List<String> names = new ArrayList<String>();
- for (StatisticImpl stat : this.set) {
- names.add(stat.getName());
- }
- String[] answer = new String[names.size()];
- names.toArray(answer);
- return answer;
+ public synchronized String[] getStatisticNames() {
+ return
this.set.stream().map(StatisticImpl::getName).toArray(String[]::new);
}
- public Statistic[] getStatistics() {
- Statistic[] answer = new Statistic[this.set.size()];
- set.toArray(answer);
- return answer;
+ public synchronized Statistic[] getStatistics() {
+ return this.set.toArray(new Statistic[this.set.size()]);
}
- protected void addStatistic(String name, StatisticImpl statistic) {
+ @Deprecated(forRemoval = true, since = "6.2.0")
+ protected synchronized void addStatistic(String name, StatisticImpl
statistic) {
this.set.add(statistic);
}
+
+ protected synchronized void addStatistics(Collection<StatisticImpl>
statistics) {
Review Comment:
Changes applied via commit c079d1bd03df5a2faf35f2ec9625e7e51b2a4973
Issue Time Tracking
-------------------
Worklog Id: (was: 953477)
Time Spent: 6h 10m (was: 6h)
> Add advancedMessageStatistics to destinations
> ---------------------------------------------
>
> Key: AMQ-8463
> URL: https://issues.apache.org/jira/browse/AMQ-8463
> Project: ActiveMQ Classic
> Issue Type: Improvement
> Components: Broker
> Reporter: Matt Pavlovich
> Assignee: Jean-Baptiste Onofré
> Priority: Major
> Fix For: 6.2.0, 5.18.7
>
> Time Spent: 6h 10m
> Remaining Estimate: 0h
>
> Observability and tracking metrics on the destination can provide current
> message age and indication of message flow activity.
> // Most recent enqueued message info
> enqueuedMessageID
> enqueuedMessageTimestamp
> enqueuedMessageBrokerInTime
> // Most recent dequeued message info
> dequeuedMessageID
> dequeuedMessageTimestamp
> dequeuedMessageBrokerInTime
> // First enqueue since boot
> firstEnqueuedMessageID
> firstEnqueuedMessageTimestamp
> firstEnqueuedMessageBrokerInTime
> // First dequeue since boot
> firstDequeuedMessageID
> firstDequeuedMessageTimestamp
> firstDequeuedMessageBrokerInTime
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact