Fix cassandra-stress JMX connection

Patch by Berenguer Blasi; reviewed by brandonwilliams for CASSANDRA-16473
This commit is contained in:
Bereng 2021-03-03 08:26:00 +01:00 committed by Brandon Williams
parent d29dd643df
commit 2d9d17894d
4 changed files with 40 additions and 6 deletions

View File

@ -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)

View File

@ -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
-->

View File

@ -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);

View File

@ -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());
}
}