opends/resource/config/config.ldif
@@ -95,7 +95,7 @@ objectClass: ds-cfg-alert-handler cn: JMX Alert Handler ds-cfg-alert-handler-class: org.opends.server.extensions.JMXAlertHandler ds-cfg-alert-handler-enabled: true ds-cfg-alert-handler-enabled: false dn: cn=Backends,cn=config objectClass: top @@ -372,7 +372,7 @@ objectClass: ds-cfg-jmx-connection-handler cn: JMX Connection Handler ds-cfg-connection-handler-class: org.opends.server.protocols.jmx.JmxConnectionHandler ds-cfg-connection-handler-enabled: true ds-cfg-connection-handler-enabled: false ds-cfg-use-ssl: false ds-cfg-listen-port: 1689 ds-cfg-ssl-cert-nickname: server-cert opends/src/quicksetup/org/opends/quicksetup/installer/Installer.java
@@ -694,9 +694,11 @@ sec.getCertificateType()); } // For the moment do not enable JMX /* argList.add("-x"); argList.add(String.valueOf(getUserData().getServerJMXPort())); */ argList.add("-D"); argList.add(getUserData().getDirectoryManagerDn()); @@ -1688,11 +1690,13 @@ qs.displayFieldInvalid(FieldName.DIRECTORY_MANAGER_PWD_CONFIRM, false); } // For the moment do not enable JMX int defaultJMXPort = UserData.getDefaultJMXPort(new int[] {port, securePort}); if (defaultJMXPort != -1) { getUserData().setServerJMXPort(defaultJMXPort); //getUserData().setServerJMXPort(defaultJMXPort); getUserData().setServerJMXPort(-1); } if (errorMsgs.size() > 0) opends/src/server/org/opends/server/messages/ProtocolMessages.java
@@ -4617,6 +4617,13 @@ public static final int MSGID_LDAP_FILTER_ENCLOSED_IN_APOSTROPHES = CATEGORY_MASK_PROTOCOL | SEVERITY_MASK_MILD_ERROR | 427; /** * The message ID for the message that will be used as the description of the * configuration attribute specifying whether to enable the LDAPS * connection handler. */ public static final int MSGID_JMX_CONNHANDLER_DESCRIPTION_ENABLE = CATEGORY_MASK_PROTOCOL | SEVERITY_MASK_INFORMATIONAL | 428; /** * Associates a set of generic messages with the message IDs defined in this @@ -6371,6 +6378,9 @@ "configuration attribute will not take effect until the " + "connection handler is disabled and re-enabled, or until " + "the Directory Server is restarted"); registerMessage(MSGID_JMX_CONNHANDLER_DESCRIPTION_ENABLE, "Specifies whether to enable the JMX connection " + "handler"); registerMessage(MSGID_JMX_CONNHANDLER_NO_LISTEN_PORT, "No listen port was defined using configuration " + ATTR_LISTEN_PORT + " in configuration entry %s. This is " + opends/src/server/org/opends/server/tools/ConfigureDS.java
@@ -638,6 +638,11 @@ true, false, true, true, 1, true, 65535, jmxPort.getIntValue()); configEntry.putConfigAttribute(portAttr); msgID = MSGID_JMX_CONNHANDLER_DESCRIPTION_ENABLE; BooleanConfigAttribute enablePortAttr = new BooleanConfigAttribute(ATTR_CONNECTION_HANDLER_ENABLED, getMessage(msgID), true, true, true); configEntry.putConfigAttribute(enablePortAttr); } catch (Exception e) { opends/src/server/org/opends/server/tools/InstallDS.java
@@ -559,6 +559,9 @@ } else { /* Do not ask for the JMX port if the user did not provide it.*/ jmxPortNumber = -1; /* while (true) { int msgID = MSGID_INSTALLDS_PROMPT_JMXPORT; @@ -594,6 +597,7 @@ } } } */ } @@ -841,8 +845,11 @@ argList.add(configFileName); argList.add("-p"); argList.add(String.valueOf(ldapPortNumber)); argList.add("-x"); argList.add(String.valueOf(jmxPortNumber)); if (jmxPortNumber != -1) { argList.add("-x"); argList.add(String.valueOf(jmxPortNumber)); } for (DN dn : baseDNs) { opends/tests/unit-tests-testng/src/server/org/opends/server/protocols/jmx/JmxConnectTest.java
@@ -57,14 +57,21 @@ import org.opends.server.core.AddOperation; import org.opends.server.core.DeleteOperation; import org.opends.server.core.DirectoryServer; import org.opends.server.core.ModifyOperation; import org.opends.server.protocols.internal.InternalClientConnection; import org.opends.server.types.ConfigChangeResult; import org.opends.server.types.Control; import org.opends.server.types.Control; import org.opends.server.types.DN; import org.opends.server.types.Entry; import org.opends.server.types.Modification; import org.opends.server.types.ModificationType; import org.opends.server.types.ResultCode; import org.testng.annotations.BeforeClass; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; import static org.opends.server.config.ConfigConstants.ATTR_LISTEN_PORT; import static org.testng.Assert.*; @@ -420,9 +427,9 @@ /** * @param config * @throws ConfigException * @throws Exception */ private void configureJmx(Entry entry) throws ConfigException { private void configureJmx(Entry entry) throws Exception { ArrayList<String> reasons = new ArrayList<String>(); // Get the Jmx connection handler from the core server @@ -448,8 +455,9 @@ /** * Get a reference to the JMX connection handler. * @throws an Exception is something went wrong. */ private JmxConnectionHandler getJmxConnectionHandler() { private JmxConnectionHandler getJmxConnectionHandler() throws Exception { List<ConnectionHandler> handlers = DirectoryServer .getConnectionHandlers(); assertNotNull(handlers); @@ -460,6 +468,20 @@ break; } } if (jmxConnectionHandler == null) { enableJmx(); synchronized (this) { this.wait(500); } for (ConnectionHandler handler : handlers) { if (handler instanceof JmxConnectionHandler) { jmxConnectionHandler = (JmxConnectionHandler) handler; break; } } } return jmxConnectionHandler; } @@ -627,4 +649,25 @@ mbsc.setAttribute(name, attr); } /** * Enable JMX with the port chosen in TestCaseUtils. * @throws Exception if the handler cannot be enabled. */ private void enableJmx() throws Exception { ArrayList<Modification> mods = new ArrayList<Modification>(); InternalClientConnection conn = InternalClientConnection.getRootConnection(); mods.add(new Modification(ModificationType.REPLACE, new org.opends.server.types.Attribute("ds-cfg-connection-handler-enabled", "true"))); ModifyOperation op = new ModifyOperation(conn, conn.nextOperationID(), conn.nextMessageID(), new ArrayList<Control>(), DN.decode( "cn=JMX Connection Handler,cn=Connection Handlers,cn=config"), mods); op.run(); } }