diff options
| author | Keith Wall <kwall@apache.org> | 2011-09-14 13:35:17 +0000 |
|---|---|---|
| committer | Keith Wall <kwall@apache.org> | 2011-09-14 13:35:17 +0000 |
| commit | f7fb81d90c7f10ea187416883b2699dd6cb25f83 (patch) | |
| tree | ca8c859bbd16ba3f3aad2289623f944f30f8e175 /qpid/java | |
| parent | 5b4907d81effd26d15dd418ff2a3df8bb3dab9e3 (diff) | |
| download | qpid-python-f7fb81d90c7f10ea187416883b2699dd6cb25f83.tar.gz | |
QPID-3486: Make connector server port used for JMX configurable.
Commited work from Andrew MacBean <andymacbean@gmail.com> any myself.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1170612 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java')
14 files changed, 250 insertions, 170 deletions
diff --git a/qpid/java/broker-plugins/experimental/info/src/main/java/org/apache/qpid/info/AppInfo.java b/qpid/java/broker-plugins/experimental/info/src/main/java/org/apache/qpid/info/AppInfo.java index 9bdd4b9d17..bf3ef61ea1 100644 --- a/qpid/java/broker-plugins/experimental/info/src/main/java/org/apache/qpid/info/AppInfo.java +++ b/qpid/java/broker-plugins/experimental/info/src/main/java/org/apache/qpid/info/AppInfo.java @@ -70,7 +70,7 @@ public class AppInfo sc = ApplicationRegistry.getInstance().getConfiguration(); if (null != sc) { - appInfoMap.put("jmxport", sc.getJMXManagementPort() + ""); + appInfoMap.put("jmxport", sc.getJMXPortRegistryServer() + ""); appInfoMap.put("port", sc.getPorts().toString()); appInfoMap.put("version", QpidProperties.getReleaseVersion()); appInfoMap.put("vhosts", "standalone"); diff --git a/qpid/java/broker/etc/config.xml b/qpid/java/broker/etc/config.xml index 59e5ed0f58..2752274155 100644 --- a/qpid/java/broker/etc/config.xml +++ b/qpid/java/broker/etc/config.xml @@ -30,7 +30,7 @@ <connector> <!-- To enable SSL edit the keystorePath and keystorePassword and set enabled to true. - To disasble Non-SSL port set sslOnly to true --> + To disable Non-SSL port set sslOnly to true --> <ssl> <enabled>false</enabled> <port>5671</port> @@ -44,7 +44,13 @@ </connector> <management> <enabled>true</enabled> - <jmxport>8999</jmxport> + <jmxport> + <registryServer>8999</registryServer> + <!-- + If unspecified, connectorServer defaults to 100 + registryServer port. + <connectorServer>9099</connectionServer> + --> + </jmxport> <ssl> <enabled>false</enabled> <!-- Update below path to your keystore location, or run the bin/create-example-ssl-stores(.sh|.bat) diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/Broker.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/Broker.java index 75891d02a3..5dfd841434 100644 --- a/qpid/java/broker/src/main/java/org/apache/qpid/server/Broker.java +++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/Broker.java @@ -110,7 +110,7 @@ public class Broker ConfigurationFileApplicationRegistry config = new ConfigurationFileApplicationRegistry(configFile, options.getBundleContext()); ServerConfiguration serverConfig = config.getConfiguration(); - updateManagementPort(serverConfig, options.getJmxPort()); + updateManagementPorts(serverConfig, options.getJmxPortRegistryServer(), options.getJmxPortConnectorServer()); ApplicationRegistry.initialise(config); @@ -318,19 +318,30 @@ public class Broker /** * Update the configuration data with the management port. * @param configuration - * @param managementPort The string from the command line + * @param registryServerPort The string from the command line */ - private void updateManagementPort(ServerConfiguration configuration, Integer managementPort) + private void updateManagementPorts(ServerConfiguration configuration, Integer registryServerPort, Integer connectorServerPort) { - if (managementPort != null) + if (registryServerPort != null) { try { - configuration.setJMXManagementPort(managementPort); + configuration.setJMXPortRegistryServer(registryServerPort); } catch (NumberFormatException e) { - throw new InitException("Invalid management port: " + managementPort, null); + throw new InitException("Invalid management (registry server) port: " + registryServerPort, null); + } + } + if (connectorServerPort != null) + { + try + { + configuration.setJMXPortConnectorServer(connectorServerPort); + } + catch (NumberFormatException e) + { + throw new InitException("Invalid management (connector server) port: " + connectorServerPort, null); } } } diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/BrokerOptions.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/BrokerOptions.java index b2d029eb95..3defd8260c 100644 --- a/qpid/java/broker/src/main/java/org/apache/qpid/server/BrokerOptions.java +++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/BrokerOptions.java @@ -37,14 +37,6 @@ public class BrokerOptions public static final String DEFAULT_LOG_CONFIG_FILE = "etc/log4j.xml"; public static final String QPID_HOME = "QPID_HOME"; - public static final String PORTS = "p"; - public static final String SSL_PORTS = "s"; - public static final String BIND = "b"; - public static final String MANAGEMENT = "m"; - public static final String LOG_CONFIG = "l"; - public static final String WATCH = "w"; - public static final String CONFIG = "c"; - private final Set<Integer> _ports = new HashSet<Integer>(); private final Set<Integer> _sslPorts = new HashSet<Integer>(); private final Map<ProtocolExclusion,Set<Integer>> _exclusionMap = new HashMap<ProtocolExclusion, Set<Integer>>(); @@ -52,7 +44,8 @@ public class BrokerOptions private String _configFile; private String _logConfigFile; private String _bind; - private Integer _jmxPort; + private Integer _jmxPortRegistryServer; + private Integer _jmxPortConnectorServer; private BundleContext _bundleContext; private Integer _logWatchFrequency = 0; @@ -98,14 +91,24 @@ public class BrokerOptions _logConfigFile = logConfigFile; } - public Integer getJmxPort() + public Integer getJmxPortRegistryServer() + { + return _jmxPortRegistryServer; + } + + public void setJmxPortRegistryServer(final int jmxPortRegistryServer) { - return _jmxPort; + _jmxPortRegistryServer = jmxPortRegistryServer; } - public void setJmxPort(final int jmxPort) + public Integer getJmxPortConnectorServer() { - _jmxPort = jmxPort; + return _jmxPortConnectorServer; + } + + public void setJmxPortConnectorServer(final int jmxPortConnectorServer) + { + _jmxPortConnectorServer = jmxPortConnectorServer; } public String getQpidHome() @@ -163,4 +166,5 @@ public class BrokerOptions { _bundleContext = bundleContext; } + }
\ No newline at end of file diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/Main.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/Main.java index 15d23e30b6..0c038c7800 100644 --- a/qpid/java/broker/src/main/java/org/apache/qpid/server/Main.java +++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/Main.java @@ -27,7 +27,6 @@ import org.apache.commons.cli.OptionBuilder; import org.apache.commons.cli.Options; import org.apache.commons.cli.ParseException; import org.apache.commons.cli.PosixParser; -import org.apache.log4j.Logger; import org.apache.qpid.server.Broker.InitException; import org.apache.qpid.server.registry.ApplicationRegistry; @@ -38,7 +37,92 @@ import org.apache.qpid.server.registry.ApplicationRegistry; */ public class Main { - private final Options options = new Options(); + + private static final Option OPTION_HELP = new Option("h", "help", false, "print this message"); + + private static final Option OPTION_VERSION = new Option("v", "version", false, "print the version information and exit"); + + private static final Option OPTION_CONFIG_FILE = + OptionBuilder.withArgName("file").hasArg().withDescription("use given configuration file").withLongOpt("config") + .create("c"); + + private static final Option OPTION_PORT = + OptionBuilder.withArgName("port").hasArg() + .withDescription("listen on the specified port. Overrides any value in the config file") + .withLongOpt("port").create("p"); + + private static final Option OPTION_SSLPORT = + OptionBuilder.withArgName("port").hasArg() + .withDescription("SSL port. Overrides any value in the config file") + .withLongOpt("sslport").create("s"); + + private static final Option OPTION_EXCLUDE_0_10 = + OptionBuilder.withArgName("port").hasArg() + .withDescription("when listening on the specified port do not accept AMQP0-10 connections. The specified port must be one specified on the command line") + .withLongOpt("exclude-0-10").create(); + + private static final Option OPTION_EXCLUDE_0_9_1 = + OptionBuilder.withArgName("port").hasArg() + .withDescription("when listening on the specified port do not accept AMQP0-9-1 connections. The specified port must be one specified on the command line") + .withLongOpt("exclude-0-9-1").create(); + + private static final Option OPTION_EXCLUDE_0_9 = + OptionBuilder.withArgName("port").hasArg() + .withDescription("when listening on the specified port do not accept AMQP0-9 connections. The specified port must be one specified on the command line") + .withLongOpt("exclude-0-9").create(); + + private static final Option OPTION_EXCLUDE_0_8 = + OptionBuilder.withArgName("port").hasArg() + .withDescription("when listening on the specified port do not accept AMQP0-8 connections. The specified port must be one specified on the command line") + .withLongOpt("exclude-0-8").create(); + + private static final Option OPTION_JMX_PORT_REGISTRY_SERVER = + OptionBuilder.withArgName("port").hasArg() + .withDescription("listen on the specified management (registry server) port. Overrides any value in the config file") + .withLongOpt("jmxregistryport").create("m"); + + private static final Option OPTION_JMX_PORT_CONNECTOR_SERVER = + OptionBuilder.withArgName("port").hasArg() + .withDescription("listen on the specified management (connector server) port. Overrides any value in the config file") + .withLongOpt("jmxconnectorport").create(); + + private static final Option OPTION_BIND = + OptionBuilder.withArgName("address").hasArg() + .withDescription("bind to the specified address. Overrides any value in the config file") + .withLongOpt("bind").create("b"); + + private static final Option OPTION_LOG_CONFIG_FILE = + OptionBuilder.withArgName("file").hasArg() + .withDescription("use the specified log4j xml configuration file. By " + + "default looks for a file named " + BrokerOptions.DEFAULT_LOG_CONFIG_FILE + + " in the same directory as the configuration file").withLongOpt("logconfig").create("l"); + + private static final Option OPTION_LOG_WATCH = + OptionBuilder.withArgName("period").hasArg() + .withDescription("monitor the log file configuration file for changes. Units are seconds. " + + "Zero means do not check for changes.").withLongOpt("logwatch").create("w"); + + private static final Options OPTIONS = new Options(); + + static + { + OPTIONS.addOption(OPTION_HELP); + OPTIONS.addOption(OPTION_VERSION); + OPTIONS.addOption(OPTION_CONFIG_FILE); + OPTIONS.addOption(OPTION_LOG_CONFIG_FILE); + OPTIONS.addOption(OPTION_LOG_WATCH); + OPTIONS.addOption(OPTION_PORT); + OPTIONS.addOption(OPTION_SSLPORT); + OPTIONS.addOption(OPTION_EXCLUDE_0_10); + OPTIONS.addOption(OPTION_EXCLUDE_0_9_1); + OPTIONS.addOption(OPTION_EXCLUDE_0_9); + OPTIONS.addOption(OPTION_EXCLUDE_0_8); + OPTIONS.addOption(OPTION_BIND); + + OPTIONS.addOption(OPTION_JMX_PORT_REGISTRY_SERVER); + OPTIONS.addOption(OPTION_JMX_PORT_CONNECTOR_SERVER); + } + private CommandLine commandLine; public static void main(String[] args) @@ -56,7 +140,6 @@ public class Main public Main(final String[] args) { - setOptions(options); if (parseCommandline(args)) { try @@ -76,7 +159,7 @@ public class Main { try { - commandLine = new PosixParser().parse(options, args); + commandLine = new PosixParser().parse(OPTIONS, args); return true; } @@ -84,121 +167,52 @@ public class Main { System.err.println("Error: " + e.getMessage()); HelpFormatter formatter = new HelpFormatter(); - formatter.printHelp("Qpid", options, true); + formatter.printHelp("Qpid", OPTIONS, true); return false; } } - protected void setOptions(final Options options) - { - Option help = new Option("h", "help", false, "print this message"); - Option version = new Option("v", "version", false, "print the version information and exit"); - Option configFile = - OptionBuilder.withArgName("file").hasArg().withDescription("use given configuration file").withLongOpt("config") - .create("c"); - Option port = - OptionBuilder.withArgName("port").hasArg() - .withDescription("listen on the specified port. Overrides any value in the config file") - .withLongOpt("port").create("p"); - - Option exclude0_10 = - OptionBuilder.withArgName("exclude-0-10").hasArg() - .withDescription("when listening on the specified port do not accept AMQP0-10 connections. The specified port must be one specified on the command line") - .withLongOpt("exclude-0-10").create(); - - Option exclude0_9_1 = - OptionBuilder.withArgName("exclude-0-9-1").hasArg() - .withDescription("when listening on the specified port do not accept AMQP0-9-1 connections. The specified port must be one specified on the command line") - .withLongOpt("exclude-0-9-1").create(); - - - Option exclude0_9 = - OptionBuilder.withArgName("exclude-0-9").hasArg() - .withDescription("when listening on the specified port do not accept AMQP0-9 connections. The specified port must be one specified on the command line") - .withLongOpt("exclude-0-9").create(); - - - Option exclude0_8 = - OptionBuilder.withArgName("exclude-0-8").hasArg() - .withDescription("when listening on the specified port do not accept AMQP0-8 connections. The specified port must be one specified on the command line") - .withLongOpt("exclude-0-8").create(); - - - Option mport = - OptionBuilder.withArgName("mport").hasArg() - .withDescription("listen on the specified management port. Overrides any value in the config file") - .withLongOpt("mport").create("m"); - - - Option bind = - OptionBuilder.withArgName("bind").hasArg() - .withDescription("bind to the specified address. Overrides any value in the config file") - .withLongOpt("bind").create(BrokerOptions.BIND); - Option logconfig = - OptionBuilder.withArgName("logconfig").hasArg() - .withDescription("use the specified log4j xml configuration file. By " - + "default looks for a file named " + BrokerOptions.DEFAULT_LOG_CONFIG_FILE - + " in the same directory as the configuration file").withLongOpt("logconfig").create(BrokerOptions.LOG_CONFIG); - Option logwatchconfig = - OptionBuilder.withArgName("logwatch").hasArg() - .withDescription("monitor the log file configuration file for changes. Units are seconds. " - + "Zero means do not check for changes.").withLongOpt("logwatch").create(BrokerOptions.WATCH); - - Option sslport = - OptionBuilder.withArgName("sslport").hasArg() - .withDescription("SSL port. Overrides any value in the config file") - .withLongOpt("sslport").create(BrokerOptions.SSL_PORTS); - - options.addOption(help); - options.addOption(version); - options.addOption(configFile); - options.addOption(logconfig); - options.addOption(logwatchconfig); - options.addOption(port); - options.addOption(exclude0_10); - options.addOption(exclude0_9_1); - options.addOption(exclude0_9); - options.addOption(exclude0_8); - options.addOption(mport); - options.addOption(bind); - options.addOption(sslport); - } - protected void execute() throws Exception { BrokerOptions options = new BrokerOptions(); - String configFile = commandLine.getOptionValue(BrokerOptions.CONFIG); + String configFile = commandLine.getOptionValue(OPTION_CONFIG_FILE.getOpt()); if(configFile != null) { options.setConfigFile(configFile); } - String logWatchConfig = commandLine.getOptionValue(BrokerOptions.WATCH); + String logWatchConfig = commandLine.getOptionValue(OPTION_LOG_WATCH.getOpt()); if(logWatchConfig != null) { options.setLogWatchFrequency(Integer.parseInt(logWatchConfig)); } - String logConfig = commandLine.getOptionValue(BrokerOptions.LOG_CONFIG); + String logConfig = commandLine.getOptionValue(OPTION_LOG_CONFIG_FILE.getOpt()); if(logConfig != null) { options.setLogConfigFile(logConfig); } - String jmxPort = commandLine.getOptionValue(BrokerOptions.MANAGEMENT); - if(jmxPort != null) + String jmxPortRegistryServer = commandLine.getOptionValue(OPTION_JMX_PORT_REGISTRY_SERVER.getOpt()); + if(jmxPortRegistryServer != null) + { + options.setJmxPortRegistryServer(Integer.parseInt(jmxPortRegistryServer)); + } + + String jmxPortConnectorServer = commandLine.getOptionValue(OPTION_JMX_PORT_CONNECTOR_SERVER.getLongOpt()); + if(jmxPortConnectorServer != null) { - options.setJmxPort(Integer.parseInt(jmxPort)); + options.setJmxPortConnectorServer(Integer.parseInt(jmxPortConnectorServer)); } - String bindAddr = commandLine.getOptionValue(BrokerOptions.BIND); + String bindAddr = commandLine.getOptionValue(OPTION_BIND.getOpt()); if (bindAddr != null) { options.setBind(bindAddr); } - String[] portStr = commandLine.getOptionValues(BrokerOptions.PORTS); + String[] portStr = commandLine.getOptionValues(OPTION_PORT.getOpt()); if(portStr != null) { parsePortArray(options, portStr, false); @@ -208,7 +222,7 @@ public class Main } } - String[] sslPortStr = commandLine.getOptionValues(BrokerOptions.SSL_PORTS); + String[] sslPortStr = commandLine.getOptionValues(OPTION_SSLPORT.getOpt()); if(sslPortStr != null) { parsePortArray(options, sslPortStr, true); diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ServerConfiguration.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ServerConfiguration.java index dd2df45019..9ca916a633 100644 --- a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ServerConfiguration.java +++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ServerConfiguration.java @@ -58,7 +58,8 @@ public class ServerConfiguration extends ConfigurationPlugin public static final int DEFAULT_PORT = 5672; public static final int DEFAULT_SSL_PORT = 5671; public static final long DEFAULT_HOUSEKEEPING_PERIOD = 30000L; - public static final int DEFAULT_JMXPORT = 8999; + public static final int DEFAULT_JMXPORT_REGISTRYSERVER = 8999; + public static final int JMXPORT_CONNECTORSERVER_OFFSET = 100; public static final String QPID_HOME = "QPID_HOME"; public static final String QPID_WORK = "QPID_WORK"; @@ -77,6 +78,8 @@ public class ServerConfiguration extends ConfigurationPlugin // Configuration values to be read from the configuration file //todo Move all properties to static values to ensure system testing can be performed. public static final String MGMT_CUSTOM_REGISTRY_SOCKET = "management.custom-registry-socket"; + public static final String MGMT_JMXPORT_REGISTRYSERVER = "management.jmxport.registryServer"; + public static final String MGMT_JMXPORT_CONNECTORSERVER = "management.jmxport.connectorServer"; public static final String STATUS_UPDATES = "status-updates"; public static final String ADVANCED_LOCALE = "advanced.locale"; @@ -85,7 +88,8 @@ public class ServerConfiguration extends ConfigurationPlugin envVarMap.put("QPID_ENABLEDIRECTBUFFERS", "advanced.enableDirectBuffers"); envVarMap.put("QPID_SSLPORT", "connector.ssl.port"); envVarMap.put("QPID_WRITEBIASED", "advanced.useWriteBiasedPool"); - envVarMap.put("QPID_JMXPORT", "management.jmxport"); + envVarMap.put("QPID_JMXPORT_REGISTRYSERVER", MGMT_JMXPORT_REGISTRYSERVER); + envVarMap.put("QPID_JMXPORT_CONNECTORSERVER", MGMT_JMXPORT_CONNECTORSERVER); envVarMap.put("QPID_FRAMESIZE", "advanced.framesize"); envVarMap.put("QPID_MSGAUTH", "security.msg-auth"); envVarMap.put("QPID_AUTOREGISTER", "auto_register"); @@ -470,14 +474,24 @@ public class ServerConfiguration extends ConfigurationPlugin return System.getProperty(QPID_HOME); } - public void setJMXManagementPort(int mport) + public void setJMXPortRegistryServer(int registryServerPort) { - getConfig().setProperty("management.jmxport", mport); + getConfig().setProperty(MGMT_JMXPORT_REGISTRYSERVER, registryServerPort); } - public int getJMXManagementPort() + public int getJMXPortRegistryServer() { - return getIntValue("management.jmxport", DEFAULT_JMXPORT); + return getIntValue(MGMT_JMXPORT_REGISTRYSERVER, DEFAULT_JMXPORT_REGISTRYSERVER); + } + + public void setJMXPortConnectorServer(int connectorServerPort) + { + getConfig().setProperty(MGMT_JMXPORT_CONNECTORSERVER, connectorServerPort); + } + + public int getJMXConnectorServerPort() + { + return getIntValue(MGMT_JMXPORT_CONNECTORSERVER, getJMXPortRegistryServer() + JMXPORT_CONNECTORSERVER_OFFSET); } public boolean getUseCustomRMISocketFactory() diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/management/JMXManagedObjectRegistry.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/management/JMXManagedObjectRegistry.java index 6a34ff4a26..b44964f176 100644 --- a/qpid/java/broker/src/main/java/org/apache/qpid/server/management/JMXManagedObjectRegistry.java +++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/management/JMXManagedObjectRegistry.java @@ -72,15 +72,14 @@ public class JMXManagedObjectRegistry implements ManagedObjectRegistry { private static final Logger _log = Logger.getLogger(JMXManagedObjectRegistry.class); - public static final String MANAGEMENT_PORT_CONFIG_PATH = "management.jmxport"; - public static final int MANAGEMENT_PORT_DEFAULT = 8999; - public static final int PORT_EXPORT_OFFSET = 100; - private final MBeanServer _mbeanServer; private JMXConnectorServer _cs; private Registry _rmiRegistry; private boolean _useCustomSocketFactory; + private final int _jmxPortRegistryServer; + private final int _jmxPortConnectorServer; + public JMXManagedObjectRegistry() throws AMQException { _log.info("Initialising managed object registry using platform MBean server"); @@ -93,8 +92,11 @@ public class JMXManagedObjectRegistry implements ManagedObjectRegistry _mbeanServer = platformServer ? ManagementFactory.getPlatformMBeanServer() : MBeanServerFactory.createMBeanServer(ManagedObject.DOMAIN); - } + _jmxPortRegistryServer = appRegistry.getConfiguration().getJMXPortRegistryServer(); + _jmxPortConnectorServer = appRegistry.getConfiguration().getJMXConnectorServerPort(); + + } public void start() throws IOException, ConfigurationException { @@ -109,7 +111,6 @@ public class JMXManagedObjectRegistry implements ManagedObjectRegistry } IApplicationRegistry appRegistry = ApplicationRegistry.getInstance(); - int port = appRegistry.getConfiguration().getJMXManagementPort(); //Socket factories for the RMIConnectorServer, either default or SLL depending on configuration @@ -204,14 +205,14 @@ public class JMXManagedObjectRegistry implements ManagedObjectRegistry System.setProperty("java.rmi.server.randomIDs", "true"); if(_useCustomSocketFactory) { - _rmiRegistry = LocateRegistry.createRegistry(port, null, new CustomRMIServerSocketFactory()); + _rmiRegistry = LocateRegistry.createRegistry(_jmxPortRegistryServer, null, new CustomRMIServerSocketFactory()); } else { - _rmiRegistry = LocateRegistry.createRegistry(port, null, null); + _rmiRegistry = LocateRegistry.createRegistry(_jmxPortRegistryServer, null, null); } - CurrentActor.get().message(ManagementConsoleMessages.LISTENING("RMI Registry", port)); + CurrentActor.get().message(ManagementConsoleMessages.LISTENING("RMI Registry", _jmxPortRegistryServer)); /* * We must now create the RMI ConnectorServer manually, as the JMX Factory methods use RMI calls @@ -222,7 +223,7 @@ public class JMXManagedObjectRegistry implements ManagedObjectRegistry * The registry is exported on the defined management port 'port'. We will export the RMIConnectorServer * on 'port +1'. Use of these two well-defined ports will ease any navigation through firewall's. */ - final RMIServerImpl rmiConnectorServerStub = new RMIJRMPServerImpl(port+PORT_EXPORT_OFFSET, csf, ssf, env); + final RMIServerImpl rmiConnectorServerStub = new RMIJRMPServerImpl(_jmxPortConnectorServer, csf, ssf, env); String localHost; try { @@ -234,9 +235,9 @@ public class JMXManagedObjectRegistry implements ManagedObjectRegistry } final String hostname = localHost; final JMXServiceURL externalUrl = new JMXServiceURL( - "service:jmx:rmi://"+hostname+":"+(port+PORT_EXPORT_OFFSET)+"/jndi/rmi://"+hostname+":"+port+"/jmxrmi"); + "service:jmx:rmi://"+hostname+":"+(_jmxPortConnectorServer)+"/jndi/rmi://"+hostname+":"+_jmxPortRegistryServer+"/jmxrmi"); - final JMXServiceURL internalUrl = new JMXServiceURL("rmi", hostname, port+PORT_EXPORT_OFFSET); + final JMXServiceURL internalUrl = new JMXServiceURL("rmi", hostname, _jmxPortConnectorServer); _cs = new RMIConnectorServer(internalUrl, env, rmiConnectorServerStub, _mbeanServer) { @Override @@ -305,7 +306,7 @@ public class JMXManagedObjectRegistry implements ManagedObjectRegistry _cs.start(); String connectorServer = (sslEnabled ? "SSL " : "") + "JMX RMIConnectorServer"; - CurrentActor.get().message(ManagementConsoleMessages.LISTENING(connectorServer, port + PORT_EXPORT_OFFSET)); + CurrentActor.get().message(ManagementConsoleMessages.LISTENING(connectorServer, _jmxPortConnectorServer)); CurrentActor.get().message(ManagementConsoleMessages.READY(false)); } @@ -400,7 +401,7 @@ public class JMXManagedObjectRegistry implements ManagedObjectRegistry if (_rmiRegistry != null) { // Stopping the RMI registry - CurrentActor.get().message(ManagementConsoleMessages.SHUTTING_DOWN("RMI Registry", _cs.getAddress().getPort() - PORT_EXPORT_OFFSET)); + CurrentActor.get().message(ManagementConsoleMessages.SHUTTING_DOWN("RMI Registry", _jmxPortRegistryServer)); try { UnicastRemoteObject.unexportObject(_rmiRegistry, false); diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/BrokerOptionsTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/BrokerOptionsTest.java index 63423cbaa7..131f316330 100644 --- a/qpid/java/broker/src/test/java/org/apache/qpid/server/BrokerOptionsTest.java +++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/BrokerOptionsTest.java @@ -20,16 +20,11 @@ */ package org.apache.qpid.server; -import static org.apache.qpid.transport.ConnectionSettings.WILDCARD_ADDRESS; -import static org.apache.qpid.server.configuration.ServerConfiguration.DEFAULT_PORT; -import static org.apache.qpid.server.configuration.ServerConfiguration.DEFAULT_JMXPORT; - -import java.util.Collections; import java.util.Arrays; +import java.util.Collections; import java.util.HashSet; import java.util.Set; - import org.apache.qpid.test.utils.QpidTestCase; @@ -126,15 +121,26 @@ public class BrokerOptionsTest extends QpidTestCase assertEquals(testLogConfigFile, _options.getLogConfigFile()); } - public void testDefaultJmxPort() + public void testDefaultJmxPortRegistryServer() + { + assertNull(_options.getJmxPortRegistryServer()); + } + + public void testJmxPortRegistryServer() + { + _options.setJmxPortRegistryServer(TEST_PORT1); + assertEquals(Integer.valueOf(TEST_PORT1), _options.getJmxPortRegistryServer()); + } + + public void testDefaultJmxPortConnectorServer() { - assertNull(_options.getJmxPort()); + assertNull(_options.getJmxPortConnectorServer()); } - public void testJmxPort() + public void testJmxPortConnectorServer() { - _options.setJmxPort(TEST_PORT1); - assertEquals(Integer.valueOf(TEST_PORT1), _options.getJmxPort()); + _options.setJmxPortConnectorServer(TEST_PORT1); + assertEquals(Integer.valueOf(TEST_PORT1), _options.getJmxPortConnectorServer()); } public void testQpidHomeExposesSysProperty() diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/MainTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/MainTest.java index 3bb8d33190..9b0ae82b84 100644 --- a/qpid/java/broker/src/test/java/org/apache/qpid/server/MainTest.java +++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/MainTest.java @@ -17,7 +17,7 @@ public class MainTest extends QpidTestCase assertTrue(options.getPorts().isEmpty()); assertTrue(options.getSSLPorts().isEmpty()); - assertEquals(null, options.getJmxPort()); + assertEquals(null, options.getJmxPortRegistryServer()); assertEquals(null, options.getConfigFile()); assertEquals(null, options.getLogConfigFile()); assertEquals(null, options.getBind()); @@ -76,11 +76,21 @@ public class MainTest extends QpidTestCase assertEquals(1, options.getSSLPorts().size()); } - public void testJMXportOverridden() + public void testJmxPortRegistryServerOverridden() { - BrokerOptions options = startDummyMain("-m 3456"); + BrokerOptions options = startDummyMain("--jmxregistryport 3456"); - assertEquals(Integer.valueOf(3456), options.getJmxPort()); + assertEquals(Integer.valueOf(3456), options.getJmxPortRegistryServer()); + + options = startDummyMain("-m 3457"); + assertEquals(Integer.valueOf(3457), options.getJmxPortRegistryServer()); + } + + public void testJmxPortConnectorServerOverridden() + { + BrokerOptions options = startDummyMain("--jmxconnectorport 3456"); + + assertEquals(Integer.valueOf(3456), options.getJmxPortConnectorServer()); } public void testExclude0_10() diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/ServerConfigurationTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/ServerConfigurationTest.java index 7d54533632..d368a2d1ee 100644 --- a/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/ServerConfigurationTest.java +++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/ServerConfigurationTest.java @@ -58,18 +58,45 @@ public class ServerConfigurationTest extends QpidTestCase ApplicationRegistry.remove(); } - public void testSetJMXManagementPort() throws ConfigurationException + public void testSetJMXPortRegistryServer() throws ConfigurationException { _serverConfig.initialise(); - _serverConfig.setJMXManagementPort(23); - assertEquals(23, _serverConfig.getJMXManagementPort()); + _serverConfig.setJMXPortRegistryServer(23); + assertEquals(23, _serverConfig.getJMXPortRegistryServer()); } - public void testGetJMXManagementPort() throws ConfigurationException + public void testGetJMXPortRegistryServer() throws ConfigurationException { - _config.setProperty("management.jmxport", 42); + _config.setProperty(ServerConfiguration.MGMT_JMXPORT_REGISTRYSERVER, 42); _serverConfig.initialise(); - assertEquals(42, _serverConfig.getJMXManagementPort()); + assertEquals(42, _serverConfig.getJMXPortRegistryServer()); + } + + public void testDefaultJMXPortRegistryServer() throws ConfigurationException + { + _serverConfig.initialise(); + assertEquals(8999, _serverConfig.getJMXPortRegistryServer()); + } + + public void testSetJMXPortConnectorServer() throws ConfigurationException + { + ServerConfiguration serverConfig = new ServerConfiguration(_config); + serverConfig.setJMXPortConnectorServer(67); + assertEquals(67, serverConfig.getJMXConnectorServerPort()); + } + + public void testGetJMXPortConnectorServer() throws ConfigurationException + { + _config.setProperty(ServerConfiguration.MGMT_JMXPORT_CONNECTORSERVER, 67); + ServerConfiguration serverConfig = new ServerConfiguration(_config); + assertEquals(67, serverConfig.getJMXConnectorServerPort()); + } + + public void testDefaultJMXPortConnectorServer() throws ConfigurationException + { + ServerConfiguration serverConfig = new ServerConfiguration(_config); + assertEquals(ServerConfiguration.DEFAULT_JMXPORT_REGISTRYSERVER + ServerConfiguration.JMXPORT_CONNECTORSERVER_OFFSET, + serverConfig.getJMXConnectorServerPort()); } public void testGetPlatformMbeanserver() throws ConfigurationException diff --git a/qpid/java/systests/etc/config-systests-firewall-2.xml b/qpid/java/systests/etc/config-systests-firewall-2.xml index f16cce6b85..2549a7e6c4 100644 --- a/qpid/java/systests/etc/config-systests-firewall-2.xml +++ b/qpid/java/systests/etc/config-systests-firewall-2.xml @@ -42,13 +42,6 @@ </connector> <management> <enabled>false</enabled> - <jmxport>8999</jmxport> - <ssl> - <enabled>false</enabled> - <!-- Update below path to your keystore location, eg ${conf}/qpid.keystore --> - <keyStorePath>${prefix}/../test-profiles/test_resources/ssl/keystore.jks</keyStorePath> - <keyStorePassword>password</keyStorePassword> - </ssl> </management> <advanced> <filterchain enableExecutorPool="true"/> diff --git a/qpid/java/systests/etc/config-systests-firewall-3.xml b/qpid/java/systests/etc/config-systests-firewall-3.xml index 71644e4185..0cafb6d70a 100644 --- a/qpid/java/systests/etc/config-systests-firewall-3.xml +++ b/qpid/java/systests/etc/config-systests-firewall-3.xml @@ -42,13 +42,6 @@ </connector> <management> <enabled>false</enabled> - <jmxport>8999</jmxport> - <ssl> - <enabled>false</enabled> - <!-- Update below path to your keystore location, eg ${conf}/qpid.keystore --> - <keyStorePath>${prefix}/../test-profiles/test_resources/ssl/keystore.jks</keyStorePath> - <keyStorePassword>password</keyStorePassword> - </ssl> </management> <advanced> <filterchain enableExecutorPool="true"/> diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ManagementLoggingTest.java b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ManagementLoggingTest.java index 9feca7279e..24e6aa4207 100644 --- a/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ManagementLoggingTest.java +++ b/qpid/java/systests/src/main/java/org/apache/qpid/server/logging/ManagementLoggingTest.java @@ -22,6 +22,7 @@ package org.apache.qpid.server.logging; import junit.framework.AssertionFailedError; +import org.apache.qpid.server.configuration.ServerConfiguration; import org.apache.qpid.util.LogMonitor; import java.util.List; @@ -206,7 +207,7 @@ public class ManagementLoggingTest extends AbstractTestLogging validateMessageID("MNG-1002", log); //Check the RMI Registry port is as expected - int mPort = getPort() + (DEFAULT_MANAGEMENT_PORT - DEFAULT_PORT); + int mPort = getManagementPort(getPort()); assertTrue("RMI Registry port not as expected(" + mPort + ").:" + getMessageString(log), getMessageString(log).endsWith(String.valueOf(mPort))); @@ -217,7 +218,7 @@ public class ManagementLoggingTest extends AbstractTestLogging // We expect the RMI Registry port (the defined 'management port') to be // 100 lower than the JMX RMIConnector Server Port (the actual JMX server) - int jmxPort = mPort + 100; + int jmxPort = mPort + ServerConfiguration.JMXPORT_CONNECTORSERVER_OFFSET; assertTrue("JMX RMIConnectorServer port not as expected(" + jmxPort + ").:" + getMessageString(log), getMessageString(log).endsWith(String.valueOf(jmxPort))); } diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java b/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java index 0a98fc3382..40df024c67 100644 --- a/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java +++ b/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java @@ -137,7 +137,7 @@ public class QpidBrokerTestCase extends QpidTestCase public static final int DEFAULT_VM_PORT = 1; public static final int DEFAULT_PORT = Integer.getInteger("test.port", ServerConfiguration.DEFAULT_PORT); public static final int FAILING_PORT = Integer.parseInt(System.getProperty("test.port.alt")); - public static final int DEFAULT_MANAGEMENT_PORT = Integer.getInteger("test.mport", ServerConfiguration.DEFAULT_JMXPORT); + public static final int DEFAULT_MANAGEMENT_PORT = Integer.getInteger("test.mport", ServerConfiguration.DEFAULT_JMXPORT_REGISTRYSERVER); public static final int DEFAULT_SSL_PORT = Integer.getInteger("test.port.ssl", ServerConfiguration.DEFAULT_SSL_PORT); protected String _brokerLanguage = System.getProperty(BROKER_LANGUAGE, JAVA); @@ -480,7 +480,7 @@ public class QpidBrokerTestCase extends QpidTestCase addExcludedPorts(port, DEFAULT_SSL_PORT, options); - options.setJmxPort(getManagementPort(port)); + options.setJmxPortRegistryServer(getManagementPort(port)); //Set the log config file, relying on the log4j.configuration system property //set on the JVM by the JUnit runner task in module.xml. |
