diff --git a/tooling/maven-perf-plugin/pom.xml b/tooling/maven-perf-plugin/pom.xml new file mode 100644 index 0000000000..6c9090c2ea --- /dev/null +++ b/tooling/maven-perf-plugin/pom.xml @@ -0,0 +1,62 @@ + + + 4.0.0 + + + incubator-activemq + activemq-parent + 4.0-SNAPSHOT + ../../pom.xml + + + + incubator-activemq + maven-perf-plugin + maven-plugin + ActiveMQ :: Performance Test Plugin + + + + org.apache.maven + maven-plugin-api + 2.0 + + + junit + junit + 3.8.1 + test + + + incubator-activemq + activemq-core + 4.0-SNAPSHOT + + + incubator-activemq + activemq-console + 4.0-SNAPSHOT + + + incubator-activemq + activemq-perftest + 4.0-SNAPSHOT + + + org.apache.derby + derby + 10.1.1.0 + + + org.apache.derby + derbynet + 10.1.1.0 + + + org.apache.geronimo.specs + geronimo-j2ee-management_1.0_spec + 1.0 + + + \ No newline at end of file diff --git a/tooling/maven-perf-plugin/src/main/java/org/apache/activemq/maven/ConsumerMojo.java b/tooling/maven-perf-plugin/src/main/java/org/apache/activemq/maven/ConsumerMojo.java new file mode 100644 index 0000000000..fc991b4301 --- /dev/null +++ b/tooling/maven-perf-plugin/src/main/java/org/apache/activemq/maven/ConsumerMojo.java @@ -0,0 +1,69 @@ +package org.apache.activemq.maven; + +/* + * Copyright 2001-2005 The Apache Software Foundation. + * + * Licensed 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. + */ + +import org.apache.activemq.tool.ConsumerTool; +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; + + +/** + * Goal which touches a timestamp file. + * + * @goal consumer + * @phase process + */ +public class ConsumerMojo + extends AbstractMojo { + + /** + * @parameter expression="${url}" default-value="tcp://localhost:61616" + * @required + */ + private String url; + + /** + * @parameter expression="${topic}" default-value="true" + * @required + */ + private String topic; + + /** + * @parameter expression="${subject}" default-value="FOO.BAR" + * @required + */ + private String subject; + + /** + * @parameter expression="${durable}" default-value="false" + * @required + */ + private String durable; + + /** + * @parameter expression="${maximumMessage}" default-value="10" + * @required + */ + private String maximumMessage; + + public void execute() + throws MojoExecutionException { + + String[] args = {url, topic, subject, durable, maximumMessage}; + ConsumerTool.main(args); + } +} diff --git a/tooling/maven-perf-plugin/src/main/java/org/apache/activemq/maven/ProducerMojo.java b/tooling/maven-perf-plugin/src/main/java/org/apache/activemq/maven/ProducerMojo.java new file mode 100644 index 0000000000..6f64a3c30c --- /dev/null +++ b/tooling/maven-perf-plugin/src/main/java/org/apache/activemq/maven/ProducerMojo.java @@ -0,0 +1,71 @@ +package org.apache.activemq.maven; + +import org.apache.activemq.tool.ConsumerTool; +import org.apache.activemq.tool.ProducerTool; +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; + +/* + * Copyright 2001-2005 The Apache Software Foundation. + * + * Licensed 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. + */ + + +/** + * Goal which touches a timestamp file. + * + * @goal producer + * @phase process + */ +public class ProducerMojo + extends AbstractMojo { + + /** + * @parameter expression="${url}" default-value="tcp://localhost:61616" + * @required + */ + private String url; + /** + * @parameter expression="${topic}" default-value="true" + * @required + */ + private String topic; + /** + * @parameter expression="${subject}" default-value="FOO.BAR" + * @required + */ + private String subject; + /** + * @parameter expression="${durable}" default-value="false" + * @required + */ + private String durable; + /** + * @parameter expression="${messageCount}" default-value="10" + * @required + */ + private String messageCount; + /** + * @parameter expression="${messageSize}" default-value="255" + * @required + */ + private String messageSize; + + public void execute() + throws MojoExecutionException { + + String[] args = {url,topic,subject,durable,messageCount,messageSize}; + ProducerTool.main(args); + } +} diff --git a/tooling/maven-perf-plugin/src/main/java/org/apache/activemq/maven/ServerMojo.java b/tooling/maven-perf-plugin/src/main/java/org/apache/activemq/maven/ServerMojo.java new file mode 100644 index 0000000000..5e70c88954 --- /dev/null +++ b/tooling/maven-perf-plugin/src/main/java/org/apache/activemq/maven/ServerMojo.java @@ -0,0 +1,124 @@ +package org.apache.activemq.maven; + +/* + * Copyright 2001-2005 The Apache Software Foundation. + * + * Licensed 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. + */ + +import org.apache.activemq.console.Main; +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.nio.MappedByteBuffer; +import java.nio.channels.FileChannel; + +/** + * Goal which starts activemq broker. + * + * @goal server + * @phase process + */ +public class ServerMojo + extends AbstractMojo { + /** + * Location of the output directory. Defaults to target. + * + * @parameter expression="${project.build.directory}" + * @required + */ + private File outputDirectory; + + /** + * Location of the predefined config files. + * + * @parameter expression="${configDirectory}" default-value="${basedir}/src/main/resources/config" + * @required + */ + private String configDirectory; + + /** + * Type of activemq configuration to use. This is also the filename used. + * + * @parameter expression="${configType}" default-value="activemq" + * @required + */ + private String configType; + + /** + * Location of activemq config file other those found in resources/config. + * + * @parameter expression="${configFile}" + */ + private File configFile; + + public void execute() + throws MojoExecutionException { + + File out = outputDirectory; + + // Create output directory if it doesn't exist. + if (!out.exists()) { + out.mkdirs(); + } + + File config; + if (configFile != null) { + config = configFile; + } else { + config = new File(configDirectory + File.separator + configType + ".xml"); + } + + try { + config = copy(config); + } catch (IOException e) { + throw new MojoExecutionException(e.getMessage()); + } + + String[] args = {"start", "xbean:" + (config.toURI()).toString()}; + Main.main(args); + } + + /** + * Copy activemq configuration file to output directory. + * + * @param source + * @return + * @throws IOException + */ + public File copy(File source) throws IOException { + FileChannel in = null, out = null; + + File dest = new File(outputDirectory.getAbsolutePath() + File.separator + "activemq.xml"); + + try { + in = new FileInputStream(source).getChannel(); + out = new FileOutputStream(dest).getChannel(); + + long size = in.size(); + MappedByteBuffer buf = in.map(FileChannel.MapMode.READ_ONLY, 0, size); + + out.write(buf); + + } finally { + if (in != null) in.close(); + if (out != null) out.close(); + } + + return dest; + } +} \ No newline at end of file