diff options
| author | Martin Ritchie <ritchiem@apache.org> | 2007-07-17 11:33:08 +0000 |
|---|---|---|
| committer | Martin Ritchie <ritchiem@apache.org> | 2007-07-17 11:33:08 +0000 |
| commit | b101bd671ef4372c91642c8284820595a4c04521 (patch) | |
| tree | 548ded26c6c7a01531bac5284818f4deeb206840 /java | |
| parent | b71371b892bec1645fb218c74f66baad81325328 (diff) | |
| download | qpid-python-b101bd671ef4372c91642c8284820595a4c04521.tar.gz | |
Change to allow the management port to be specified on the command line, via -m or --mport
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/branches/M2@556888 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java')
| -rw-r--r-- | java/broker/src/main/java/org/apache/qpid/server/Main.java | 89 | ||||
| -rw-r--r-- | java/broker/src/main/java/org/apache/qpid/server/management/JMXManagedObjectRegistry.java | 44 |
2 files changed, 85 insertions, 48 deletions
diff --git a/java/broker/src/main/java/org/apache/qpid/server/Main.java b/java/broker/src/main/java/org/apache/qpid/server/Main.java index baf3c5bc61..a87c704cf8 100644 --- a/java/broker/src/main/java/org/apache/qpid/server/Main.java +++ b/java/broker/src/main/java/org/apache/qpid/server/Main.java @@ -20,14 +20,6 @@ */ package org.apache.qpid.server; -import java.io.File; -import java.io.IOException; -import java.net.InetAddress; -import java.net.InetSocketAddress; -import java.net.BindException; -import java.util.Collection; -import java.util.List; - import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.HelpFormatter; import org.apache.commons.cli.Option; @@ -35,23 +27,22 @@ 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.commons.configuration.Configuration; import org.apache.commons.configuration.ConfigurationException; - import org.apache.log4j.BasicConfigurator; import org.apache.log4j.Logger; import org.apache.log4j.xml.DOMConfigurator; - import org.apache.mina.common.ByteBuffer; import org.apache.mina.common.IoAcceptor; import org.apache.mina.common.SimpleByteBufferAllocator; import org.apache.mina.transport.socket.nio.SocketAcceptorConfig; import org.apache.mina.transport.socket.nio.SocketSessionConfig; - import org.apache.qpid.AMQException; import org.apache.qpid.common.QpidProperties; import org.apache.qpid.framing.ProtocolVersion; import org.apache.qpid.pool.ReadWriteThreadModel; import org.apache.qpid.server.configuration.VirtualHostConfiguration; +import org.apache.qpid.server.management.JMXManagedObjectRegistry; import org.apache.qpid.server.protocol.AMQPFastProtocolHandler; import org.apache.qpid.server.protocol.AMQPProtocolProvider; import org.apache.qpid.server.registry.ApplicationRegistry; @@ -59,11 +50,19 @@ import org.apache.qpid.server.registry.ConfigurationFileApplicationRegistry; import org.apache.qpid.server.transport.ConnectorConfiguration; import org.apache.qpid.url.URLSyntaxException; +import java.io.File; +import java.io.IOException; +import java.net.BindException; +import java.net.InetAddress; +import java.net.InetSocketAddress; +import java.util.Collection; +import java.util.List; + /** * Main entry point for AMQPD. * */ -@SuppressWarnings({ "AccessStaticViaInstance" }) +@SuppressWarnings({"AccessStaticViaInstance"}) public class Main { private static final Logger _logger = Logger.getLogger(Main.class); @@ -74,8 +73,8 @@ public class Main private static final String DEFAULT_LOG_CONFIG_FILENAME = "log4j.xml"; public static final String QPID_HOME = "QPID_HOME"; private static final int IPV4_ADDRESS_LENGTH = 4; - - private static final char IPV4_LITERAL_SEPARATOR = '.'; + + private static final char IPV4_LITERAL_SEPARATOR = '.'; protected static class InitException extends Exception { @@ -126,6 +125,12 @@ public class Main OptionBuilder.withArgName("port").hasArg() .withDescription("listen on the specified port. Overrides any value in the config file") .withLongOpt("port").create("p"); + 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") @@ -146,6 +151,7 @@ public class Main options.addOption(logconfig); options.addOption(logwatchconfig); options.addOption(port); + options.addOption(mport); options.addOption(bind); } @@ -244,7 +250,15 @@ public class Main configureLogging(logConfigFile, logWatchConfig); } - ApplicationRegistry.initialise(new ConfigurationFileApplicationRegistry(configFile)); + ConfigurationFileApplicationRegistry config = new ConfigurationFileApplicationRegistry(configFile); + + + updateManagementPort(config.getConfiguration(), commandLine.getOptionValue("m")); + + + + ApplicationRegistry.initialise(config); + //fixme .. use QpidProperties.getVersionString when we have fixed the classpath issues // that are causing the broker build to pick up the wrong properties file and hence say @@ -303,6 +317,29 @@ public class Main } + /** + * Update the configuration data with the management port. + * @param configuration + * @param managementPort The string from the command line + */ + private void updateManagementPort(Configuration configuration, String managementPort) + { + if (managementPort != null) + { + int mport; + int defaultMPort = configuration.getInt(JMXManagedObjectRegistry.MANAGEMENT_PORT_CONFIG_PATH); + try + { + mport = Integer.parseInt(managementPort); + configuration.setProperty(JMXManagedObjectRegistry.MANAGEMENT_PORT_CONFIG_PATH, mport); + } + catch (NumberFormatException e) + { + _logger.warn("Invalid management port: " + managementPort + " will use default:" + defaultMPort, e); + } + } + } + protected void setupVirtualHosts(String configFileParent, String configFilePath) throws ConfigurationException, AMQException, URLSyntaxException { @@ -388,7 +425,7 @@ public class Main try { - acceptor.bind(new InetSocketAddress(connectorConfig.sslPort), handler, sconfig); + acceptor.bind(new InetSocketAddress(connectorConfig.sslPort), handler, sconfig); //fixme qpid.AMQP should be using qpidproperties to get value _brokerLogger.info("Qpid.AMQP listening on SSL port " + connectorConfig.sslPort); @@ -419,30 +456,30 @@ public class Main private byte[] parseIP(String address) throws Exception { - char[] literalBuffer = address.toCharArray(); + char[] literalBuffer = address.toCharArray(); int byteCount = 0; int currByte = 0; byte[] ip = new byte[IPV4_ADDRESS_LENGTH]; - for (int i = 0 ; i < literalBuffer.length ; i++) + for (int i = 0; i < literalBuffer.length; i++) { char currChar = literalBuffer[i]; - if ((currChar >= '0') && (currChar <= '9')) + if ((currChar >= '0') && (currChar <= '9')) { - currByte = (currByte * 10) + (Character.digit(currChar, 10) & 0xFF); - } + currByte = (currByte * 10) + (Character.digit(currChar, 10) & 0xFF); + } - if (currChar == IPV4_LITERAL_SEPARATOR || (i + 1 == literalBuffer.length)) + if (currChar == IPV4_LITERAL_SEPARATOR || (i + 1 == literalBuffer.length)) { - ip[byteCount++] = (byte)currByte; + ip[byteCount++] = (byte) currByte; currByte = 0; - } + } } if (byteCount != 4) { throw new Exception("Invalid IP address: " + address); - } - return ip; + } + return ip; } private void configureLogging(File logConfigFile, String logWatchConfig) diff --git a/java/broker/src/main/java/org/apache/qpid/server/management/JMXManagedObjectRegistry.java b/java/broker/src/main/java/org/apache/qpid/server/management/JMXManagedObjectRegistry.java index f277398b50..4caae2b26f 100644 --- a/java/broker/src/main/java/org/apache/qpid/server/management/JMXManagedObjectRegistry.java +++ b/java/broker/src/main/java/org/apache/qpid/server/management/JMXManagedObjectRegistry.java @@ -20,14 +20,14 @@ */ package org.apache.qpid.server.management; -import java.io.IOException; -import java.lang.management.ManagementFactory; -import java.rmi.RemoteException; -import java.rmi.registry.LocateRegistry; -import java.rmi.registry.Registry; -import java.rmi.server.UnicastRemoteObject; -import java.util.HashMap; -import java.util.Map; +import org.apache.log4j.Logger; +import org.apache.qpid.AMQException; +import org.apache.qpid.server.registry.ApplicationRegistry; +import org.apache.qpid.server.registry.IApplicationRegistry; +import org.apache.qpid.server.security.auth.database.Base64MD5PasswordFilePrincipalDatabase; +import org.apache.qpid.server.security.auth.database.PlainPasswordFilePrincipalDatabase; +import org.apache.qpid.server.security.auth.database.PrincipalDatabase; +import org.apache.qpid.server.security.auth.sasl.crammd5.CRAMMD5HashedInitialiser; import javax.management.JMException; import javax.management.MBeanServer; @@ -43,17 +43,14 @@ import javax.security.auth.callback.PasswordCallback; import javax.security.auth.callback.UnsupportedCallbackException; import javax.security.auth.login.AccountNotFoundException; import javax.security.sasl.AuthorizeCallback; - -import org.apache.log4j.Logger; - -import org.apache.qpid.AMQException; -import org.apache.qpid.server.registry.ApplicationRegistry; -import org.apache.qpid.server.registry.IApplicationRegistry; -import org.apache.qpid.server.security.auth.database.PrincipalDatabase; -import org.apache.qpid.server.security.auth.database.Base64MD5PasswordFilePrincipalDatabase; -import org.apache.qpid.server.security.auth.database.PlainPasswordFilePrincipalDatabase; -import org.apache.qpid.server.security.auth.sasl.UsernamePrincipal; -import org.apache.qpid.server.security.auth.sasl.crammd5.CRAMMD5HashedInitialiser; +import java.io.IOException; +import java.lang.management.ManagementFactory; +import java.rmi.RemoteException; +import java.rmi.registry.LocateRegistry; +import java.rmi.registry.Registry; +import java.rmi.server.UnicastRemoteObject; +import java.util.HashMap; +import java.util.Map; /** * This class starts up an MBeanserver. If out of the box agent is being used then there are no security features @@ -68,6 +65,9 @@ public class JMXManagedObjectRegistry implements ManagedObjectRegistry private final MBeanServer _mbeanServer; private Registry _rmiRegistry; private JMXServiceURL _jmxURL; + + public static final String MANAGEMENT_PORT_CONFIG_PATH = "management.jmxport"; + public static final int MANAGEMENT_PORT_DEFAULT = 8999; public JMXManagedObjectRegistry() throws AMQException { @@ -95,7 +95,7 @@ public class JMXManagedObjectRegistry implements ManagedObjectRegistry IApplicationRegistry appRegistry = ApplicationRegistry.getInstance(); boolean security = appRegistry.getConfiguration().getBoolean("management.security-enabled", false); - int port = appRegistry.getConfiguration().getInt("management.jmxport", 8999); + int port = appRegistry.getConfiguration().getInt(MANAGEMENT_PORT_CONFIG_PATH, MANAGEMENT_PORT_DEFAULT); if (security) { @@ -144,13 +144,13 @@ public class JMXManagedObjectRegistry implements ManagedObjectRegistry MBeanServerForwarder mbsf = MBeanInvocationHandlerImpl.newProxyInstance(); cs.setMBeanServerForwarder(mbsf); cs.start(); - _log.warn("JMX: Started JMXConnector server with SASL"); + _log.warn("JMX: Started JMXConnector server on port '" + port + "' with SASL"); } else { startJMXConnectorServer(port); - _log.warn("JMX: Started JMXConnector server with security disabled"); + _log.warn("JMX: Started JMXConnector server on port '" + port + "' with security disabled"); } } |
