diff options
| author | Rajith Muditha Attapattu <rajith@apache.org> | 2011-02-14 15:21:44 +0000 |
|---|---|---|
| committer | Rajith Muditha Attapattu <rajith@apache.org> | 2011-02-14 15:21:44 +0000 |
| commit | 87515049a36ba1cfc24378cb231188a83c9dd5e7 (patch) | |
| tree | 6725fb112c567d5c0611b52fbcc1c452dc0fa50f /qpid/java/tools/src | |
| parent | 45b7f66230bd8db2b0242ce019da558dc4ebaa6e (diff) | |
| download | qpid-python-87515049a36ba1cfc24378cb231188a83c9dd5e7.tar.gz | |
QPID-3055
As the first step added system properties for host, port and address and got rid of the jndi lookup.
There is also a system property for URL which allows a user to specify a fully fledged URL with various connection options like SSL etc..
If the host & port is specified the URL property is ignored.
I also added some documentation in the perf_report.sh suggesting recommended settings for performance testing.
These are guidelines only and a prospective user needs to experiment with their environment to fine tune the settings.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1070519 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/tools/src')
| -rw-r--r-- | qpid/java/tools/src/main/java/org/apache/qpid/tools/PerfBase.java | 42 | ||||
| -rw-r--r-- | qpid/java/tools/src/main/java/org/apache/qpid/tools/TestParams.java | 58 |
2 files changed, 39 insertions, 61 deletions
diff --git a/qpid/java/tools/src/main/java/org/apache/qpid/tools/PerfBase.java b/qpid/java/tools/src/main/java/org/apache/qpid/tools/PerfBase.java index 88e75fb6a9..ac597d17de 100644 --- a/qpid/java/tools/src/main/java/org/apache/qpid/tools/PerfBase.java +++ b/qpid/java/tools/src/main/java/org/apache/qpid/tools/PerfBase.java @@ -30,6 +30,9 @@ import javax.jms.Session; import javax.naming.Context; import javax.naming.InitialContext; +import org.apache.qpid.client.AMQAnyDestination; +import org.apache.qpid.client.AMQConnection; + public class PerfBase { TestParams params; @@ -45,48 +48,21 @@ public class PerfBase } public void setUp() throws Exception - { - Hashtable<String,String> env = new Hashtable<String,String>(); - env.put(Context.INITIAL_CONTEXT_FACTORY, params.getInitialContextFactory()); - env.put(Context.PROVIDER_URL, params.getProviderURL()); + { - Context ctx = null; - try + if (params.getHost().equals("") || params.getPort() == -1) { - ctx = new InitialContext(env); + con = new AMQConnection(params.getUrl()); } - catch(Exception e) + else { - throw new Exception("Error initializing JNDI",e); - + con = new AMQConnection(params.getHost(),params.getPort(),"guest","guest","test","test"); } - - ConnectionFactory conFac = null; - try - { - conFac = (ConnectionFactory)ctx.lookup(params.getConnectionFactory()); - } - catch(Exception e) - { - throw new Exception("Error looking up connection factory",e); - } - - con = conFac.createConnection(); con.start(); session = con.createSession(params.isTransacted(), params.isTransacted()? Session.SESSION_TRANSACTED:params.getAckMode()); - try - { - dest = (Destination)ctx.lookup( params.isDurable()? - params.getDurableDestination(): - params.getTransientDestination() - ); - } - catch(Exception e) - { - throw new Exception("Error looking up destination",e); - } + dest = new AMQAnyDestination(params.getAddress()); } public void handleError(Exception e,String msg) diff --git a/qpid/java/tools/src/main/java/org/apache/qpid/tools/TestParams.java b/qpid/java/tools/src/main/java/org/apache/qpid/tools/TestParams.java index f1b682ff32..89d6462a39 100644 --- a/qpid/java/tools/src/main/java/org/apache/qpid/tools/TestParams.java +++ b/qpid/java/tools/src/main/java/org/apache/qpid/tools/TestParams.java @@ -24,15 +24,22 @@ import javax.jms.Session; public class TestParams { - private String initialContextFactory = "org.apache.qpid.jndi.PropertiesFileInitialContextFactory"; - - private String providerURL = System.getenv("QPID_TEST_HOME") + "/etc/jndi.properties"; - - private String connectionFactory = "connectionFactory"; - - private String transientDest = "transientQueue"; + /* + * By default the connection URL is used. + * This allows a user to easily specify a fully fledged URL any given property. + * Ex. SSL parameters + * + * By providing a host & port allows a user to simply override the URL. + * This allows to create multiple clients in test scripts easily, + * without having to deal with the long URL format. + */ + private String url = "amqp://guest:guest@clientid/testpath?brokerlist='tcp://localhost:5672'"; + + private String host = ""; + + private int port = -1; - private String durableDest = "durableQueue"; + private String address = "queue; {create : always}"; private int msg_size = 1024; @@ -60,11 +67,11 @@ public class TestParams public TestParams() { - initialContextFactory = System.getProperty("java.naming.factory.initial",initialContextFactory); - providerURL = System.getProperty("java.naming.provider.url",providerURL); - - transientDest = System.getProperty("transDest",transientDest); - durableDest = System.getProperty("durableDest",durableDest); + + url = System.getProperty("url",url); + host = System.getProperty("host",""); + port = Integer.getInteger("port", -1); + address = System.getProperty("address","queue"); msg_size = Integer.getInteger("msg_size", 1024); msg_type = Integer.getInteger("msg_type",1); @@ -80,29 +87,29 @@ public class TestParams random_msg_size = Boolean.getBoolean("random_msg_size"); } - public int getAckMode() + public String getUrl() { - return ack_mode; + return url; } - public String getConnectionFactory() + public String getHost() { - return connectionFactory; + return host; } - public String getTransientDestination() + public int getPort() { - return transientDest; + return port; } - public String getDurableDestination() + public String getAddress() { - return durableDest; + return address; } - public String getInitialContextFactory() + public int getAckMode() { - return initialContextFactory; + return ack_mode; } public int getMsgCount() @@ -125,11 +132,6 @@ public class TestParams return durable; } - public String getProviderURL() - { - return providerURL; - } - public boolean isTransacted() { return transacted; |
