mirror of https://github.com/apache/activemq.git
Added option to specify a properties file to configure the system
git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@418007 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b583afccc2
commit
52105b6c25
|
@ -36,6 +36,8 @@ import javax.jms.ConnectionMetaData;
|
|||
import java.util.Properties;
|
||||
import java.util.Enumeration;
|
||||
import java.io.IOException;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
|
||||
public abstract class AbstractJmsClientSystem extends AbstractObjectProperties {
|
||||
private static final Log log = LogFactory.getLog(AbstractJmsClientSystem.class);
|
||||
|
@ -227,4 +229,36 @@ public abstract class AbstractJmsClientSystem extends AbstractObjectProperties {
|
|||
}
|
||||
|
||||
protected abstract void runJmsClient(String clientName, int clientDestIndex, int clientDestCount);
|
||||
|
||||
protected static Properties parseStringArgs(String[] args) {
|
||||
File configFile = null;
|
||||
Properties props = new Properties();
|
||||
for (int i=0; i<args.length; i++) {
|
||||
String arg = args[i];
|
||||
if (arg.startsWith("-D") || arg.startsWith("-d")) {
|
||||
arg = arg.substring(2);
|
||||
}
|
||||
int index = arg.indexOf("=");
|
||||
String key = arg.substring(0, index);
|
||||
String val = arg.substring(index + 1);
|
||||
|
||||
if (key.equalsIgnoreCase("sysTest.propsConfigFile")) {
|
||||
if (!val.endsWith(".properties")) {
|
||||
val += ".properties";
|
||||
}
|
||||
configFile = new File(val);
|
||||
}
|
||||
props.setProperty(key, val);
|
||||
}
|
||||
|
||||
Properties fileProps = new Properties();
|
||||
try {
|
||||
fileProps.load(new FileInputStream(configFile));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
// Overwrite file settings with command line settings
|
||||
fileProps.putAll(props);
|
||||
return fileProps;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,20 +67,8 @@ public class JmsConsumerSystem extends AbstractJmsClientSystem {
|
|||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
Properties props = new Properties();
|
||||
for (int i=0; i<args.length; i++) {
|
||||
String arg = args[i];
|
||||
if (arg.startsWith("-D") || arg.startsWith("-d")) {
|
||||
arg = arg.substring(2);
|
||||
}
|
||||
int index = arg.indexOf("=");
|
||||
String key = arg.substring(0, index);
|
||||
String val = arg.substring(index + 1);
|
||||
props.setProperty(key, val);
|
||||
}
|
||||
|
||||
JmsConsumerSystem sys = new JmsConsumerSystem();
|
||||
sys.configureProperties(props);
|
||||
sys.configureProperties(AbstractJmsClientSystem.parseStringArgs(args));
|
||||
|
||||
try {
|
||||
sys.runSystemTest();
|
||||
|
|
|
@ -67,20 +67,8 @@ public class JmsProducerSystem extends AbstractJmsClientSystem {
|
|||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
Properties props = new Properties();
|
||||
for (int i=0; i<args.length; i++) {
|
||||
String arg = args[i];
|
||||
if (arg.startsWith("-D") || arg.startsWith("-d")) {
|
||||
arg = arg.substring(2);
|
||||
}
|
||||
int index = arg.indexOf("=");
|
||||
String key = arg.substring(0, index);
|
||||
String val = arg.substring(index + 1);
|
||||
props.setProperty(key, val);
|
||||
}
|
||||
|
||||
JmsProducerSystem sys = new JmsProducerSystem();
|
||||
sys.configureProperties(props);
|
||||
sys.configureProperties(AbstractJmsClientSystem.parseStringArgs(args));
|
||||
|
||||
try {
|
||||
sys.runSystemTest();
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
*/
|
||||
package org.apache.activemq.tool.properties;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class JmsClientSystemProperties extends AbstractObjectProperties {
|
||||
public static final String DEST_DISTRO_ALL = "all"; // Each client will send/receive to all destination;
|
||||
public static final String DEST_DISTRO_EQUAL = "equal"; // Equally divide the number of destinations to the number of clients
|
||||
|
@ -27,6 +29,8 @@ public class JmsClientSystemProperties extends AbstractObjectProperties {
|
|||
public static final String SAMPLER_TP = "tp";
|
||||
public static final String SAMPLER_CPU = "cpu";
|
||||
|
||||
protected File propsConfigFile = null;
|
||||
|
||||
protected String reportType = REPORT_XML_FILE;
|
||||
protected String reportDir = "./";
|
||||
protected String reportName = null;
|
||||
|
@ -110,4 +114,12 @@ public class JmsClientSystemProperties extends AbstractObjectProperties {
|
|||
public void setDestDistro(String destDistro) {
|
||||
this.destDistro = destDistro;
|
||||
}
|
||||
|
||||
public String getPropsConfigFile() {
|
||||
return this.propsConfigFile + "";
|
||||
}
|
||||
|
||||
public void setPropsConfigFile(String propsConfigFile) {
|
||||
this.propsConfigFile = new File(propsConfigFile);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue