cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jji...@apache.org
Subject [2/6] cassandra git commit: Use a unique metric reservoir per test run when using Cassandra-wide metrics residing in MBeans
Date Fri, 17 Mar 2017 22:43:13 GMT
Use a unique metric reservoir per test run when using Cassandra-wide metrics residing in MBeans

Patch by Alex Petrov; reviewed by Michael Kjellman for CASSANDRA-13216.


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/1dcb3131
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/1dcb3131
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/1dcb3131

Branch: refs/heads/cassandra-3.11
Commit: 1dcb3131a4d7417634551456f1fe3f519fa17fd0
Parents: 5918375
Author: Alex Petrov <oleksandr.petrov@gmail.com>
Authored: Mon Mar 6 08:44:53 2017 +0100
Committer: Jeff Jirsa <jeff@jeffjirsa.net>
Committed: Fri Mar 17 15:26:14 2017 -0700

----------------------------------------------------------------------
 CHANGES.txt                                        |  1 +
 .../cassandra/metrics/DroppedMessageMetrics.java   |  6 +++++-
 .../org/apache/cassandra/net/MessagingService.java | 17 ++++++++++++++++-
 .../apache/cassandra/net/MessagingServiceTest.java |  8 ++++++++
 4 files changed, 30 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/1dcb3131/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 2017b78..97d8561 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 3.0.13
+ * Applying: Use a unique metric reservoir per test run when using Cassandra-wide metrics
residing in MBeans (CASSANDRA-13216)
  * Propagate row deletions in 2i tables on upgrade (CASSANDRA-13320)
  * Slice.isEmpty() returns false for some empty slices (CASSANDRA-13305)
  * Add formatted row output to assertEmpty in CQL Tester (CASSANDRA-13238)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/1dcb3131/src/java/org/apache/cassandra/metrics/DroppedMessageMetrics.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/metrics/DroppedMessageMetrics.java b/src/java/org/apache/cassandra/metrics/DroppedMessageMetrics.java
index 58c80fb..6d16f8b 100644
--- a/src/java/org/apache/cassandra/metrics/DroppedMessageMetrics.java
+++ b/src/java/org/apache/cassandra/metrics/DroppedMessageMetrics.java
@@ -32,7 +32,11 @@ public class DroppedMessageMetrics
 
     public DroppedMessageMetrics(MessagingService.Verb verb)
     {
-        MetricNameFactory factory = new DefaultNameFactory("DroppedMessage", verb.toString());
+        this(new DefaultNameFactory("DroppedMessage", verb.toString()));
+    }
+
+    public DroppedMessageMetrics(MetricNameFactory factory)
+    {
         dropped = Metrics.meter(factory.createMetricName("Dropped"));
     }
 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/1dcb3131/src/java/org/apache/cassandra/net/MessagingService.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/net/MessagingService.java b/src/java/org/apache/cassandra/net/MessagingService.java
index 31ea09e..e8095d3 100644
--- a/src/java/org/apache/cassandra/net/MessagingService.java
+++ b/src/java/org/apache/cassandra/net/MessagingService.java
@@ -65,6 +65,7 @@ import org.apache.cassandra.io.util.DataInputPlus;
 import org.apache.cassandra.io.util.DataOutputPlus;
 import org.apache.cassandra.io.util.FileUtils;
 import org.apache.cassandra.locator.ILatencySubscriber;
+import org.apache.cassandra.metrics.CassandraMetricsRegistry;
 import org.apache.cassandra.metrics.ConnectionMetrics;
 import org.apache.cassandra.metrics.DroppedMessageMetrics;
 import org.apache.cassandra.repair.messages.RepairMessage;
@@ -338,12 +339,26 @@ public final class MessagingService implements MessagingServiceMBean
 
         DroppedMessages(Verb verb)
         {
-            this.metrics = new DroppedMessageMetrics(verb);
+            this(new DroppedMessageMetrics(verb));
+        }
+
+        DroppedMessages(DroppedMessageMetrics metrics)
+        {
+            this.metrics = metrics;
             this.droppedInternalTimeout = new AtomicInteger(0);
             this.droppedCrossNodeTimeout = new AtomicInteger(0);
         }
+    }
 
+    @VisibleForTesting
+    public void resetDroppedMessagesMap(String scope)
+    {
+        for (Verb verb : droppedMessagesMap.keySet())
+            droppedMessagesMap.put(verb, new DroppedMessages(new DroppedMessageMetrics(metricName
-> {
+                return new CassandraMetricsRegistry.MetricName("DroppedMessages", metricName,
scope);
+            })));
     }
+
     // total dropped message counts for server lifetime
     private final Map<Verb, DroppedMessages> droppedMessagesMap = new EnumMap<>(Verb.class);
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/1dcb3131/test/unit/org/apache/cassandra/net/MessagingServiceTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/net/MessagingServiceTest.java b/test/unit/org/apache/cassandra/net/MessagingServiceTest.java
index 8631f03..3be1990 100644
--- a/test/unit/org/apache/cassandra/net/MessagingServiceTest.java
+++ b/test/unit/org/apache/cassandra/net/MessagingServiceTest.java
@@ -22,6 +22,7 @@ package org.apache.cassandra.net;
 
 import java.util.List;
 
+import org.junit.Before;
 import org.junit.Test;
 
 import static org.junit.Assert.assertEquals;
@@ -30,6 +31,13 @@ public class MessagingServiceTest
 {
     private final MessagingService messagingService = MessagingService.test();
 
+    private static int metricScopeId = 0;
+
+    @Before
+    public void before() {
+        messagingService.resetDroppedMessagesMap(Integer.toString(metricScopeId++));;
+    }
+
     @Test
     public void testDroppedMessages()
     {


Mime
View raw message