This is an automated email from the ASF dual-hosted git repository.

maedhroz pushed a commit to branch cassandra-4.0
in repository https://gitbox.apache.org/repos/asf/cassandra.git


The following commit(s) were added to refs/heads/cassandra-4.0 by this push:
     new e6946e7  Make JmxHistogram#getRecentValues() thread-safe
e6946e7 is described below

commit e6946e7ddb76bd72109995664289e988b0e9818c
Author: Caleb Rackliffe <[email protected]>
AuthorDate: Wed Jun 2 14:56:41 2021 -0500

    Make JmxHistogram#getRecentValues() thread-safe
    
    patch by Caleb Rackliffe; reviewed by Brandon Williams and Yifan Cai for 
CASSANDRA-16707
---
 CHANGES.txt                                          |  1 +
 .../cassandra/metrics/CassandraMetricsRegistry.java  | 20 ++++++++++++++++++--
 2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/CHANGES.txt b/CHANGES.txt
index dc92a5b..d562f54 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 4.0-rc2
+ * Make JmxHistogram#getRecentValues() and JmxTimer#getRecentValues() 
thread-safe (CASSANDRA-16707)
  * Keep python driver in artifacts (CASSANDRA-16700)
  * Improve AuditLogging documentation and logback.xml(CASSANDRA-16682)
  * Spin up SEPWorker threads whenever we grow the number of work 
permits(CASSANDRA-16668)
diff --git 
a/src/java/org/apache/cassandra/metrics/CassandraMetricsRegistry.java 
b/src/java/org/apache/cassandra/metrics/CassandraMetricsRegistry.java
index 0b5bac5..1ae2455 100644
--- a/src/java/org/apache/cassandra/metrics/CassandraMetricsRegistry.java
+++ b/src/java/org/apache/cassandra/metrics/CassandraMetricsRegistry.java
@@ -388,8 +388,16 @@ public class CassandraMetricsRegistry extends 
MetricRegistry
             return metric.getSnapshot().getValues();
         }
 
+        /**
+         * Returns a histogram describing the values recorded since the last 
time this method was called.
+         *
+         * ex. If the counts are [0, 1, 2, 1] at the time the first caller 
arrives, but change to [1, 2, 3, 2] by the 
+         * time a second caller arrives, the second caller will receive [1, 1, 
1, 1].
+         *
+         * @return a histogram whose bucket offsets are assumed to be in 
nanoseconds
+         */
         @Override
-        public long[] getRecentValues()
+        public synchronized long[] getRecentValues()
         {
             long[] now = metric.getSnapshot().getValues();
             long[] delta = delta(now, last);
@@ -605,8 +613,16 @@ public class CassandraMetricsRegistry extends 
MetricRegistry
             return metric.getSnapshot().getValues();
         }
 
+        /**
+         * Returns a histogram describing the values recorded since the last 
time this method was called.
+         * 
+         * ex. If the counts are [0, 1, 2, 1] at the time the first caller 
arrives, but change to [1, 2, 3, 2] by the 
+         * time a second caller arrives, the second caller will receive [1, 1, 
1, 1].
+         * 
+         * @return a histogram whose bucket offsets are assumed to be in 
nanoseconds
+         */
         @Override
-        public long[] getRecentValues()
+        public synchronized long[] getRecentValues()
         {
             long[] now = metric.getSnapshot().getValues();
             long[] delta = delta(now, last);

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to