Skip to content

Commit

Permalink
JMX: Disable creating by default an RMI JMX connector, closes #348.
Browse files Browse the repository at this point in the history
  • Loading branch information
kimchy committed Sep 2, 2010
1 parent 0250896 commit 7bd08d6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
Expand Up @@ -31,7 +31,6 @@
import org.elasticsearch.common.logging.log4j.LogConfigurator;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.env.Environment;
import org.elasticsearch.jmx.JmxService;
import org.elasticsearch.node.Node;
import org.elasticsearch.node.NodeBuilder;
import org.elasticsearch.node.internal.InternalSettingsPerparer;
Expand All @@ -43,7 +42,6 @@
import static jline.ANSIBuffer.ANSICodes.*;
import static org.elasticsearch.common.collect.Sets.*;
import static org.elasticsearch.common.settings.ImmutableSettings.Builder.*;
import static org.elasticsearch.common.settings.ImmutableSettings.*;

/**
* A main entry point when starting from the command line.
Expand Down Expand Up @@ -73,11 +71,12 @@ private void setup(boolean addShutdownHook, Tuple<Settings, Environment> tuple)
}

private static Tuple<Settings, Environment> setupJmx(Tuple<Settings, Environment> tuple) {
if (tuple.v1().get(JmxService.SettingsConstants.CREATE_CONNECTOR) == null) {
// automatically create the connector if we are bootstrapping
Settings updated = settingsBuilder().put(tuple.v1()).put(JmxService.SettingsConstants.CREATE_CONNECTOR, true).build();
tuple = new Tuple<Settings, Environment>(updated, tuple.v2());
}
// We disable JMX on by default, since we don't really want the overhead of RMI (and RMI GC...)
// if (tuple.v1().get(JmxService.SettingsConstants.CREATE_CONNECTOR) == null) {
// // automatically create the connector if we are bootstrapping
// Settings updated = settingsBuilder().put(tuple.v1()).put(JmxService.SettingsConstants.CREATE_CONNECTOR, true).build();
// tuple = new Tuple<Settings, Environment>(updated, tuple.v2());
// }
return tuple;
}

Expand Down
Expand Up @@ -98,6 +98,16 @@ public void connectAndRegister(String nodeDescription, final NetworkService netw
started = true;
this.nodeDescription = nodeDescription;
if (settings.getAsBoolean(SettingsConstants.CREATE_CONNECTOR, false)) {
// we are going to create the connector, set the GC interval to a large value
try {
if (System.getProperty("sun.rmi.dgc.client.gcInterval") == null)
System.setProperty("sun.rmi.dgc.client.gcInterval", "36000000");
if (System.getProperty("sun.rmi.dgc.server.gcInterval") == null)
System.setProperty("sun.rmi.dgc.server.gcInterval", "36000000");
} catch (Exception secExc) {
logger.warn("Failed to set sun.rmi.dgc.xxx system properties", secExc);
}

final String port = settings.get("jmx.port", "9400-9500");

PortsRange portsRange = new PortsRange(port);
Expand Down

0 comments on commit 7bd08d6

Please sign in to comment.