You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by br...@apache.org on 2021/03/03 15:35:31 UTC

[cassandra] branch trunk updated: Fix cassandra-stress JMX connection

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

brandonwilliams pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/cassandra.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 2d9d178  Fix cassandra-stress JMX connection
2d9d178 is described below

commit 2d9d17894dab365df09f515e37b62b658bce6594
Author: Bereng <be...@gmail.com>
AuthorDate: Wed Mar 3 08:26:00 2021 +0100

    Fix cassandra-stress JMX connection
    
    Patch by Berenguer Blasi; reviewed by brandonwilliams for CASSANDRA-16473
---
 CHANGES.txt                                        |  1 +
 build.xml                                          |  8 ++++++++
 .../cassandra/stress/report/StressMetrics.java     | 23 ++++++++++++++++------
 .../stress/settings/StressSettingsTest.java        | 14 +++++++++++++
 4 files changed, 40 insertions(+), 6 deletions(-)

diff --git a/CHANGES.txt b/CHANGES.txt
index 7b00c4a..5c7da2a 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 4.0-beta5
+ * Fix cassandra-stress JMX connection (CASSANDRA-16473)
  * Avoid processing redundant application states on endpoint changes (CASSANDRA-16381)
  * Prevent parent repair sessions leak (CASSANDRA-16446)
  * Fix timestamp issue in SinglePartitionSliceCommandTest testPartitionD…eletionRowDeletionTie (CASSANDRA-16443)
diff --git a/build.xml b/build.xml
index 5c93897..fee69a0 100644
--- a/build.xml
+++ b/build.xml
@@ -1089,6 +1089,14 @@
         </testmacro>
     </target>
 
+    <target name="stress-test-some" depends="stress-build-test, build-test" description="Runs stress tests">
+        <testmacro inputdir="${stress.test.src}"
+                       timeout="${test.timeout}">
+          <test unless:blank="${test.methods}" name="${test.name}" methods="${test.methods}" outfile="build/test/output/TEST-${test.name}-${test.methods}"/>
+          <test if:blank="${test.methods}" name="${test.name}" outfile="build/test/output/TEST-${test.name}"/>
+        </testmacro>
+    </target>
+
     <!--
         fqltool build file
         -->
diff --git a/tools/stress/src/org/apache/cassandra/stress/report/StressMetrics.java b/tools/stress/src/org/apache/cassandra/stress/report/StressMetrics.java
index a4058f2..b2afd1b 100644
--- a/tools/stress/src/org/apache/cassandra/stress/report/StressMetrics.java
+++ b/tools/stress/src/org/apache/cassandra/stress/report/StressMetrics.java
@@ -21,8 +21,6 @@ package org.apache.cassandra.stress.report;
  */
 
 
-import static java.util.concurrent.TimeUnit.NANOSECONDS;
-
 import java.io.FileNotFoundException;
 import java.util.ArrayDeque;
 import java.util.ArrayList;
@@ -31,11 +29,17 @@ import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Queue;
+import java.util.Set;
 import java.util.TreeMap;
 import java.util.concurrent.Callable;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.locks.LockSupport;
+import java.util.stream.Collectors;
+
+import com.google.common.annotations.VisibleForTesting;
+
+import org.apache.commons.lang3.time.DurationFormatUtils;
 
 import org.HdrHistogram.Histogram;
 import org.HdrHistogram.HistogramLogWriter;
@@ -45,11 +49,12 @@ import org.apache.cassandra.stress.StressAction.OpMeasurement;
 import org.apache.cassandra.stress.settings.SettingsLog.Level;
 import org.apache.cassandra.stress.settings.StressSettings;
 import org.apache.cassandra.stress.util.JmxCollector;
-import org.apache.cassandra.stress.util.ResultLogger;
 import org.apache.cassandra.stress.util.JmxCollector.GcStats;
+import org.apache.cassandra.stress.util.ResultLogger;
 import org.apache.cassandra.stress.util.Uncertainty;
 import org.apache.cassandra.utils.FBUtilities;
-import org.apache.commons.lang3.time.DurationFormatUtils;
+
+import static java.util.concurrent.TimeUnit.NANOSECONDS;
 
 public class StressMetrics implements MeasurementSink
 {
@@ -105,7 +110,8 @@ public class StressMetrics implements MeasurementSink
         totalGcStats = new JmxCollector.GcStats(0);
         try
         {
-            gcStatsCollector = new JmxCollector(settings.node.resolveAllPermitted(settings), settings.port.jmxPort);
+            gcStatsCollector = new JmxCollector(toJmxNodes(settings.node.resolveAllPermitted(settings)),
+                                                settings.port.jmxPort);
         }
         catch (Throwable t)
         {
@@ -150,7 +156,6 @@ public class StressMetrics implements MeasurementSink
         stopped.await();
     }
 
-
     private void reportingLoop(final long logIntervalMillis)
     {
         // align report timing to the nearest second
@@ -345,6 +350,12 @@ public class StressMetrics implements MeasurementSink
     public static final String[] HEADMETRICS = new String[]{"type", "total ops","op/s","pk/s","row/s","mean","med",".95",".99",".999","max","time","stderr", "errors", "gc: #", "max ms", "sum ms", "sdv ms", "mb"};
     public static final String HEAD = String.format(HEADFORMAT, (Object[]) HEADMETRICS);
 
+    @VisibleForTesting
+    public static Set<String> toJmxNodes(Set<String> nodes)
+    {
+        return nodes.stream().map(n -> n.split(":")[0]).collect(Collectors.toSet());
+    }
+
     private static void printHeader(String prefix, ResultLogger output)
     {
         output.println(prefix + HEAD);
diff --git a/tools/stress/test/unit/org/apache/cassandra/stress/settings/StressSettingsTest.java b/tools/stress/test/unit/org/apache/cassandra/stress/settings/StressSettingsTest.java
index c664aee..98578ef 100644
--- a/tools/stress/test/unit/org/apache/cassandra/stress/settings/StressSettingsTest.java
+++ b/tools/stress/test/unit/org/apache/cassandra/stress/settings/StressSettingsTest.java
@@ -20,11 +20,18 @@ package org.apache.cassandra.stress.settings;
 
 import java.io.ByteArrayOutputStream;
 import java.io.ObjectOutputStream;
+import java.util.Arrays;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Map;
+import java.util.Set;
 
 import org.junit.Test;
 
+import org.apache.cassandra.stress.report.StressMetrics;
+
+import static org.junit.Assert.assertEquals;
+
 public class StressSettingsTest
 {
     @Test
@@ -36,4 +43,11 @@ public class StressSettingsTest
         // Will throw if not all settings are Serializable
         new ObjectOutputStream(new ByteArrayOutputStream()).writeObject(settings);
     }
+
+    @Test
+    public void test16473()
+    {
+        Set<String> jmxNodes = StressMetrics.toJmxNodes(new HashSet<String>(Arrays.asList("127.0.0.1:9042", "127.0.0.1")));
+        assertEquals(0, jmxNodes.stream().filter(n -> n.contains(":")).count());
+    }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org