mirror of https://github.com/apache/lucene.git
LUCENE-4337: Revert JMX code, was not needed in that complexity.
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1379006 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
2fdd58398a
commit
72c1b74d5c
|
@ -61,13 +61,6 @@ public class JmxMonitoredMap<K, V> extends
|
||||||
|
|
||||||
public JmxMonitoredMap(String coreName, String coreHashCode,
|
public JmxMonitoredMap(String coreName, String coreHashCode,
|
||||||
final JmxConfiguration jmxConfig) {
|
final JmxConfiguration jmxConfig) {
|
||||||
this(coreName, coreHashCode, jmxConfig, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Make public? Move Map<String,?> env to environment?
|
|
||||||
// Currently the map is needed to bind to localhost
|
|
||||||
JmxMonitoredMap(String coreName, String coreHashCode,
|
|
||||||
final JmxConfiguration jmxConfig, Map<String,?> env) {
|
|
||||||
this.coreHashCode = coreHashCode;
|
this.coreHashCode = coreHashCode;
|
||||||
jmxRootName = (null != jmxConfig.rootName ?
|
jmxRootName = (null != jmxConfig.rootName ?
|
||||||
jmxConfig.rootName
|
jmxConfig.rootName
|
||||||
|
@ -101,7 +94,7 @@ public class JmxMonitoredMap<K, V> extends
|
||||||
server = MBeanServerFactory.newMBeanServer();
|
server = MBeanServerFactory.newMBeanServer();
|
||||||
JMXConnectorServer connector = JMXConnectorServerFactory
|
JMXConnectorServer connector = JMXConnectorServerFactory
|
||||||
.newJMXConnectorServer(new JMXServiceURL(jmxConfig.serviceUrl),
|
.newJMXConnectorServer(new JMXServiceURL(jmxConfig.serviceUrl),
|
||||||
env, server);
|
null, server);
|
||||||
connector.start();
|
connector.start();
|
||||||
LOG.info("JMX monitoring is enabled at " + jmxConfig.serviceUrl);
|
LOG.info("JMX monitoring is enabled at " + jmxConfig.serviceUrl);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
package org.apache.solr.core;
|
package org.apache.solr.core;
|
||||||
|
|
||||||
import org.apache.lucene.util.LuceneTestCase;
|
import org.apache.lucene.util.LuceneTestCase;
|
||||||
|
import org.apache.solr.util.AbstractSolrTestCase;
|
||||||
import org.apache.solr.common.util.NamedList;
|
import org.apache.solr.common.util.NamedList;
|
||||||
import org.apache.solr.core.SolrConfig.JmxConfiguration;
|
import org.apache.solr.core.SolrConfig.JmxConfiguration;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
|
@ -32,13 +33,10 @@ import javax.management.remote.JMXConnectorFactory;
|
||||||
import javax.management.remote.JMXServiceURL;
|
import javax.management.remote.JMXServiceURL;
|
||||||
import javax.management.remote.rmi.RMIConnectorServer;
|
import javax.management.remote.rmi.RMIConnectorServer;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.InetSocketAddress;
|
|
||||||
import java.net.Socket;
|
|
||||||
import java.net.ServerSocket;
|
import java.net.ServerSocket;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.rmi.registry.LocateRegistry;
|
import java.rmi.registry.LocateRegistry;
|
||||||
import java.rmi.server.RMIServerSocketFactory;
|
import java.rmi.server.RMIServerSocketFactory;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import static org.hamcrest.CoreMatchers.allOf;
|
import static org.hamcrest.CoreMatchers.allOf;
|
||||||
|
@ -64,12 +62,11 @@ public class TestJmxMonitoredMap extends LuceneTestCase {
|
||||||
@Override
|
@Override
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
|
|
||||||
super.setUp();
|
super.setUp();
|
||||||
String oldHost = System.getProperty("java.rmi.server.hostname");
|
String oldHost = System.getProperty("java.rmi.server.hostname");
|
||||||
try {
|
try {
|
||||||
// this stupid sysprop thing is needed, because remote stubs use the
|
// this stupid sysprop thing is needed, because remote stubs use an
|
||||||
// hostname to connect, which does not work with server bound to 127.0.0.1
|
// arbitrary local ip to connect
|
||||||
// See: http://weblogs.java.net/blog/emcmanus/archive/2006/12/multihomed_comp.html
|
// See: http://weblogs.java.net/blog/emcmanus/archive/2006/12/multihomed_comp.html
|
||||||
System.setProperty("java.rmi.server.hostname", "127.0.0.1");
|
System.setProperty("java.rmi.server.hostname", "127.0.0.1");
|
||||||
class LocalhostRMIServerSocketFactory implements RMIServerSocketFactory {
|
class LocalhostRMIServerSocketFactory implements RMIServerSocketFactory {
|
||||||
|
@ -77,19 +74,16 @@ public class TestJmxMonitoredMap extends LuceneTestCase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ServerSocket createServerSocket(int port) throws IOException {
|
public ServerSocket createServerSocket(int port) throws IOException {
|
||||||
socket = new ServerSocket();
|
return socket = new ServerSocket(port);
|
||||||
socket.bind(new InetSocketAddress("127.0.0.1", port));
|
|
||||||
return socket;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
LocalhostRMIServerSocketFactory factory = new LocalhostRMIServerSocketFactory();
|
LocalhostRMIServerSocketFactory factory = new LocalhostRMIServerSocketFactory();
|
||||||
LocateRegistry.createRegistry(0, null, factory);
|
LocateRegistry.createRegistry(0, null, factory);
|
||||||
port = factory.socket.getLocalPort();
|
port = factory.socket.getLocalPort();
|
||||||
//System.out.println("Using port: " + port);
|
AbstractSolrTestCase.log.info("Using port: " + port);
|
||||||
String url = "service:jmx:rmi://127.0.0.1:"+port+"/jndi/rmi://127.0.0.1:"+port+"/solrjmx";
|
String url = "service:jmx:rmi:///jndi/rmi://127.0.0.1:"+port+"/solrjmx";
|
||||||
JmxConfiguration config = new JmxConfiguration(true, null, url, null);
|
JmxConfiguration config = new JmxConfiguration(true, null, url, null);
|
||||||
monitoredMap = new JmxMonitoredMap<String, SolrInfoMBean>("", "", config,
|
monitoredMap = new JmxMonitoredMap<String, SolrInfoMBean>("", "", config);
|
||||||
Collections.singletonMap(RMIConnectorServer.RMI_SERVER_SOCKET_FACTORY_ATTRIBUTE, factory));
|
|
||||||
JMXServiceURL u = new JMXServiceURL(url);
|
JMXServiceURL u = new JMXServiceURL(url);
|
||||||
connector = JMXConnectorFactory.connect(u);
|
connector = JMXConnectorFactory.connect(u);
|
||||||
mbeanServer = connector.getMBeanServerConnection();
|
mbeanServer = connector.getMBeanServerConnection();
|
||||||
|
|
Loading…
Reference in New Issue