diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/perf/PerfClientCommand.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/perf/PerfClientCommand.java index e8e7159fd4c..0ffb4480423 100644 --- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/perf/PerfClientCommand.java +++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/perf/PerfClientCommand.java @@ -209,6 +209,191 @@ public Object execute(ActionContext context) throws Exception { // topic destinations instead. destinations = Collections.singletonList(ActiveMQDestination.TOPIC_QUALIFIED_PREFIX + "TEST"); } + + if (durableSubscription && clientID == null) { + throw new IllegalArgumentException("The clientID must be set on durable subscriptions"); + } + return super.execute(context); } + + public boolean isTransaction() { + return transaction; + } + + public PerfClientCommand setTransaction(boolean transaction) { + this.transaction = transaction; + return this; + } + + public int getSharedSubscription() { + return sharedSubscription; + } + + public PerfClientCommand setSharedSubscription(int sharedSubscription) { + this.sharedSubscription = sharedSubscription; + return this; + } + + public boolean isDurableSubscription() { + return durableSubscription; + } + + public PerfClientCommand setDurableSubscription(boolean durableSubscription) { + this.durableSubscription = durableSubscription; + return this; + } + + public int getConsumerConnections() { + return consumerConnections; + } + + public PerfClientCommand setConsumerConnections(int consumerConnections) { + this.consumerConnections = consumerConnections; + return this; + } + + public int getConsumersPerDestination() { + return consumersPerDestination; + } + + public PerfClientCommand setConsumersPerDestination(int consumersPerDestination) { + this.consumersPerDestination = consumersPerDestination; + return this; + } + + public boolean isPersistent() { + return persistent; + } + + public PerfClientCommand setPersistent(boolean persistent) { + this.persistent = persistent; + return this; + } + + public int getMessageSize() { + return messageSize; + } + + public PerfClientCommand setMessageSize(int messageSize) { + this.messageSize = messageSize; + return this; + } + + public Long getRate() { + return rate; + } + + public PerfClientCommand setRate(Long rate) { + this.rate = rate; + return this; + } + + public long getTtl() { + return ttl; + } + + public PerfClientCommand setTtl(long ttl) { + this.ttl = ttl; + return this; + } + + public String getMsgGroupID() { + return msgGroupID; + } + + public PerfClientCommand setMsgGroupID(String msgGroupID) { + this.msgGroupID = msgGroupID; + return this; + } + + public boolean isSharedConnections() { + return sharedConnections; + } + + public PerfClientCommand setSharedConnections(boolean sharedConnections) { + this.sharedConnections = sharedConnections; + return this; + } + + public long getTxSize() { + return txSize; + } + + public PerfClientCommand setTxSize(long txSize) { + this.txSize = txSize; + return this; + } + + public int getProducersPerDestination() { + return producersPerDestination; + } + + public PerfClientCommand setProducersPerDestination(int producersPerDestination) { + this.producersPerDestination = producersPerDestination; + return this; + } + + public int getThreads() { + return threads; + } + + public PerfClientCommand setThreads(int threads) { + this.threads = threads; + return this; + } + + public long getMaxPending() { + return maxPending; + } + + public PerfClientCommand setMaxPending(long maxPending) { + this.maxPending = maxPending; + return this; + } + + public String getConsumerUrl() { + return consumerUrl; + } + + public PerfClientCommand setConsumerUrl(String consumerUrl) { + this.consumerUrl = consumerUrl; + return this; + } + + public String getConsumerProtocol() { + return consumerProtocol; + } + + public PerfClientCommand setConsumerProtocol(String consumerProtocol) { + this.consumerProtocol = consumerProtocol; + return this; + } + + public boolean isEnableMessageID() { + return enableMessageID; + } + + public PerfClientCommand setEnableMessageID(boolean enableMessageID) { + this.enableMessageID = enableMessageID; + return this; + } + + public boolean isEnableTimestamp() { + return enableTimestamp; + } + + public PerfClientCommand setEnableTimestamp(boolean enableTimestamp) { + this.enableTimestamp = enableTimestamp; + return this; + } + + public BenchmarkService getProducerBenchmark() { + return producerBenchmark; + } + + public PerfClientCommand setProducerBenchmark(BenchmarkService producerBenchmark) { + this.producerBenchmark = producerBenchmark; + return this; + } } diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/perf/PerfCommand.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/perf/PerfCommand.java index c30dc598995..0d57c752aef 100644 --- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/perf/PerfCommand.java +++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/messages/perf/PerfCommand.java @@ -151,4 +151,79 @@ private static Destination[] lookupDestinations(final ConnectionFactory factory, return jmsDestinations; } + public boolean isShowLatency() { + return showLatency; + } + + public PerfCommand setShowLatency(boolean showLatency) { + this.showLatency = showLatency; + return this; + } + + public String getReportFileName() { + return reportFileName; + } + + public PerfCommand setReportFileName(String reportFileName) { + this.reportFileName = reportFileName; + return this; + } + + public String getHdrFileName() { + return hdrFileName; + } + + public PerfCommand setHdrFileName(String hdrFileName) { + this.hdrFileName = hdrFileName; + return this; + } + + public int getDuration() { + return duration; + } + + public PerfCommand setDuration(int duration) { + this.duration = duration; + return this; + } + + public int getWarmup() { + return warmup; + } + + public PerfCommand setWarmup(int warmup) { + this.warmup = warmup; + return this; + } + + public long getMessageCount() { + return messageCount; + } + + public PerfCommand setMessageCount(long messageCount) { + this.messageCount = messageCount; + return this; + } + + public int getNumDestinations() { + return numDestinations; + } + + public PerfCommand setNumDestinations(int numDestinations) { + this.numDestinations = numDestinations; + return this; + } + + public List getDestinations() { + return destinations; + } + + public PerfCommand setDestinations(List destinations) { + this.destinations = destinations; + return this; + } + + public CountDownLatch getCompleted() { + return completed; + } } diff --git a/artemis-cli/src/test/java/org/apache/activemq/cli/test/CliPerfClientTest.java b/artemis-cli/src/test/java/org/apache/activemq/cli/test/CliPerfClientTest.java index aa487ec5991..9f6668ade42 100644 --- a/artemis-cli/src/test/java/org/apache/activemq/cli/test/CliPerfClientTest.java +++ b/artemis-cli/src/test/java/org/apache/activemq/cli/test/CliPerfClientTest.java @@ -16,10 +16,10 @@ */ package org.apache.activemq.cli.test; -import org.apache.activemq.artemis.cli.commands.ActionContext; import org.apache.activemq.artemis.cli.commands.messages.perf.PerfClientCommand; import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory; import org.junit.After; +import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -46,26 +46,22 @@ public void tearDown() throws Exception { super.tearDown(); } - private void start(boolean durable) throws Exception { - PerfClientCommand command = new PerfClientCommand() { - @Override - public Object execute(ActionContext context) throws Exception { - clientID = "perfClientTest"; - durableSubscription = durable; - messageCount = 1; - return super.execute(context); - } - }; - command.setUser("admin").setPassword("admin").execute(new TestActionContext()); - } - @Test public void testNonDurableStarts() throws Exception { - start(false); + new PerfClientCommand().setDurableSubscription(false).setMessageCount(1).setUser("admin").setPassword("admin").setClientID("perfClientTest").execute(new TestActionContext()); } @Test public void testDurableStarts() throws Exception { - start(true); + new PerfClientCommand().setDurableSubscription(true).setMessageCount(1).setUser("admin").setPassword("admin").setClientID("perfClientTest").execute(new TestActionContext()); + } + + @Test + public void testDurableNoClientIDSet() throws Exception { + try { + new PerfClientCommand().setDurableSubscription(true).setMessageCount(1).setUser("admin").setPassword("admin").execute(new TestActionContext()); + Assert.fail("Exception expected"); + } catch (IllegalArgumentException cliExpected) { + } } } \ No newline at end of file