[
https://issues.apache.org/jira/browse/AMQ-8463?focusedWorklogId=948782&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-948782
]
ASF GitHub Bot logged work on AMQ-8463:
---------------------------------------
Author: ASF GitHub Bot
Created on: 17/Dec/24 15:10
Start Date: 17/Dec/24 15:10
Worklog Time Spent: 10m
Work Description: cshannon commented on code in PR #1329:
URL: https://github.com/apache/activemq/pull/1329#discussion_r1888679702
##########
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:
This also doesn't make a lot of sense, you don't need to synchronize and
also use a CopyOnWriteArrayList.
Issue Time Tracking
-------------------
Worklog Id: (was: 948782)
Time Spent: 4h 10m (was: 4h)
> 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
>
> Time Spent: 4h 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