Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/test/java/com/rabbitmq/examples/PerfTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@


public class PerfTest {
public static void main(String[] args) {

public static void main(String[] args) {
Options options = getOptions();
CommandLineParser parser = new GnuParser();
try {
Expand Down Expand Up @@ -82,7 +82,7 @@ public static void main(String[] args) {
1000L * samplingInterval,
producerCount > 0,
consumerCount > 0,
(flags.contains("mandatory") ||
(flags.contains("mandatory") ||
flags.contains("immediate")),
confirm != -1);

Expand Down Expand Up @@ -118,7 +118,7 @@ public static void main(String[] args) {
p.setProducerRateLimit(producerRateLimit);
p.setTimeLimit( timeLimit);

MulticastSet set = new MulticastSet(stats, factory, p);
MulticastSet set = new MulticastSet(stats, factory, p, testID);
set.run(true);

stats.printFinal();
Expand All @@ -141,7 +141,7 @@ private static void usage(Options options) {
private static Options getOptions() {
Options options = new Options();
options.addOption(new Option("?", "help", false,"show usage"));
options.addOption(new Option("d", "id", true, "Test ID"));
options.addOption(new Option("d", "id", true, "test ID"));
options.addOption(new Option("h", "uri", true, "connection URI"));
options.addOption(new Option("t", "type", true, "exchange type"));
options.addOption(new Option("e", "exchange", true, "exchange name"));
Expand Down Expand Up @@ -198,7 +198,7 @@ private static class PrintlnStats extends Stats {
private final boolean recvStatsEnabled;
private final boolean returnStatsEnabled;
private final boolean confirmStatsEnabled;

private final String testID;

public PrintlnStats(String testID, long interval,
Expand All @@ -215,7 +215,7 @@ public PrintlnStats(String testID, long interval,
@Override
protected void report(long now) {
String output = "id: " + testID + ", ";

output += "time: " + String.format("%.3f", (now - startTime)/1000.0) + "s";
output +=
getRate("sent", sendCountInterval, sendStatsEnabled, elapsedInterval) +
Expand Down
26 changes: 20 additions & 6 deletions src/test/java/com/rabbitmq/examples/perf/MulticastSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@

package com.rabbitmq.examples.perf;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

import java.io.IOException;
import java.util.UUID;
import java.util.concurrent.TimeoutException;

import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

public class MulticastSet {
private final String id;
private final Stats stats;
private final ConnectionFactory factory;
private final MulticastParams params;
private final String testID;

public MulticastSet(Stats stats, ConnectionFactory factory,
MulticastParams params) {
Expand All @@ -39,6 +39,20 @@ public MulticastSet(Stats stats, ConnectionFactory factory,
this.stats = stats;
this.factory = factory;
this.params = params;
this.testID = "perftest";
}

public MulticastSet(Stats stats, ConnectionFactory factory,
MulticastParams params, String testID) {
if (params.getRoutingKey() == null) {
this.id = UUID.randomUUID().toString();
} else {
this.id = params.getRoutingKey();
}
this.stats = stats;
this.factory = factory;
this.params = params;
this.testID = testID;
}

public void run() throws IOException, InterruptedException, TimeoutException {
Expand All @@ -50,7 +64,7 @@ public void run(boolean announceStartup) throws IOException, InterruptedExceptio
Connection[] consumerConnections = new Connection[consumerThreads.length];
for (int i = 0; i < consumerConnections.length; i++) {
if (announceStartup) {
System.out.println("starting consumer #" + i);
System.out.println("id: " + testID + ", starting consumer #" + i);
}
Connection conn = factory.newConnection();
consumerConnections[i] = conn;
Expand All @@ -68,7 +82,7 @@ public void run(boolean announceStartup) throws IOException, InterruptedExceptio
Connection[] producerConnections = new Connection[producerThreads.length];
for (int i = 0; i < producerThreads.length; i++) {
if (announceStartup) {
System.out.println("starting producer #" + i);
System.out.println("id: " + testID + ", starting producer #" + i);
}
Connection conn = factory.newConnection();
producerConnections[i] = conn;
Expand Down