Author: ritchiem
Date: Tue Jul 17 04:33:08 2007
New Revision: 556888
URL: http://svn.apache.org/viewvc?view=rev&rev=556888
Log:
Change to allow the management port to be specified on the command line, via -m
or --mport
Modified:
incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/server/Main.java
incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/server/management/JMXManagedObjectRegistry.java
Modified:
incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/server/Main.java
URL:
http://svn.apache.org/viewvc/incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/server/Main.java?view=diff&rev=556888&r1=556887&r2=556888
==============================================================================
---
incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/server/Main.java
(original)
+++
incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/server/Main.java
Tue Jul 17 04:33:08 2007
@@ -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.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.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.
*
*/
[EMAIL PROTECTED]({ "AccessStaticViaInstance" })
[EMAIL PROTECTED]({"AccessStaticViaInstance"})
public class Main
{
private static final Logger _logger = Logger.getLogger(Main.class);
@@ -74,8 +73,8 @@
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 @@
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 @@
options.addOption(logconfig);
options.addOption(logwatchconfig);
options.addOption(port);
+ options.addOption(mport);
options.addOption(bind);
}
@@ -244,7 +250,15 @@
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 @@
}
+ /**
+ * 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 @@
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 @@
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)
Modified:
incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/server/management/JMXManagedObjectRegistry.java
URL:
http://svn.apache.org/viewvc/incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/server/management/JMXManagedObjectRegistry.java?view=diff&rev=556888&r1=556887&r2=556888
==============================================================================
---
incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/server/management/JMXManagedObjectRegistry.java
(original)
+++
incubator/qpid/branches/M2/java/broker/src/main/java/org/apache/qpid/server/management/JMXManagedObjectRegistry.java
Tue Jul 17 04:33:08 2007
@@ -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.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 @@
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 @@
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 @@
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");
}
}