soreuse addr on rmi connector and enable some debug logging to track down hudson jmx related intermittent failures

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@833376 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gary Tully 2009-11-06 12:26:34 +00:00
parent 46a7f9eeab
commit f1fa8f911d
3 changed files with 19 additions and 4 deletions

View File

@ -19,8 +19,10 @@ package org.apache.activemq.broker.jmx;
import java.io.IOException;
import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.ServerSocket;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.rmi.server.RMIServerSocketFactory;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
@ -89,17 +91,20 @@ public class ManagementContext implements Service {
try {
getMBeanServer().invoke(namingServiceObjectName, "start", null, null);
} catch (Throwable ignore) {
LOG.debug("ignored error on start invocation", ignore);
}
Thread t = new Thread("JMX connector") {
public void run() {
try {
JMXConnectorServer server = connectorServer;
if (started.get() && server != null) {
LOG.debug("Starting JMX JMXConnectorServer...");
server.start();
LOG.info("JMX consoles can connect to " + server.getAddress());
}
} catch (IOException e) {
LOG.warn("Failed to start jmx connector: " + e.getMessage());
LOG.debug("Reason for failed jms connector start", e);
}
}
};
@ -403,9 +408,15 @@ public class ManagementContext implements Service {
private void createConnector(MBeanServer mbeanServer) throws MalformedObjectNameException, MalformedURLException, IOException {
// Create the NamingService, needed by JSR 160
try {
if (registry == null) {
registry = LocateRegistry.createRegistry(connectorPort);
}
if (registry == null) {
registry = LocateRegistry.createRegistry(connectorPort, null, new RMIServerSocketFactory() {
public ServerSocket createServerSocket(int port)
throws IOException {
ServerSocket result = new ServerSocket(port);
result.setReuseAddress(true);
return result;
}});
}
namingServiceObjectName = ObjectName.getInstance("naming:type=rmiregistry");
// Do not use the createMBean as the mx4j jar may not be in the
// same class loader than the server

View File

@ -25,7 +25,6 @@ import junit.framework.TestCase;
import org.apache.activemq.broker.BrokerPlugin;
import org.apache.activemq.broker.BrokerPluginSupport;
import org.apache.activemq.broker.BrokerService;
import org.apache.activemq.util.SocketProxy;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@ -89,5 +88,7 @@ public class MasterSlaveSlaveDieTest extends TestCase {
LOG.info("checking master still alive");
assertTrue("master is still alive", master.isStarted());
assertFalse("plugin was not yet stopped", pluginStopped.get());
master.stop();
master.waitUntilStopped();
}
}

View File

@ -22,6 +22,9 @@ log4j.rootLogger=INFO, out, stdout
#log4j.logger.org.apache.activemq=DEBUG
# get to the bottom of jmx related intermittent failures
log4j.logger.org.apache.activemq.broker.jmx.ManagementContext=DEBUG
# CONSOLE appender not used by default
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout