cshannon commented on code in PR #1329:
URL: https://github.com/apache/activemq/pull/1329#discussion_r1924396957


##########
activemq-broker/src/main/java/org/apache/activemq/broker/region/DestinationStatistics.java:
##########
@@ -233,6 +222,7 @@ public void setParent(DestinationStatistics parent) {
             
maxUncommittedExceededCount.setParent(parent.maxUncommittedExceededCount);
             networkEnqueues.setParent(parent.networkEnqueues);
             networkDequeues.setParent(parent.networkDequeues);
+            // [AMQ-9437] Advanced Message Statistics do not parent.

Review Comment:
   ```suggestion
               // [AMQ-9437] Advanced Message Statistics does not have a parent.
   ```



##########
activemq-broker/src/main/java/org/apache/activemq/broker/region/DestinationStatistics.java:
##########
@@ -252,7 +242,29 @@ public void setParent(DestinationStatistics parent) {
             maxUncommittedExceededCount.setParent(null);
             networkEnqueues.setParent(null);
             networkDequeues.setParent(null);
+            // [AMQ-9437] Advanced Message Statistics do not parent.

Review Comment:
   ```suggestion
               // [AMQ-9437] Advanced Message Statistics does not have a parent.
   ```



##########
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:
   I don't think any of these needs to be made protected, no child classes use 
them and if they need to read the value they could use a getter.



##########
activemq-broker/src/main/java/org/apache/activemq/broker/region/DestinationStatistics.java:
##########
@@ -252,7 +242,29 @@ public void setParent(DestinationStatistics parent) {
             maxUncommittedExceededCount.setParent(null);
             networkEnqueues.setParent(null);
             networkDequeues.setParent(null);
+            // [AMQ-9437] Advanced Message Statistics do not parent.
         }
     }
 
+    // This is the only method that can mutate the messageFlowStats state
+    // so we only need to synchronize this method to make sure we don't have 2 
threads
+    // trying to set at the same time.
+    public synchronized void setAdvancedMessageStatisticsEnabled(boolean 
enabled) {
+        // we can just use the get() here on the reference as no other spot can

Review Comment:
   You can get rid of this comment here after this was refactored



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscr...@activemq.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscr...@activemq.apache.org
For additional commands, e-mail: gitbox-h...@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact


Reply via email to