[jboss-cvs] JBoss Messaging SVN: r2771 - in projects/perf/trunk: etc and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Jun 11 08:40:05 EDT 2007
Author: sergeypk
Date: 2007-06-11 08:40:05 -0400 (Mon, 11 Jun 2007)
New Revision: 2771
Added:
projects/perf/trunk/etc/perf.properties
projects/perf/trunk/src/main/org/jboss/jms/perf/framework/remoting/rmi/RegistryHelper.java
projects/perf/trunk/src/main/org/jboss/jms/perf/framework/remoting/rmi/RegistryLocation.java
projects/perf/trunk/src/main/org/jboss/jms/perf/framework/remoting/rmi/SimpleRMIClientSocketFactory.java
projects/perf/trunk/src/main/org/jboss/jms/perf/framework/remoting/rmi/SingleAddressRMIServerSocketFactory.java
Removed:
projects/perf/trunk/src/main/org/jboss/jms/perf/framework/remoting/rmi/RMIURL.java
Modified:
projects/perf/trunk/build-perf.xml
projects/perf/trunk/etc/perf.xml
projects/perf/trunk/src/etc/rmi-executor-service.xml
projects/perf/trunk/src/main/org/jboss/jms/perf/framework/remoting/rmi/ExecutorKiller.java
projects/perf/trunk/src/main/org/jboss/jms/perf/framework/remoting/rmi/RMICoordinator.java
projects/perf/trunk/src/main/org/jboss/jms/perf/framework/remoting/rmi/RMIExecutor.java
projects/perf/trunk/src/main/org/jboss/jms/perf/framework/remoting/rmi/RegistryKiller.java
projects/perf/trunk/src/main/org/jboss/jms/perf/framework/remoting/rmi/RegistryRunner.java
Log:
Configure registry host and port in a single place (etc/perf.properties).
Make registry only listen on the configured hostname, not on all available interfaces.
Modified: projects/perf/trunk/build-perf.xml
===================================================================
--- projects/perf/trunk/build-perf.xml 2007-06-11 12:10:15 UTC (rev 2770)
+++ projects/perf/trunk/build-perf.xml 2007-06-11 12:40:05 UTC (rev 2771)
@@ -55,15 +55,6 @@
<taskdef resource="net/sf/antcontrib/antcontrib.properties"/>
<!--
- JMS implementations used in the benchmark.
-
- Place JARs for each implementation under lib/providers/<implementation-name> directory.
- Each implementation will have its remote executors named 'remote-<implementation-name>'
- and 'remote-<implementation-name>2'
- -->
- <property name="providers" value="jbossmq messaging activemq qpid" />
-
- <!--
Project paths.
-->
@@ -89,6 +80,8 @@
<property name="build.scoped-sar" value="${project.output}/scoped-sar"/>
<property name="project.thirdparty" value="${project.root}/thirdparty"/>
+ <property file="${project.root}/etc/perf.properties" />
+
<!-- ======================================================================================== -->
<!-- Thirdparty Dependency Definitions -->
<!-- ======================================================================================== -->
@@ -223,6 +216,8 @@
<filterset>
<filter token="NAME_1" value="local-jbossmq"/>
<filter token="NAME_2" value="local-jbossmq2"/>
+ <filter token="REGISTRY_HOST" value="${perf.registry.host}" />
+ <filter token="REGISTRY_PORT" value="${perf.registry.port}" />
</filterset>
</copy>
<copy file="${project.source}/etc/RMIExecutor-xmbean.xml" todir="${build.classes}/xmdesc"/>
@@ -241,6 +236,8 @@
<filterset>
<filter token="NAME_1" value="local-messaging"/>
<filter token="NAME_2" value="local-messaging2"/>
+ <filter token="REGISTRY_HOST" value="${perf.registry.host}" />
+ <filter token="REGISTRY_PORT" value="${perf.registry.port}" />
</filterset>
</copy>
@@ -340,6 +337,8 @@
<arg line="-config ${project.root}/etc/${perf.config.file} -action ${action}"/>
<sysproperty key="project.output" value="${project.output}"/>
<sysproperty key="log.suffix" value="${log.suffix}"/>
+ <sysproperty key="perf.registry.host" value="${perf.registry.host}" />
+ <sysproperty key="perf.registry.port" value="${perf.registry.port}" />
<classpath refid="perf.classpath"/>
</java>
</target>
@@ -362,16 +361,16 @@
<target name="start-rmi-executors">
<antcall target="start-rmi-registry"/>
<sleep seconds="1"/>
- <foreach list="${providers}" delimiter=" " param="provider.name"
+ <foreach list="${perf.providers}" delimiter=" " param="provider.name"
target="start-standalone-rmi-executor">
- <param name="registry.host" value="localhost"/>
- <param name="registry.port" value="7777"/>
+ <param name="registry.host" value="${perf.registry.host}"/>
+ <param name="registry.port" value="${perf.registry.port}"/>
<param name="executor.suffix" value=""/>
</foreach>
- <foreach list="${providers}" delimiter=" " param="provider.name"
+ <foreach list="${perf.providers}" delimiter=" " param="provider.name"
target="start-standalone-rmi-executor">
- <param name="registry.host" value="localhost"/>
- <param name="registry.port" value="7777"/>
+ <param name="registry.host" value="${perf.registry.host}"/>
+ <param name="registry.port" value="${perf.registry.port}"/>
<param name="executor.suffix" value="2"/>
</foreach>
<!-- deploy colocated executors; port values hardcoded for the time being -->
@@ -396,16 +395,16 @@
<delete file="${ENV.JBOSS_HOME}/server/${jbossmq.config.name}/deploy/rmi-executor.sar"/>
<!-- and kill the standalone VMs -->
- <foreach list="${providers}" delimiter=" " param="provider.name"
+ <foreach list="${perf.providers}" delimiter=" " param="provider.name"
target="kill-rmi-executor">
- <param name="registry.host" value="localhost"/>
- <param name="registry.port" value="7777"/>
+ <param name="registry.host" value="${perf.registry.host}"/>
+ <param name="registry.port" value="${perf.registry.port}"/>
<param name="executor.suffix" value=""/>
</foreach>
- <foreach list="${providers}" delimiter=" " param="provider.name"
+ <foreach list="${perf.providers}" delimiter=" " param="provider.name"
target="kill-rmi-executor">
- <param name="registry.host" value="localhost"/>
- <param name="registry.port" value="7777"/>
+ <param name="registry.host" value="${perf.registry.host}"/>
+ <param name="registry.port" value="${perf.registry.port}"/>
<param name="executor.suffix" value="2"/>
</foreach>
<!-- allow some time for service undeployment -->
@@ -434,7 +433,7 @@
<target name="start-standalone-rmi-executor" description="Start a standalone (its own VM) RMI executor">
<property name="executor.name" value="remote-${provider.name}${executor.suffix}"/>
- <echo message="Starting standalone RMI executor rmi://${registry.host}:${registry.port}/${executor.name}"/>
+ <echo message="Starting standalone RMI executor rmi://${executor.name}, registry ${registry.host}:${registry.port}"/>
<java classname="org.jboss.jms.perf.framework.remoting.rmi.RMIExecutor" fork="true" spawn="true">
<arg value="${executor.name}"/>
<arg value="${registry.port}"/>
@@ -454,10 +453,12 @@
</target>
<target name="start-rmi-registry">
- <echo message="Starting registry"/>
+ <echo message="Starting registry on ${perf.registry.host}:${perf.registry.port}"/>
<java classname="org.jboss.jms.perf.framework.remoting.rmi.RegistryRunner" fork="true" spawn="true">
<sysproperty key="project.output" value="${project.output}"/>
<sysproperty key="log.suffix" value="registry"/>
+ <sysproperty key="perf.registry.host" value="${perf.registry.host}" />
+ <sysproperty key="perf.registry.port" value="${perf.registry.port}" />
<!--
<jvmarg line="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_shmem,server=y,suspend=y,address=executor"/>
-->
@@ -466,10 +467,12 @@
</target>
<target name="kill-rmi-registry">
- <echo message="Killing registry"/>
+ <echo message="Killing registry on ${perf.registry.host}:${perf.registry.port}"/>
<java classname="org.jboss.jms.perf.framework.remoting.rmi.RegistryKiller" fork="true" spawn="true">
<sysproperty key="project.output" value="${project.output}"/>
<sysproperty key="log.suffix" value="registry.kill"/>
+ <sysproperty key="perf.registry.host" value="${perf.registry.host}" />
+ <sysproperty key="perf.registry.port" value="${perf.registry.port}" />
<!--
<jvmarg line="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_shmem,server=y,suspend=y,address=executor"/>
-->
@@ -493,7 +496,7 @@
<target name="kill-rmi-executor" description="Kill a RMI executor (co-located or standalone)">
<property name="executor.name" value="remote-${provider.name}${executor.suffix}"/>
- <echo message="Killing RMI executor rmi://${registry.host}:${registry.port}/${executor.name}"/>
+ <echo message="Killing RMI executor rmi://${executor.name}, registry ${registry.host}:${registry.port}"/>
<java classname="org.jboss.jms.perf.framework.remoting.rmi.ExecutorKiller" fork="true">
<arg value="${executor.name}"/>
<arg value="${registry.port}"/>
Added: projects/perf/trunk/etc/perf.properties
===================================================================
--- projects/perf/trunk/etc/perf.properties (rev 0)
+++ projects/perf/trunk/etc/perf.properties 2007-06-11 12:40:05 UTC (rev 2771)
@@ -0,0 +1,3 @@
+perf.providers=jbossmq messaging activemq qpid
+perf.registry.host=localhost
+perf.registry.port=7777
\ No newline at end of file
Modified: projects/perf/trunk/etc/perf.xml
===================================================================
--- projects/perf/trunk/etc/perf.xml 2007-06-11 12:10:15 UTC (rev 2770)
+++ projects/perf/trunk/etc/perf.xml 2007-06-11 12:40:05 UTC (rev 2771)
@@ -23,10 +23,10 @@
<factory>org.jnp.interfaces.NamingContextFactory</factory>
<url>jnp://localhost:1099</url>
<pkg>org.jboss.naming:org.jnp.interfaces</pkg>
- <executor name="REMOTE" url="rmi://localhost:7777/remote-messaging"/>
- <executor name="REMOTE2" url="rmi://localhost:7777/remote-messaging2"/>
- <executor name="COLOCATED" url="rmi://localhost:7777/local-messaging"/>
- <executor name="COLOCATED2" url="rmi://localhost:7777/local-messaging2"/>
+ <executor name="REMOTE" url="rmi://remote-messaging"/>
+ <executor name="REMOTE2" url="rmi://remote-messaging2"/>
+ <executor name="COLOCATED" url="rmi://local-messaging"/>
+ <executor name="COLOCATED2" url="rmi://local-messaging2"/>
<color>255,0,0</color>
</provider>
@@ -34,10 +34,10 @@
<factory>org.jnp.interfaces.NamingContextFactory</factory>
<url>jnp://localhost:1199</url>
<pkg>org.jboss.naming:org.jnp.interfaces</pkg>
- <executor name="REMOTE" url="rmi://localhost:7777/remote-jbossmq"/>
- <executor name="REMOTE2" url="rmi://localhost:7777/remote-jbossmq2"/>
- <executor name="COLOCATED" url="rmi://localhost:7777/local-jbossmq"/>
- <executor name="COLOCATED2" url="rmi://localhost:7777/local-jbossmq2"/>
+ <executor name="REMOTE" url="rmi://remote-jbossmq"/>
+ <executor name="REMOTE2" url="rmi://remote-jbossmq2"/>
+ <executor name="COLOCATED" url="rmi://local-jbossmq"/>
+ <executor name="COLOCATED2" url="rmi://local-jbossmq2"/>
<color>0,0, 255</color>
</provider>
@@ -48,8 +48,8 @@
<jndi-property name="queue./queue/simpleQueue">SIMPLE_QUEUE</jndi-property>
<jndi-property name="connectionFactoryNames">/ConnectionFactory</jndi-property>
- <executor name="REMOTE" url="rmi://localhost:7777/remote-activemq"/>
- <executor name="REMOTE2" url="rmi://localhost:7777/remote-activemq2"/>
+ <executor name="REMOTE" url="rmi://remote-activemq"/>
+ <executor name="REMOTE2" url="rmi://remote-activemq2"/>
<color>0, 255, 255</color>
</provider>
@@ -60,8 +60,8 @@
<jndi-property name="queue./queue/testQueue">testQueue</jndi-property>
<jndi-property name="queue./queue/simpleQueue">simpleQueue</jndi-property>
- <executor name="REMOTE" url="rmi://localhost:7777/remote-qpid"/>
- <executor name="REMOTE2" url="rmi://localhost:7777/remote-qpid2"/>
+ <executor name="REMOTE" url="rmi://remote-qpid"/>
+ <executor name="REMOTE2" url="rmi://remote-qpid2"/>
<color>255, 0, 255</color>
</provider>
@@ -71,7 +71,7 @@
<performance-tests>
<!-- just makes sure the executors are deployed and ready -->
- <!--
+ <!-- -->
<performance-test name="Ping" loops="1">
<ping executor="REMOTE"/>
<ping executor="REMOTE2"/>
@@ -86,9 +86,9 @@
<execution provider="JBossMessaging"/>
<execution provider="JBossMQ"/>
</performance-test>
- -->
+ <!-- -->
- <!--
+ <!-- -->
<performance-test name="Ping Remote Only" loops="1">
<ping executor="REMOTE"/>
<ping executor="REMOTE2"/>
@@ -101,7 +101,7 @@
<execution provider="ActiveMQ"/>
<execution provider="Qpid"/>
</performance-test>
- -->
+ <!-- -->
<!--
<performance-test name="Single Burst" loops="10">
@@ -498,6 +498,7 @@
</performance-test>
-->
+ <!--
<performance-test name="Measured Send Rate vs. Intended Send Rate Remote">
<graph>
@@ -538,6 +539,7 @@
<execution provider="ActiveMQ"/>
</performance-test>
+ -->
<!--
<performance-test name="Send 50000 Non-Persistent Non-Transactional 0 KB Local">
Modified: projects/perf/trunk/src/etc/rmi-executor-service.xml
===================================================================
--- projects/perf/trunk/src/etc/rmi-executor-service.xml 2007-06-11 12:10:15 UTC (rev 2770)
+++ projects/perf/trunk/src/etc/rmi-executor-service.xml 2007-06-11 12:40:05 UTC (rev 2771)
@@ -18,8 +18,8 @@
xmbean-dd="xmdesc/RMIExecutor-xmbean.xml">
<constructor>
<arg type="java.lang.String" value="@NAME_1@"/>
- <arg type="int" value="7777"/>
- <arg type="java.lang.String" value="localhost"/>
+ <arg type="int" value="@REGISTRY_PORT@"/>
+ <arg type="java.lang.String" value="@REGISTRY_HOST@"/>
</constructor>
</mbean>
@@ -28,8 +28,8 @@
xmbean-dd="xmdesc/RMIExecutor-xmbean.xml">
<constructor>
<arg type="java.lang.String" value="@NAME_2@"/>
- <arg type="int" value="7777"/>
- <arg type="java.lang.String" value="localhost"/>
+ <arg type="int" value="@REGISTRY_PORT@"/>
+ <arg type="java.lang.String" value="@REGISTRY_HOST@"/>
</constructor>
</mbean>
Modified: projects/perf/trunk/src/main/org/jboss/jms/perf/framework/remoting/rmi/ExecutorKiller.java
===================================================================
--- projects/perf/trunk/src/main/org/jboss/jms/perf/framework/remoting/rmi/ExecutorKiller.java 2007-06-11 12:10:15 UTC (rev 2770)
+++ projects/perf/trunk/src/main/org/jboss/jms/perf/framework/remoting/rmi/ExecutorKiller.java 2007-06-11 12:40:05 UTC (rev 2771)
@@ -6,12 +6,11 @@
*/
package org.jboss.jms.perf.framework.remoting.rmi;
-import org.jboss.logging.Logger;
-import org.jboss.jms.perf.framework.protocol.KillRequest;
-
import java.rmi.registry.Registry;
-import java.rmi.registry.LocateRegistry;
+import org.jboss.jms.perf.framework.protocol.KillRequest;
+import org.jboss.logging.Logger;
+
/**
* @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
* @version <tt>$Revision: 723 $</tt>
@@ -61,9 +60,7 @@
// Attributes ----------------------------------------------------
private String name;
- private int registryPort;
- private String registryHost;
- private String url;
+ private RegistryLocation registryLocation;
// Constructors --------------------------------------------------
@@ -72,28 +69,15 @@
String registryHost) throws Exception
{
this.name = name;
- this.registryPort = registryPort;
- this.registryHost = registryHost;
+ this.registryLocation = new RegistryLocation(registryHost, registryPort);
}
// Public --------------------------------------------------------
public void run() throws Exception
{
- if (registryPort > 0 && registryPort < 65535)
- {
- if (registryHost != null)
- {
- url = "//" + registryHost + ":" + registryPort + "/" + name;
- }
- else
- {
- url = "//localhost:" + registryPort + "/" + name;
- }
- }
-
- Registry r = LocateRegistry.getRegistry(registryHost, registryPort);
- Server server = (Server)r.lookup(url);
+ Registry r = RegistryHelper.getRegistry(registryLocation);
+ Server server = (Server)r.lookup(name);
server.execute(new KillRequest());
log.info("kill request sent sucessfully");
}
Modified: projects/perf/trunk/src/main/org/jboss/jms/perf/framework/remoting/rmi/RMICoordinator.java
===================================================================
--- projects/perf/trunk/src/main/org/jboss/jms/perf/framework/remoting/rmi/RMICoordinator.java 2007-06-11 12:10:15 UTC (rev 2770)
+++ projects/perf/trunk/src/main/org/jboss/jms/perf/framework/remoting/rmi/RMICoordinator.java 2007-06-11 12:40:05 UTC (rev 2771)
@@ -6,14 +6,14 @@
*/
package org.jboss.jms.perf.framework.remoting.rmi;
+import java.rmi.RemoteException;
+import java.rmi.registry.Registry;
+
import org.jboss.jms.perf.framework.remoting.Coordinator;
+import org.jboss.jms.perf.framework.remoting.Request;
import org.jboss.jms.perf.framework.remoting.Result;
-import org.jboss.jms.perf.framework.remoting.Request;
import org.jboss.logging.Logger;
-import java.rmi.registry.LocateRegistry;
-import java.rmi.registry.Registry;
-
/**
* @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
* @version <tt>$Revision: 729 $</tt>
@@ -27,11 +27,29 @@
// Static --------------------------------------------------------
+ /**
+ * Parse the string representation of an RMI URL. Accepted syntax is
+ * <code>rmi://<em>name</em></code>.
+ *
+ * @return the <em>name</em> part of the URL.
+ */
+ private static String parseURL(String url) throws IllegalArgumentException
+ {
+ String s = url;
+
+ if (s.startsWith("rmi://"))
+ {
+ return s.substring(6);
+ }
+
+ throw new IllegalArgumentException("Invalid RMI URL: " + url);
+ }
+
public static boolean isValidURL(String url)
{
try
{
- new RMIURL(url);
+ parseURL(url);
return true;
}
catch(Exception e)
@@ -41,19 +59,30 @@
}
// Attributes ----------------------------------------------------
+
+ private Registry registry;
// Constructors --------------------------------------------------
-
+
// Coordinator implementation ------------------------------------
+
+ private Registry getRegistry() throws RemoteException
+ {
+ if (registry == null)
+ {
+ RegistryLocation registryLocation = RegistryHelper.getRegistryLocationFromProperties();
+ registry = RegistryHelper.getRegistry(registryLocation);
+ }
+
+ return registry;
+ }
public Result sendToExecutor(String executorURL, Request request) throws Throwable
{
- RMIURL url = new RMIURL(executorURL);
-
log.debug(this + " sending " + request + " to " + executorURL);
- Registry r = LocateRegistry.getRegistry(url.getHost(), url.getPort());
- Server server = (Server)r.lookup(url.getURL());
+ String name = parseURL(executorURL);
+ Server server = (Server)getRegistry().lookup(name);
Result result = server.execute(request);
log.debug(this + " received result from " + executorURL);
Modified: projects/perf/trunk/src/main/org/jboss/jms/perf/framework/remoting/rmi/RMIExecutor.java
===================================================================
--- projects/perf/trunk/src/main/org/jboss/jms/perf/framework/remoting/rmi/RMIExecutor.java 2007-06-11 12:10:15 UTC (rev 2770)
+++ projects/perf/trunk/src/main/org/jboss/jms/perf/framework/remoting/rmi/RMIExecutor.java 2007-06-11 12:40:05 UTC (rev 2771)
@@ -6,17 +6,16 @@
*/
package org.jboss.jms.perf.framework.remoting.rmi;
-import org.jboss.logging.Logger;
-import org.jboss.jms.perf.framework.remoting.Result;
-import org.jboss.jms.perf.framework.remoting.Request;
-import org.jboss.jms.perf.framework.remoting.Executor;
-import org.jboss.jms.perf.framework.remoting.Context;
-
-import java.rmi.server.UnicastRemoteObject;
-import java.rmi.registry.Registry;
-import java.rmi.registry.LocateRegistry;
import java.rmi.AlreadyBoundException;
+import java.rmi.registry.Registry;
+import java.rmi.server.UnicastRemoteObject;
+import org.jboss.jms.perf.framework.remoting.Context;
+import org.jboss.jms.perf.framework.remoting.Executor;
+import org.jboss.jms.perf.framework.remoting.Request;
+import org.jboss.jms.perf.framework.remoting.Result;
+import org.jboss.logging.Logger;
+
/**
* @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
* @version <tt>$Revision: 729 $</tt>
@@ -68,9 +67,7 @@
// Attributes ----------------------------------------------------
private String name;
- private int registryPort;
- private String registryHost;
- private String url;
+ private RegistryLocation registryLocation;
private Registry registry;
private Executor delegateExecutor;
@@ -84,8 +81,7 @@
String registryHost) throws Exception
{
this.name = name;
- this.registryPort = registryPort;
- this.registryHost = registryHost;
+ this.registryLocation = new RegistryLocation(registryHost, registryPort);
registry = null;
delegateExecutor = new Executor(this);
colocated = true;
@@ -111,12 +107,12 @@
public int getRegistryPort()
{
- return registryPort;
+ return registryLocation.getPort();
}
public String getRegistryHost()
{
- return registryHost;
+ return registryLocation.getHost();
}
public String getName()
@@ -128,27 +124,11 @@
public void start() throws Exception
{
- if (registryPort > 0 && registryPort < 65535)
- {
- if (registryHost != null)
- {
- url = "//" + registryHost + ":" + registryPort + "/" + name;
- System.setProperty("java.rmi.server.hostname", registryHost);
- }
- else
- {
- url = "//localhost:" + registryPort + "/" + name;
- }
- }
- else
- {
- throw new Exception("registry port name needed");
- }
-
- registry = LocateRegistry.getRegistry(registryHost, registryPort);
+ System.setProperty("java.rmi.server.hostname", registryLocation.getHost());
+ registry = RegistryHelper.getRegistry(registryLocation);
try
{
- registry.bind(url, this);
+ registry.bind(name, this);
log.info(this + " started");
}
catch(AlreadyBoundException e)
@@ -159,14 +139,14 @@
public void stop() throws Exception
{
- log.debug("Unbinding " + url + " from " + registry);
- registry.unbind(url);
+ log.debug("Unbinding " + name + " from " + registry);
+ registry.unbind(name);
log.info(this + " stopped");
}
public String toString()
{
- return "RMIExecutor[" + url + "]";
+ return "RMIExecutor[" + name + "]";
}
// Package protected ---------------------------------------------
Deleted: projects/perf/trunk/src/main/org/jboss/jms/perf/framework/remoting/rmi/RMIURL.java
===================================================================
--- projects/perf/trunk/src/main/org/jboss/jms/perf/framework/remoting/rmi/RMIURL.java 2007-06-11 12:10:15 UTC (rev 2770)
+++ projects/perf/trunk/src/main/org/jboss/jms/perf/framework/remoting/rmi/RMIURL.java 2007-06-11 12:40:05 UTC (rev 2771)
@@ -1,85 +0,0 @@
-/**
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.jms.perf.framework.remoting.rmi;
-
-/**
- * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
- * @version <tt>$Revision: 723 $</tt>
- * <p/>
- * $Id: RMIURL.java 723 2006-03-11 07:05:24Z ovidiu $
- */
-public class RMIURL
-{
- // Constants -----------------------------------------------------
-
- // Static --------------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- private int port;
- private String host;
- private String name;
-
- // Constructors --------------------------------------------------
-
- public RMIURL(String url) throws Exception
- {
- String s = url;
- if (s.startsWith("rmi://"))
- {
- s = s.substring(6);
- int idx = s.indexOf(':');
- if (idx != -1)
- {
- host = s.substring(0, idx);
- s = s.substring(idx + 1);
- idx = s.indexOf('/');
- if (idx != -1)
- {
- String sp = s.substring(0, idx);
- port = Integer.parseInt(sp);
- name = s.substring(idx + 1);
- return;
- }
- }
- }
-
- throw new Exception("Invalid RMI URL: " + url);
-
- }
-
- // Public --------------------------------------------------------
-
- public int getPort()
- {
- return port;
- }
-
- public String getHost()
- {
- return host;
- }
-
- public String getName()
- {
- return name;
- }
-
- public String getURL()
- {
- return "//" + (host != null ? host : "localhost") + ":" + port + "/" + name;
- }
-
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-}
Added: projects/perf/trunk/src/main/org/jboss/jms/perf/framework/remoting/rmi/RegistryHelper.java
===================================================================
--- projects/perf/trunk/src/main/org/jboss/jms/perf/framework/remoting/rmi/RegistryHelper.java (rev 0)
+++ projects/perf/trunk/src/main/org/jboss/jms/perf/framework/remoting/rmi/RegistryHelper.java 2007-06-11 12:40:05 UTC (rev 2771)
@@ -0,0 +1,56 @@
+package org.jboss.jms.perf.framework.remoting.rmi;
+
+import java.rmi.RemoteException;
+import java.rmi.registry.LocateRegistry;
+import java.rmi.registry.Registry;
+
+public final class RegistryHelper
+{
+ private RegistryHelper() { }
+
+ public static final String REGISTRY_HOST_PROPERTY = "perf.registry.host";
+ public static final String REGISTRY_PORT_PROPERTY = "perf.registry.port";
+
+ /**
+ * Reads a <code>RegistryLocation</code> from system properties.
+ * @return
+ */
+ public static RegistryLocation getRegistryLocationFromProperties()
+ {
+ String host = System.getProperty(REGISTRY_HOST_PROPERTY, "localhost");
+ String portString = System.getProperty(REGISTRY_PORT_PROPERTY, "7777");
+
+ int port = Integer.parseInt(portString);
+
+ return new RegistryLocation(host, port);
+ }
+
+ /**
+ * Creates an RMI {@link Registry} at the given <code>location</code>.
+ * Contrary to {@link Registry.createRegistry(int)}, the registry created
+ * by this method will only listen on the hostname given by
+ * {@link RegistryLocation#getHost()}.
+ * @param location
+ * @return
+ * @throws RemoteException
+ * @see LocateRegistry#createRegistry(int, java.rmi.server.RMIClientSocketFactory, java.rmi.server.RMIServerSocketFactory)
+ */
+ public static Registry createRegistry(RegistryLocation location) throws RemoteException
+ {
+ return LocateRegistry.createRegistry(location.getPort(),
+ new SimpleRMIClientSocketFactory(),
+ new SingleAddressRMIServerSocketFactory(location.getHost()));
+ }
+
+ /**
+ * Returns the RMI {@link Registry} at the given <code>location</code>.
+ * @param location
+ * @return
+ * @throws RemoteException
+ * @see LocateRegistry#getRegistry(int)
+ */
+ public static Registry getRegistry(RegistryLocation location) throws RemoteException
+ {
+ return LocateRegistry.getRegistry(location.getHost(), location.getPort());
+ }
+}
Modified: projects/perf/trunk/src/main/org/jboss/jms/perf/framework/remoting/rmi/RegistryKiller.java
===================================================================
--- projects/perf/trunk/src/main/org/jboss/jms/perf/framework/remoting/rmi/RegistryKiller.java 2007-06-11 12:10:15 UTC (rev 2770)
+++ projects/perf/trunk/src/main/org/jboss/jms/perf/framework/remoting/rmi/RegistryKiller.java 2007-06-11 12:40:05 UTC (rev 2771)
@@ -6,12 +6,11 @@
*/
package org.jboss.jms.perf.framework.remoting.rmi;
+import java.rmi.registry.Registry;
+
import org.jboss.logging.Logger;
-import java.rmi.registry.LocateRegistry;
-import java.rmi.registry.Registry;
-
/**
* @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
* @version <tt>$Revision: 729 $</tt>
@@ -29,11 +28,15 @@
{
try
{
- Registry registry = LocateRegistry.getRegistry("localhost", 7777);
+ RegistryLocation registryLocation = RegistryHelper.getRegistryLocationFromProperties();
+
+ log.info("looking for registry at " + registryLocation);
+ Registry registry = RegistryHelper.getRegistry(registryLocation);
+
log.info("registry: " + registry);
- RegistryManagement m = (RegistryManagement)registry.lookup("//localhost:7777/management");
+ RegistryManagement m = (RegistryManagement)registry.lookup("management");
m.kill();
@@ -42,6 +45,7 @@
catch(Throwable t)
{
log.error("exception", t);
+ System.exit(1);
}
}
Added: projects/perf/trunk/src/main/org/jboss/jms/perf/framework/remoting/rmi/RegistryLocation.java
===================================================================
--- projects/perf/trunk/src/main/org/jboss/jms/perf/framework/remoting/rmi/RegistryLocation.java (rev 0)
+++ projects/perf/trunk/src/main/org/jboss/jms/perf/framework/remoting/rmi/RegistryLocation.java 2007-06-11 12:40:05 UTC (rev 2771)
@@ -0,0 +1,40 @@
+package org.jboss.jms.perf.framework.remoting.rmi;
+
+import java.io.Serializable;
+
+public class RegistryLocation implements Serializable
+{
+ private final String host;
+ private final int port;
+
+ public RegistryLocation(String host, int port)
+ {
+ if (port < 0 || port > 65535)
+ {
+ throw new IllegalArgumentException("Registry port should be between 0 and 65535, value given was " + port);
+ }
+
+ if (host == null)
+ {
+ throw new IllegalArgumentException("Registry host should not be null");
+ }
+
+ this.host = host;
+ this.port = port;
+ }
+
+ public String getHost()
+ {
+ return host;
+ }
+
+ public int getPort()
+ {
+ return port;
+ }
+
+ public String toString()
+ {
+ return host + ":" + port;
+ }
+}
Modified: projects/perf/trunk/src/main/org/jboss/jms/perf/framework/remoting/rmi/RegistryRunner.java
===================================================================
--- projects/perf/trunk/src/main/org/jboss/jms/perf/framework/remoting/rmi/RegistryRunner.java 2007-06-11 12:10:15 UTC (rev 2770)
+++ projects/perf/trunk/src/main/org/jboss/jms/perf/framework/remoting/rmi/RegistryRunner.java 2007-06-11 12:40:05 UTC (rev 2771)
@@ -31,21 +31,27 @@
{
try
{
- int port = 7777;
+ String portString = System.getProperty("perf.registry.port", "7777");
+ int port = Integer.parseInt(portString);
- System.setProperty("java.rmi.server.hostname", "localhost");
+ String host = System.getProperty("perf.registry.host", "localhost");
- registry = LocateRegistry.createRegistry(port);
+ System.setProperty("java.rmi.server.hostname", host);
+ registry = LocateRegistry.createRegistry(port,
+ new SimpleRMIClientSocketFactory(),
+ new SingleAddressRMIServerSocketFactory(host));
+
log.info("registry created");
- registry.bind("//localhost:7777/management", new RegistryRunner());
+ registry.bind("management", new RegistryRunner());
log.info("management instance bound");
}
catch(Throwable t)
{
log.error("registry failed", t);
+ System.exit(1);
}
}
@@ -69,7 +75,7 @@
try
{
Thread.sleep(500);
- log.debug("just about to exit");
+ log.info("exiting");
System.exit(0);
}
catch(Exception e)
Added: projects/perf/trunk/src/main/org/jboss/jms/perf/framework/remoting/rmi/SimpleRMIClientSocketFactory.java
===================================================================
--- projects/perf/trunk/src/main/org/jboss/jms/perf/framework/remoting/rmi/SimpleRMIClientSocketFactory.java (rev 0)
+++ projects/perf/trunk/src/main/org/jboss/jms/perf/framework/remoting/rmi/SimpleRMIClientSocketFactory.java 2007-06-11 12:40:05 UTC (rev 2771)
@@ -0,0 +1,13 @@
+package org.jboss.jms.perf.framework.remoting.rmi;
+
+import java.io.IOException;
+import java.net.Socket;
+import java.rmi.server.RMIClientSocketFactory;
+
+public class SimpleRMIClientSocketFactory implements RMIClientSocketFactory
+{
+ public Socket createSocket(String host, int port) throws IOException
+ {
+ return new Socket(host, port);
+ }
+}
Added: projects/perf/trunk/src/main/org/jboss/jms/perf/framework/remoting/rmi/SingleAddressRMIServerSocketFactory.java
===================================================================
--- projects/perf/trunk/src/main/org/jboss/jms/perf/framework/remoting/rmi/SingleAddressRMIServerSocketFactory.java (rev 0)
+++ projects/perf/trunk/src/main/org/jboss/jms/perf/framework/remoting/rmi/SingleAddressRMIServerSocketFactory.java 2007-06-11 12:40:05 UTC (rev 2771)
@@ -0,0 +1,26 @@
+package org.jboss.jms.perf.framework.remoting.rmi;
+
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.ServerSocket;
+import java.rmi.server.RMIServerSocketFactory;
+
+public class SingleAddressRMIServerSocketFactory implements RMIServerSocketFactory
+{
+ private InetAddress bindAddress;
+
+ public SingleAddressRMIServerSocketFactory(String host) throws java.rmi.UnknownHostException {
+ try
+ {
+ this.bindAddress = InetAddress.getByName(host);
+ }
+ catch (java.net.UnknownHostException e)
+ {
+ throw new java.rmi.UnknownHostException("Unknown host: " + host, e);
+ }
+ }
+ public ServerSocket createServerSocket(int port) throws IOException
+ {
+ return new ServerSocket(port, 5, bindAddress);
+ }
+}
More information about the jboss-cvs-commits
mailing list