You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by kl...@apache.org on 2019/01/18 23:13:22 UTC
[geode] branch develop updated: GEODE-6294: Add disable-jmx config
property
This is an automated email from the ASF dual-hosted git repository.
klund pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git
The following commit(s) were added to refs/heads/develop by this push:
new 86099f9 GEODE-6294: Add disable-jmx config property
86099f9 is described below
commit 86099f921ef08696016a886d8abe9d3b5ee97eb5
Author: Kirk Lund <kl...@apache.org>
AuthorDate: Thu Jan 17 17:15:56 2019 -0800
GEODE-6294: Add disable-jmx config property
---
.../management/DisableJmxIntegrationTest.java | 73 ++++++++++++++++++++++
.../geode/admin/DistributedSystemConfig.java | 14 +++++
.../internal/DistributedSystemConfigImpl.java | 17 +++++
.../internal/AdminDistributedSystemJmxImpl.java | 10 +++
.../geode/distributed/ConfigurationProperties.java | 12 ++++
.../internal/AbstractDistributionConfig.java | 5 ++
.../distributed/internal/DistributionConfig.java | 24 +++++++
.../internal/DistributionConfigImpl.java | 19 +++++-
.../geode/internal/cache/GemFireCacheImpl.java | 15 +++--
.../internal/DistributionConfigJUnitTest.java | 4 +-
10 files changed, 185 insertions(+), 8 deletions(-)
diff --git a/geode-core/src/integrationTest/java/org/apache/geode/management/DisableJmxIntegrationTest.java b/geode-core/src/integrationTest/java/org/apache/geode/management/DisableJmxIntegrationTest.java
new file mode 100644
index 0000000..4c9efe6
--- /dev/null
+++ b/geode-core/src/integrationTest/java/org/apache/geode/management/DisableJmxIntegrationTest.java
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.geode.management;
+
+import static org.apache.geode.distributed.ConfigurationProperties.DISABLE_JMX;
+import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS;
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.util.List;
+import java.util.Properties;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import org.apache.geode.cache.CacheFactory;
+import org.apache.geode.distributed.ConfigurationProperties;
+import org.apache.geode.distributed.internal.InternalDistributedSystem;
+import org.apache.geode.distributed.internal.ResourceEventsListener;
+import org.apache.geode.internal.cache.InternalCache;
+
+/**
+ * Integration test to ensure that Geode does not create MBeans when
+ * {@link ConfigurationProperties#DISABLE_JMX} is set to true.
+ */
+public class DisableJmxIntegrationTest {
+
+ private InternalCache cache;
+
+ @Before
+ public void setUp() {
+ Properties config = new Properties();
+ config.setProperty(DISABLE_JMX, "true");
+ config.setProperty(LOCATORS, "");
+
+ cache = (InternalCache) new CacheFactory(config).create();
+ }
+
+ @After
+ public void tearDown() {
+ cache.close();
+ }
+
+ @Test
+ public void disableJmxPreventsRegistrationOfManagementListener() {
+ InternalDistributedSystem system = cache.getInternalDistributedSystem();
+
+ List<ResourceEventsListener> result = system.getResourceListeners();
+
+ assertThat(result).isEmpty();
+ }
+
+ @Test
+ public void disableJmxPreventsCreationOfMemberMXBean() {
+ ManagementService managementService = ManagementService.getManagementService(cache);
+
+ MemberMXBean result = managementService.getMemberMXBean();
+
+ assertThat(result).isNull();
+ }
+}
diff --git a/geode-core/src/main/java/org/apache/geode/admin/DistributedSystemConfig.java b/geode-core/src/main/java/org/apache/geode/admin/DistributedSystemConfig.java
index 340185f..3dc9c3e 100755
--- a/geode-core/src/main/java/org/apache/geode/admin/DistributedSystemConfig.java
+++ b/geode-core/src/main/java/org/apache/geode/admin/DistributedSystemConfig.java
@@ -197,6 +197,9 @@ public interface DistributedSystemConfig extends Cloneable {
/** The default disable-tcp value (<code>false</code>) */
boolean DEFAULT_DISABLE_TCP = DistributionConfig.DEFAULT_DISABLE_TCP;
+ /** The default disable-jmx value (<code>false</code>) */
+ boolean DEFAULT_DISABLE_JMX = DistributionConfig.DEFAULT_DISABLE_JMX;
+
/** The default enable-network-partition-detection setting (<code>false</code>) */
boolean DEFAULT_ENABLE_NETWORK_PARTITION_DETECTION =
DistributionConfig.DEFAULT_ENABLE_NETWORK_PARTITION_DETECTION;
@@ -367,6 +370,17 @@ public interface DistributedSystemConfig extends Cloneable {
*/
boolean getDisableTcp();
+ /**
+ * Sets the disable-jmx property for the system. When JMX is disabled, Geode will not create
+ * MBeans.
+ */
+ void setDisableJmx(boolean flag);
+
+ /**
+ * Returns the disable-jmx property for the process. When JMX is disabled, Geode will not create
+ * MBeans.
+ */
+ boolean getDisableJmx();
/**
* Turns on network partition detection
diff --git a/geode-core/src/main/java/org/apache/geode/admin/internal/DistributedSystemConfigImpl.java b/geode-core/src/main/java/org/apache/geode/admin/internal/DistributedSystemConfigImpl.java
index aab6df5..c6a4d4e 100755
--- a/geode-core/src/main/java/org/apache/geode/admin/internal/DistributedSystemConfigImpl.java
+++ b/geode-core/src/main/java/org/apache/geode/admin/internal/DistributedSystemConfigImpl.java
@@ -20,6 +20,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.CLUSTER_SSL_E
import static org.apache.geode.distributed.ConfigurationProperties.CLUSTER_SSL_PROTOCOLS;
import static org.apache.geode.distributed.ConfigurationProperties.CLUSTER_SSL_REQUIRE_AUTHENTICATION;
import static org.apache.geode.distributed.ConfigurationProperties.DISABLE_AUTO_RECONNECT;
+import static org.apache.geode.distributed.ConfigurationProperties.DISABLE_JMX;
import static org.apache.geode.distributed.ConfigurationProperties.DISABLE_TCP;
import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS;
import static org.apache.geode.distributed.ConfigurationProperties.MCAST_ADDRESS;
@@ -79,6 +80,7 @@ public class DistributedSystemConfigImpl implements DistributedSystemConfig {
private String serverBindAddress = DEFAULT_BIND_ADDRESS;
private String remoteCommand = DEFAULT_REMOTE_COMMAND;
private boolean disableTcp = DEFAULT_DISABLE_TCP;
+ private boolean disableJmx = DEFAULT_DISABLE_JMX;
private boolean enableNetworkPartitionDetection = DEFAULT_ENABLE_NETWORK_PARTITION_DETECTION;
private boolean disableAutoReconnect = DEFAULT_DISABLE_AUTO_RECONNECT;
private int memberTimeout = DEFAULT_MEMBER_TIMEOUT;
@@ -635,6 +637,18 @@ public class DistributedSystemConfigImpl implements DistributedSystemConfig {
}
@Override
+ public boolean getDisableJmx() {
+ return disableJmx;
+ }
+
+ @Override
+ public void setDisableJmx(boolean flag) {
+ checkReadOnly();
+ disableJmx = flag;
+ configChanged();
+ }
+
+ @Override
public void setEnableNetworkPartitionDetection(boolean newValue) {
checkReadOnly();
this.enableNetworkPartitionDetection = newValue;
@@ -1198,6 +1212,9 @@ public class DistributedSystemConfigImpl implements DistributedSystemConfig {
buf.append(" " + DISABLE_TCP + "=");
buf.append(String.valueOf(this.disableTcp));
buf.append(lf);
+ buf.append(" " + DISABLE_JMX + "=");
+ buf.append(disableJmx);
+ buf.append(lf);
buf.append(" " + DISABLE_AUTO_RECONNECT + "=");
buf.append(String.valueOf(this.disableAutoReconnect));
buf.append(lf);
diff --git a/geode-core/src/main/java/org/apache/geode/admin/jmx/internal/AdminDistributedSystemJmxImpl.java b/geode-core/src/main/java/org/apache/geode/admin/jmx/internal/AdminDistributedSystemJmxImpl.java
index a8a14bb..5a9a52f 100755
--- a/geode-core/src/main/java/org/apache/geode/admin/jmx/internal/AdminDistributedSystemJmxImpl.java
+++ b/geode-core/src/main/java/org/apache/geode/admin/jmx/internal/AdminDistributedSystemJmxImpl.java
@@ -1118,6 +1118,11 @@ public class AdminDistributedSystemJmxImpl extends AdminDistributedSystemImpl
}
@Override
+ public boolean getDisableJmx() {
+ return getConfig().getDisableJmx();
+ }
+
+ @Override
public void setEnableNetworkPartitionDetection(boolean newValue) {
getConfig().setEnableNetworkPartitionDetection(newValue);
}
@@ -1328,6 +1333,11 @@ public class AdminDistributedSystemJmxImpl extends AdminDistributedSystemImpl
}
@Override
+ public void setDisableJmx(boolean flag) {
+ getConfig().setDisableJmx(flag);
+ }
+
+ @Override
public int getRefreshInterval() {
return this.getConfig().getRefreshInterval();
}
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/ConfigurationProperties.java b/geode-core/src/main/java/org/apache/geode/distributed/ConfigurationProperties.java
index 7581f7a..94a555f 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/ConfigurationProperties.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/ConfigurationProperties.java
@@ -392,6 +392,18 @@ public interface ConfigurationProperties {
*/
String DISABLE_TCP = "disable-tcp";
/**
+ * The static String definition of the <i>"disable-jmx"</i> property <a name="disable-tcp"/a>
+ * <p>
+ * <U>Description</U>: Turns off use of JMX, preventing the process from creating Geode MBeans.
+ * <p>
+ * <U>Default</U>: "false"
+ * <p>
+ * <U>Allowed values</U>: true or false
+ * <p>
+ * <U>Since</U>: Geode 1.9
+ */
+ String DISABLE_JMX = "disable-jmx";
+ /**
* The static String definition of the <i>"distributed-system-id"</i> property
* <p>
* <a name="distributed-system-id"/a> <U>Decription:</U>A number that uniquely identifies this
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/AbstractDistributionConfig.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/AbstractDistributionConfig.java
index 3de9c16..384ed42 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/AbstractDistributionConfig.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/AbstractDistributionConfig.java
@@ -38,6 +38,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.CONSERVE_SOCK
import static org.apache.geode.distributed.ConfigurationProperties.DELTA_PROPAGATION;
import static org.apache.geode.distributed.ConfigurationProperties.DEPLOY_WORKING_DIR;
import static org.apache.geode.distributed.ConfigurationProperties.DISABLE_AUTO_RECONNECT;
+import static org.apache.geode.distributed.ConfigurationProperties.DISABLE_JMX;
import static org.apache.geode.distributed.ConfigurationProperties.DISABLE_TCP;
import static org.apache.geode.distributed.ConfigurationProperties.DISTRIBUTED_SYSTEM_ID;
import static org.apache.geode.distributed.ConfigurationProperties.DISTRIBUTED_TRANSACTIONS;
@@ -927,6 +928,10 @@ public abstract class AbstractDistributionConfig extends AbstractConfig
"Determines whether TCP/IP communications will be disabled, forcing use of datagrams between members of the distributed system. Defaults to %s",
Boolean.FALSE));
+ m.put(DISABLE_JMX, String.format(
+ "Determines whether JMX will be disabled which prevents Geode from creating MBeans. Defaults to %s",
+ Boolean.FALSE));
+
m.put(ENABLE_TIME_STATISTICS,
"Turns on timings in distribution and cache statistics. These are normally turned off to avoid expensive clock probes.");
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/DistributionConfig.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/DistributionConfig.java
index c06f965..563a1d2 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/DistributionConfig.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/DistributionConfig.java
@@ -38,6 +38,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.CONSERVE_SOCK
import static org.apache.geode.distributed.ConfigurationProperties.DELTA_PROPAGATION;
import static org.apache.geode.distributed.ConfigurationProperties.DEPLOY_WORKING_DIR;
import static org.apache.geode.distributed.ConfigurationProperties.DISABLE_AUTO_RECONNECT;
+import static org.apache.geode.distributed.ConfigurationProperties.DISABLE_JMX;
import static org.apache.geode.distributed.ConfigurationProperties.DISABLE_TCP;
import static org.apache.geode.distributed.ConfigurationProperties.DISTRIBUTED_SYSTEM_ID;
import static org.apache.geode.distributed.ConfigurationProperties.DISTRIBUTED_TRANSACTIONS;
@@ -1629,6 +1630,29 @@ public interface DistributionConfig extends Config, LogConfig, StatisticsConfig
boolean DEFAULT_DISABLE_TCP = false;
/**
+ * Returns the value of the {@link ConfigurationProperties#DISABLE_JMX} property
+ */
+ @ConfigAttributeGetter(name = DISABLE_JMX)
+ boolean getDisableJmx();
+
+ /**
+ * Sets the value of the {@link ConfigurationProperties#DISABLE_JMX} property.
+ */
+ @ConfigAttributeSetter(name = DISABLE_JMX)
+ void setDisableJmx(boolean newValue);
+
+ /**
+ * The name of the {@link ConfigurationProperties#DISABLE_JMX} property
+ */
+ @ConfigAttribute(type = Boolean.class)
+ String DISABLE_JMX_NAME = DISABLE_JMX;
+
+ /**
+ * The default value of the {@link ConfigurationProperties#DISABLE_JMX} property
+ */
+ boolean DEFAULT_DISABLE_JMX = false;
+
+ /**
* Turns on timing statistics for the distributed system
*/
@ConfigAttributeSetter(name = ENABLE_TIME_STATISTICS)
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/DistributionConfigImpl.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/DistributionConfigImpl.java
index 6261371..79742a1 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/DistributionConfigImpl.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/DistributionConfigImpl.java
@@ -276,6 +276,11 @@ public class DistributionConfigImpl extends AbstractDistributionConfig implement
protected boolean disableTcp = DEFAULT_DISABLE_TCP;
/**
+ * whether JMX should be disabled
+ */
+ protected boolean disableJmx = DEFAULT_DISABLE_JMX;
+
+ /**
* whether time statistics should be enabled for the distributed system
*/
protected boolean enableTimeStatistics = DEFAULT_ENABLE_TIME_STATISTICS;
@@ -711,6 +716,7 @@ public class DistributionConfigImpl extends AbstractDistributionConfig implement
udpRecvBufferSize = other.getUdpRecvBufferSize();
udpFragmentSize = other.getUdpFragmentSize();
disableTcp = other.getDisableTcp();
+ disableJmx = other.getDisableJmx();
enableTimeStatistics = other.getEnableTimeStatistics();
memberTimeout = other.getMemberTimeout();
membershipPortRange = other.getMembershipPortRange();
@@ -2284,6 +2290,16 @@ public class DistributionConfigImpl extends AbstractDistributionConfig implement
}
@Override
+ public boolean getDisableJmx() {
+ return disableJmx;
+ }
+
+ @Override
+ public void setDisableJmx(boolean newValue) {
+ disableJmx = newValue;
+ }
+
+ @Override
public boolean getEnableTimeStatistics() {
return enableTimeStatistics;
}
@@ -3121,6 +3137,7 @@ public class DistributionConfigImpl extends AbstractDistributionConfig implement
.append(udpSendBufferSize, that.udpSendBufferSize)
.append(udpRecvBufferSize, that.udpRecvBufferSize)
.append(udpFragmentSize, that.udpFragmentSize).append(disableTcp, that.disableTcp)
+ .append(disableJmx, that.disableJmx)
.append(enableTimeStatistics, that.enableTimeStatistics)
.append(memberTimeout, that.memberTimeout)
.append(maxWaitTimeForReconnect, that.maxWaitTimeForReconnect)
@@ -3269,7 +3286,7 @@ public class DistributionConfigImpl extends AbstractDistributionConfig implement
.append(clusterSSLKeyStorePassword).append(clusterSSLTrustStore)
.append(clusterSSLTrustStorePassword).append(clusterSSLAlias).append(mcastSendBufferSize)
.append(mcastRecvBufferSize).append(mcastFlowControl).append(udpSendBufferSize)
- .append(udpRecvBufferSize).append(udpFragmentSize).append(disableTcp)
+ .append(udpRecvBufferSize).append(udpFragmentSize).append(disableTcp).append(disableJmx)
.append(enableTimeStatistics).append(memberTimeout).append(membershipPortRange)
.append(maxWaitTimeForReconnect).append(maxNumReconnectTries)
.append(asyncDistributionTimeout).append(asyncQueueTimeout).append(asyncMaxQueueSize)
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/GemFireCacheImpl.java b/geode-core/src/main/java/org/apache/geode/internal/cache/GemFireCacheImpl.java
index 150c87d..ba2501d 100755
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/GemFireCacheImpl.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/GemFireCacheImpl.java
@@ -875,11 +875,16 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
// We only support management on members of a distributed system
// Should do this: if (!getSystem().isLoner()) {
// but it causes quickstart.CqClientTest to hang
- this.resourceEventsListener = new ManagementListener(this.system);
- this.system.addResourceListener(this.resourceEventsListener);
- if (this.system.isLoner()) {
- this.system.getInternalLogWriter()
- .info("Running in local mode since no locators were specified.");
+ boolean disableJmx = system.getConfig().getDisableJmx();
+ if (disableJmx) {
+ logger.info("Running with JMX disabled.");
+ } else {
+ this.resourceEventsListener = new ManagementListener(this.system);
+ this.system.addResourceListener(this.resourceEventsListener);
+ if (this.system.isLoner()) {
+ this.system.getInternalLogWriter()
+ .info("Running in local mode since no locators were specified.");
+ }
}
} else {
logger.info("Running in client mode");
diff --git a/geode-core/src/test/java/org/apache/geode/distributed/internal/DistributionConfigJUnitTest.java b/geode-core/src/test/java/org/apache/geode/distributed/internal/DistributionConfigJUnitTest.java
index 68d3ef2..470a6ea 100644
--- a/geode-core/src/test/java/org/apache/geode/distributed/internal/DistributionConfigJUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/distributed/internal/DistributionConfigJUnitTest.java
@@ -101,7 +101,7 @@ public class DistributionConfigJUnitTest {
@Test
public void testGetAttributeNames() {
String[] attNames = AbstractDistributionConfig._getAttNames();
- assertThat(attNames.length).isEqualTo(164);
+ assertThat(attNames.length).isEqualTo(165);
List boolList = new ArrayList();
List intList = new ArrayList();
@@ -135,7 +135,7 @@ public class DistributionConfigJUnitTest {
// TODO - This makes no sense. One has no idea what the correct expected number of attributes
// are.
- assertEquals(33, boolList.size());
+ assertEquals(34, boolList.size());
assertEquals(35, intList.size());
assertEquals(87, stringList.size());
assertEquals(5, fileList.size());