This closes #4154
This commit is contained in:
commit
3d5f588bbe
|
@ -18,6 +18,7 @@ package org.apache.activemq.artemis.cli.commands.messages.perf;
|
||||||
|
|
||||||
import javax.jms.ConnectionFactory;
|
import javax.jms.ConnectionFactory;
|
||||||
import javax.jms.Destination;
|
import javax.jms.Destination;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
import java.util.concurrent.LinkedTransferQueue;
|
import java.util.concurrent.LinkedTransferQueue;
|
||||||
|
@ -30,6 +31,7 @@ import io.netty.channel.DefaultEventLoop;
|
||||||
import io.netty.channel.DefaultEventLoopGroup;
|
import io.netty.channel.DefaultEventLoopGroup;
|
||||||
import io.netty.channel.EventLoop;
|
import io.netty.channel.EventLoop;
|
||||||
import org.apache.activemq.artemis.cli.commands.ActionContext;
|
import org.apache.activemq.artemis.cli.commands.ActionContext;
|
||||||
|
import org.apache.activemq.artemis.jms.client.ActiveMQDestination;
|
||||||
|
|
||||||
@Command(name = "client", description = "It will produce and consume messages to a broker instance")
|
@Command(name = "client", description = "It will produce and consume messages to a broker instance")
|
||||||
public class PerfClientCommand extends PerfCommand {
|
public class PerfClientCommand extends PerfCommand {
|
||||||
|
@ -199,4 +201,199 @@ public class PerfClientCommand extends PerfCommand {
|
||||||
benchmark.close();
|
benchmark.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object execute(ActionContext context) throws Exception {
|
||||||
|
if (durableSubscription && (destinations == null || destinations.isEmpty())) {
|
||||||
|
// An empty destination list would create a single queue://TEST destination but durable subscriptions require
|
||||||
|
// 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -151,4 +151,79 @@ public abstract class PerfCommand extends ConnectionAbstract {
|
||||||
return jmsDestinations;
|
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<String> getDestinations() {
|
||||||
|
return destinations;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PerfCommand setDestinations(List<String> destinations) {
|
||||||
|
this.destinations = destinations;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CountDownLatch getCompleted() {
|
||||||
|
return completed;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,67 @@
|
||||||
|
/*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership.
|
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
* (the "License"); you may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.apache.activemq.cli.test;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
import javax.jms.Connection;
|
||||||
|
|
||||||
|
public class CliPerfClientTest extends CliTestBase {
|
||||||
|
private Connection connection;
|
||||||
|
private ActiveMQConnectionFactory cf;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
@Override
|
||||||
|
public void setup() throws Exception {
|
||||||
|
setupAuth();
|
||||||
|
super.setup();
|
||||||
|
startServer();
|
||||||
|
cf = getConnectionFactory(61616);
|
||||||
|
connection = cf.createConnection("admin", "admin");
|
||||||
|
}
|
||||||
|
|
||||||
|
@After
|
||||||
|
@Override
|
||||||
|
public void tearDown() throws Exception {
|
||||||
|
closeConnection(cf, connection);
|
||||||
|
super.tearDown();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testNonDurableStarts() throws Exception {
|
||||||
|
new PerfClientCommand().setDurableSubscription(false).setMessageCount(1).setUser("admin").setPassword("admin").setClientID("perfClientTest").execute(new TestActionContext());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDurableStarts() throws Exception {
|
||||||
|
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) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue