cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject [2/6] cassandra git commit: Allow service to startup if jmx remote port configured directly
Date Tue, 10 May 2016 14:07:51 GMT
Allow service to startup if jmx remote port configured directly

Patch by Sam Tunnicliffe; reviewed by Jake Luciani for CASSANDRA-11725


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/c17cbe18
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/c17cbe18
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/c17cbe18

Branch: refs/heads/cassandra-3.7
Commit: c17cbe1875a974a00822ffbfad716abde363c8da
Parents: 31cab36
Author: Sam Tunnicliffe <sam@beobal.com>
Authored: Mon May 9 19:23:33 2016 +0100
Committer: Sam Tunnicliffe <sam@beobal.com>
Committed: Tue May 10 14:57:25 2016 +0100

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 NEWS.txt                                        |  2 ++
 .../cassandra/service/CassandraDaemon.java      | 13 ++++++++++++
 .../apache/cassandra/service/StartupChecks.java | 21 ++++++++++++++++++--
 .../apache/cassandra/utils/JMXServerUtils.java  | 20 +++----------------
 5 files changed, 38 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/c17cbe18/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index b7715ba..1690e09 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 3.6
+ * Allow server startup if JMX is configured directly (CASSANDRA-11725)
  * Prevent direct memory OOM on buffer pool allocations (CASSANDRA-11710)
  * Enhanced Compaction Logging (CASSANDRA-10805)
  * Make prepared statement cache size configurable (CASSANDRA-11555)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/c17cbe18/NEWS.txt
----------------------------------------------------------------------
diff --git a/NEWS.txt b/NEWS.txt
index 7a29924..ac33a60 100644
--- a/NEWS.txt
+++ b/NEWS.txt
@@ -25,6 +25,8 @@ New features
      connections are permitted. For more details on how to enable the new options, see the
      comments in cassandra-env.sh. A new class of IResource, JMXResource, is provided for
      the purposes of GRANT/REVOKE via CQL. See CASSANDRA-10091 for more details.
+     Also, directly setting JMX remote port via the com.sun.management.jmxremote.port system
+     property at startup is deprecated. See CASSANDRA-11725 for more details.
    - JSON timestamps are now in UTC and contain the timezone information, see CASSANDRA-11137
for more details.
    - Collision checks are performed when joining the token ring, regardless of whether
      the node should bootstrap. Additionally, replace_address can legitimately be used

http://git-wip-us.apache.org/repos/asf/cassandra/blob/c17cbe18/src/java/org/apache/cassandra/service/CassandraDaemon.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/CassandraDaemon.java b/src/java/org/apache/cassandra/service/CassandraDaemon.java
index 2b797fe..2bf4931 100644
--- a/src/java/org/apache/cassandra/service/CassandraDaemon.java
+++ b/src/java/org/apache/cassandra/service/CassandraDaemon.java
@@ -97,6 +97,19 @@ public class CassandraDaemon
 
     private void maybeInitJmx()
     {
+        // If the standard com.sun.management.jmxremote.port property has been set
+        // then the JVM agent will have already started up a default JMX connector
+        // server. This behaviour is deprecated, but some clients may be relying
+        // on it, so log a warning and skip setting up the server with the settings
+        // as configured in cassandra-env.(sh|ps1)
+        // See: CASSANDRA-11540 & CASSANDRA-11725
+        if (System.getProperty("com.sun.management.jmxremote.port") != null)
+        {
+            logger.warn("JMX settings in cassandra-env.sh have been bypassed as the JMX connector
server is " +
+                        "already initialized. Please refer to cassandra-env.(sh|ps1) for
JMX configuration info");
+            return;
+        }
+
         System.setProperty("java.rmi.server.randomIDs", "true");
 
         // If a remote port has been specified then use that to set up a JMX

http://git-wip-us.apache.org/repos/asf/cassandra/blob/c17cbe18/src/java/org/apache/cassandra/service/StartupChecks.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/StartupChecks.java b/src/java/org/apache/cassandra/service/StartupChecks.java
index d1c1943..d837921 100644
--- a/src/java/org/apache/cassandra/service/StartupChecks.java
+++ b/src/java/org/apache/cassandra/service/StartupChecks.java
@@ -32,12 +32,16 @@ import org.slf4j.LoggerFactory;
 import org.apache.cassandra.config.CFMetaData;
 import org.apache.cassandra.config.DatabaseDescriptor;
 import org.apache.cassandra.config.Schema;
-import org.apache.cassandra.db.*;
+import org.apache.cassandra.db.ColumnFamilyStore;
+import org.apache.cassandra.db.Directories;
+import org.apache.cassandra.db.SystemKeyspace;
 import org.apache.cassandra.exceptions.ConfigurationException;
 import org.apache.cassandra.exceptions.StartupException;
 import org.apache.cassandra.io.sstable.Descriptor;
 import org.apache.cassandra.io.util.FileUtils;
-import org.apache.cassandra.utils.*;
+import org.apache.cassandra.utils.CLibrary;
+import org.apache.cassandra.utils.FBUtilities;
+import org.apache.cassandra.utils.SigarLibrary;
 
 /**
  * Verifies that the system and environment is in a fit state to be started.
@@ -71,6 +75,7 @@ public class StartupChecks
     private final List<StartupCheck> DEFAULT_TESTS = ImmutableList.of(checkJemalloc,
                                                                       checkValidLaunchDate,
                                                                       checkJMXPorts,
+                                                                      checkJMXProperties,
                                                                       inspectJvmOptions,
                                                                       checkJnaInitialization,
                                                                       initSigarLibrary,
@@ -160,6 +165,18 @@ public class StartupChecks
         }
     };
 
+    public static final StartupCheck checkJMXProperties = new StartupCheck()
+    {
+        public void execute()
+        {
+            if (System.getProperty("com.sun.management.jmxremote.port") != null)
+            {
+                logger.warn("Use of com.sun.management.jmxremote.port at startup is deprecated.
" +
+                            "Please use cassandra.jmx.remote.port instead.");
+            }
+        }
+    };
+
     public static final StartupCheck inspectJvmOptions = new StartupCheck()
     {
         public void execute()

http://git-wip-us.apache.org/repos/asf/cassandra/blob/c17cbe18/src/java/org/apache/cassandra/utils/JMXServerUtils.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/utils/JMXServerUtils.java b/src/java/org/apache/cassandra/utils/JMXServerUtils.java
index b0e44a2..ad87efd 100644
--- a/src/java/org/apache/cassandra/utils/JMXServerUtils.java
+++ b/src/java/org/apache/cassandra/utils/JMXServerUtils.java
@@ -66,31 +66,17 @@ public class JMXServerUtils
         Map<String, Object> env = new HashMap<>();
 
         String urlTemplate = "service:jmx:rmi://%1$s/jndi/rmi://%1$s:%2$d/jmxrmi";
-        String url;
-        String host;
-        InetAddress serverAddress;
+        InetAddress serverAddress = null;
         if (local)
         {
             serverAddress = InetAddress.getLoopbackAddress();
-            host = serverAddress.getHostAddress();
-            System.setProperty("java.rmi.server.hostname", host);
-        }
-        else
-        {
-            // if the java.rmi.server.hostname property is set, we'll take its value
-            // and use that when creating the RMIServerSocket to which we bind the RMI
-            // registry. This allows us to effectively restrict to a single interface
-            // if required. See http://bugs.java.com/bugdatabase/view_bug.do?bug_id=4880793
-            // for more detail. If the hostname property is not set, the registry will
-            // be bound to the wildcard address
-            host = System.getProperty("java.rmi.server.hostname");
-            serverAddress = host == null ? null : InetAddress.getByName(host);
+            System.setProperty("java.rmi.server.hostname", serverAddress.getHostAddress());
         }
 
         // Configure the RMI client & server socket factories, including SSL config.
         env.putAll(configureJmxSocketFactories(serverAddress));
 
-        url = String.format(urlTemplate, (host == null ? "0.0.0.0" : serverAddress.getHostAddress()),
port);
+        String url = String.format(urlTemplate, (serverAddress != null ? serverAddress.getHostAddress()
: "0.0.0.0"), port);
         LocateRegistry.createRegistry(port,
                                      (RMIClientSocketFactory) env.get(RMIConnectorServer.RMI_CLIENT_SOCKET_FACTORY_ATTRIBUTE),
                                      (RMIServerSocketFactory) env.get(RMIConnectorServer.RMI_SERVER_SOCKET_FACTORY_ATTRIBUTE));


Mime
View raw message