geode-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (GEODE-3151) Configuration Parameter Based Registration Of internal Region over JMX
Date Wed, 06 Dec 2017 11:43:01 GMT

    [ https://issues.apache.org/jira/browse/GEODE-3151?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16280066#comment-16280066
] 

ASF GitHub Bot commented on GEODE-3151:
---------------------------------------

dineshpune2006 closed pull request #613: GEODE-3151: Internal Region Registration in JMX as
per config parameter
URL: https://github.com/apache/geode/pull/613
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

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 63f6505101..566fe88d0e 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
@@ -1534,6 +1534,17 @@
    * <U>Default</U>: ""
    */
   String SERVER_BIND_ADDRESS = "server-bind-address";
+
+  /**
+   * The static String definition of the <i>"jmx-bean-input-names"</i> property
<a
+   * name="jmx-bean-input-names"/a>
+   * <p>
+   * <U>Description</U>: Names of the internal region which are going to be register
over the jmx.
+   * <p>
+   * <U>Default</U>: ""
+   */
+  String JMX_BEAN_INPUT_NAMES = "jmx-bean-input-names";
+
   /**
    * The static String definition of the <i>"ssl-server-alias"</i> property <a
    * name="ssl-server-alias"/a>
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 795f6a5a4a..dec16d8399 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
@@ -16,7 +16,20 @@
 
 import static org.apache.geode.distributed.ConfigurationProperties.*;
 
+import java.lang.reflect.Method;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.StringTokenizer;
+
 import org.apache.commons.lang.StringUtils;
+
 import org.apache.geode.InternalGemFireException;
 import org.apache.geode.InvalidValueException;
 import org.apache.geode.UnmodifiableException;
@@ -32,18 +45,6 @@
 import org.apache.geode.memcached.GemFireMemcachedServer;
 import org.apache.logging.log4j.Logger;
 
-import java.lang.reflect.Method;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.StringTokenizer;
-
 /**
  * Provides an implementation of <code>DistributionConfig</code> that knows how
to read the
  * configuration file.
@@ -245,7 +246,7 @@ protected String checkLocators(String value) {
     while (st.hasMoreTokens()) {
       String locator = st.nextToken();
       StringBuffer locatorsb = new StringBuffer(); // string for this locator is accumulated
in this
-                                                   // buffer
+      // buffer
 
       int portIndex = locator.indexOf('[');
       if (portIndex < 1) {
@@ -851,6 +852,8 @@ public static Class _getAttributeType(String attName) {
         LocalizedStrings.AbstractDistributionConfig_SERVER_BIND_ADDRESS_NAME_0
             .toLocalizedString(DEFAULT_BIND_ADDRESS));
 
+    m.put(JMX_BEAN_INPUT_NAMES,
+        LocalizedStrings.AbstractDistributionConfig_JMX_INPUT_BEAN_NAMES_0.toLocalizedString(""));
     m.put(NAME,
         "A name that uniquely identifies a member in its distributed system."
             + " Multiple members in the same distributed system can not have the same name."
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 c2a395de0b..68d86cf256 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
@@ -17,16 +17,6 @@
 
 import static org.apache.geode.distributed.ConfigurationProperties.*;
 
-import org.apache.geode.distributed.ConfigurationProperties;
-import org.apache.geode.distributed.DistributedSystem;
-import org.apache.geode.internal.Config;
-import org.apache.geode.internal.ConfigSource;
-import org.apache.geode.internal.logging.InternalLogWriter;
-import org.apache.geode.internal.logging.LogConfig;
-import org.apache.geode.internal.security.SecurableCommunicationChannel;
-import org.apache.geode.internal.tcp.Connection;
-import org.apache.geode.memcached.GemFireMemcachedServer;
-
 import java.io.File;
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;
@@ -38,6 +28,16 @@
 import java.util.Map;
 import java.util.Properties;
 
+import org.apache.geode.distributed.ConfigurationProperties;
+import org.apache.geode.distributed.DistributedSystem;
+import org.apache.geode.internal.Config;
+import org.apache.geode.internal.ConfigSource;
+import org.apache.geode.internal.logging.InternalLogWriter;
+import org.apache.geode.internal.logging.LogConfig;
+import org.apache.geode.internal.security.SecurableCommunicationChannel;
+import org.apache.geode.internal.tcp.Connection;
+import org.apache.geode.memcached.GemFireMemcachedServer;
+
 /**
  * Provides accessor (and in some cases mutator) methods for the various GemFire distribution
  * configuration properties. The interface also provides constants for the names of properties
and
@@ -284,6 +284,33 @@
    */
   String DEFAULT_SERVER_BIND_ADDRESS = "";
 
+  /**
+   * The default value of the {@link ConfigurationProperties#JMX_BEAN_INPUT_NAMES} property.
Current
+   * value is an empty string <code>""</code>
+   */
+  String DEFAULT_JMX_BEAN_INPUT_NAMES = "";
+
+
+  /**
+   * get the value of the {@link ConfigurationProperties#JMX_BEAN_INPUT_NAMES} property
+   */
+
+  @ConfigAttributeGetter(name = JMX_BEAN_INPUT_NAMES)
+  String getBeanInputList();
+
+  /**
+   * Sets the value of the {@link ConfigurationProperties#JMX_BEAN_INPUT_NAMES} property
+   */
+  @ConfigAttributeSetter(name = JMX_BEAN_INPUT_NAMES)
+  void setBeanInputList(String value);
+
+  /**
+   * The name of the {@link ConfigurationProperties#JMX_BEAN_INPUT_NAMES} property
+   */
+  @ConfigAttribute(type = String.class)
+  String JMX_BEAN__INPUT_NAME = JMX_BEAN_INPUT_NAMES;
+
+
   /**
    * Returns the value of the {@link ConfigurationProperties#LOCATORS} property
    */
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 fbe894c964..795caed040 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
@@ -15,7 +15,55 @@
 
 package org.apache.geode.distributed.internal;
 
-import static org.apache.geode.distributed.ConfigurationProperties.*;
+import static org.apache.geode.distributed.ConfigurationProperties.CLUSTER_SSL_CIPHERS;
+import static org.apache.geode.distributed.ConfigurationProperties.CLUSTER_SSL_ENABLED;
+import static org.apache.geode.distributed.ConfigurationProperties.CLUSTER_SSL_KEYSTORE;
+import static org.apache.geode.distributed.ConfigurationProperties.CLUSTER_SSL_KEYSTORE_PASSWORD;
+import static org.apache.geode.distributed.ConfigurationProperties.CLUSTER_SSL_KEYSTORE_TYPE;
+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.CLUSTER_SSL_TRUSTSTORE;
+import static org.apache.geode.distributed.ConfigurationProperties.CLUSTER_SSL_TRUSTSTORE_PASSWORD;
+import static org.apache.geode.distributed.ConfigurationProperties.GATEWAY_SSL_CIPHERS;
+import static org.apache.geode.distributed.ConfigurationProperties.GATEWAY_SSL_ENABLED;
+import static org.apache.geode.distributed.ConfigurationProperties.GATEWAY_SSL_KEYSTORE;
+import static org.apache.geode.distributed.ConfigurationProperties.GATEWAY_SSL_KEYSTORE_PASSWORD;
+import static org.apache.geode.distributed.ConfigurationProperties.GATEWAY_SSL_KEYSTORE_TYPE;
+import static org.apache.geode.distributed.ConfigurationProperties.GATEWAY_SSL_PROTOCOLS;
+import static org.apache.geode.distributed.ConfigurationProperties.GATEWAY_SSL_REQUIRE_AUTHENTICATION;
+import static org.apache.geode.distributed.ConfigurationProperties.GATEWAY_SSL_TRUSTSTORE;
+import static org.apache.geode.distributed.ConfigurationProperties.GATEWAY_SSL_TRUSTSTORE_PASSWORD;
+import static org.apache.geode.distributed.ConfigurationProperties.HTTP_SERVICE_SSL_CIPHERS;
+import static org.apache.geode.distributed.ConfigurationProperties.HTTP_SERVICE_SSL_ENABLED;
+import static org.apache.geode.distributed.ConfigurationProperties.HTTP_SERVICE_SSL_KEYSTORE;
+import static org.apache.geode.distributed.ConfigurationProperties.HTTP_SERVICE_SSL_KEYSTORE_PASSWORD;
+import static org.apache.geode.distributed.ConfigurationProperties.HTTP_SERVICE_SSL_KEYSTORE_TYPE;
+import static org.apache.geode.distributed.ConfigurationProperties.HTTP_SERVICE_SSL_PROTOCOLS;
+import static org.apache.geode.distributed.ConfigurationProperties.HTTP_SERVICE_SSL_REQUIRE_AUTHENTICATION;
+import static org.apache.geode.distributed.ConfigurationProperties.HTTP_SERVICE_SSL_TRUSTSTORE;
+import static org.apache.geode.distributed.ConfigurationProperties.HTTP_SERVICE_SSL_TRUSTSTORE_PASSWORD;
+import static org.apache.geode.distributed.ConfigurationProperties.JMX_MANAGER_SSL_CIPHERS;
+import static org.apache.geode.distributed.ConfigurationProperties.JMX_MANAGER_SSL_ENABLED;
+import static org.apache.geode.distributed.ConfigurationProperties.JMX_MANAGER_SSL_KEYSTORE;
+import static org.apache.geode.distributed.ConfigurationProperties.JMX_MANAGER_SSL_KEYSTORE_PASSWORD;
+import static org.apache.geode.distributed.ConfigurationProperties.JMX_MANAGER_SSL_KEYSTORE_TYPE;
+import static org.apache.geode.distributed.ConfigurationProperties.JMX_MANAGER_SSL_PROTOCOLS;
+import static org.apache.geode.distributed.ConfigurationProperties.JMX_MANAGER_SSL_REQUIRE_AUTHENTICATION;
+import static org.apache.geode.distributed.ConfigurationProperties.JMX_MANAGER_SSL_TRUSTSTORE;
+import static org.apache.geode.distributed.ConfigurationProperties.JMX_MANAGER_SSL_TRUSTSTORE_PASSWORD;
+import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_PEER_AUTHENTICATOR;
+import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_PEER_AUTH_INIT;
+import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_UDP_DHALGO;
+import static org.apache.geode.distributed.ConfigurationProperties.SERVER_SSL_CIPHERS;
+import static org.apache.geode.distributed.ConfigurationProperties.SERVER_SSL_ENABLED;
+import static org.apache.geode.distributed.ConfigurationProperties.SERVER_SSL_KEYSTORE;
+import static org.apache.geode.distributed.ConfigurationProperties.SERVER_SSL_KEYSTORE_PASSWORD;
+import static org.apache.geode.distributed.ConfigurationProperties.SERVER_SSL_KEYSTORE_TYPE;
+import static org.apache.geode.distributed.ConfigurationProperties.SERVER_SSL_PROTOCOLS;
+import static org.apache.geode.distributed.ConfigurationProperties.SERVER_SSL_REQUIRE_AUTHENTICATION;
+import static org.apache.geode.distributed.ConfigurationProperties.SERVER_SSL_TRUSTSTORE;
+import static org.apache.geode.distributed.ConfigurationProperties.SERVER_SSL_TRUSTSTORE_PASSWORD;
+import static org.apache.geode.distributed.ConfigurationProperties.SSL_ENABLED_COMPONENTS;
 
 import java.io.File;
 import java.io.IOException;
@@ -32,11 +80,9 @@
 import java.util.Properties;
 import java.util.Set;
 
-import org.apache.commons.lang.ArrayUtils;
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.lang.builder.EqualsBuilder;
 import org.apache.commons.lang.builder.HashCodeBuilder;
-import org.apache.geode.redis.GeodeRedisServer;
 
 import org.apache.geode.GemFireConfigException;
 import org.apache.geode.GemFireIOException;
@@ -49,6 +95,7 @@
 import org.apache.geode.internal.process.ProcessLauncherContext;
 import org.apache.geode.internal.security.SecurableCommunicationChannel;
 import org.apache.geode.memcached.GemFireMemcachedServer;
+import org.apache.geode.redis.GeodeRedisServer;
 
 /**
  * Provides an implementation of <code>DistributionConfig</code> that knows how
to read the
@@ -110,6 +157,13 @@
    */
   private String serverBindAddress = DEFAULT_SERVER_BIND_ADDRESS;
 
+
+  /**
+   * names of the internal region, which are going to be register over the jmx
+   */
+
+  private String jmxBeanInputParameters = DEFAULT_JMX_BEAN_INPUT_NAMES;
+
   /**
    * The locations of the distribution locators
    */
@@ -610,6 +664,7 @@ public DistributionConfigImpl(DistributionConfig other) {
     this.mcastAddress = other.getMcastAddress();
     this.bindAddress = other.getBindAddress();
     this.serverBindAddress = other.getServerBindAddress();
+    this.jmxBeanInputParameters = other.getBeanInputList();
     this.locators = ((DistributionConfigImpl) other).locators;
     this.locatorWaitTime = other.getLocatorWaitTime();
     this.remoteLocators = other.getRemoteLocators();
@@ -1658,10 +1713,21 @@ public InetAddress getMcastAddress() {
     }
   }
 
+  public String getBeanInputList() {
+    return this.jmxBeanInputParameters;
+  }
+
   public String getBindAddress() {
     return this.bindAddress;
   }
 
+  public void setBeanInputList(String value) {
+    if (value == null) {
+      value = "";
+    }
+    this.jmxBeanInputParameters = (String) value;
+  }
+
   public String getServerBindAddress() {
     return this.serverBindAddress;
   }
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalDistributedSystem.java
b/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalDistributedSystem.java
index 6aa602fc8f..86fbe9f593 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalDistributedSystem.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalDistributedSystem.java
@@ -82,6 +82,7 @@
 import org.apache.geode.internal.cache.EventID;
 import org.apache.geode.internal.cache.GemFireCacheImpl;
 import org.apache.geode.internal.cache.InternalCache;
+import org.apache.geode.internal.cache.LocalRegion;
 import org.apache.geode.internal.cache.execute.FunctionServiceStats;
 import org.apache.geode.internal.cache.execute.FunctionStats;
 import org.apache.geode.internal.cache.tier.sockets.HandShake;
@@ -113,29 +114,6 @@
 import org.apache.geode.security.GemFireSecurityException;
 import org.apache.geode.security.PostProcessor;
 import org.apache.geode.security.SecurityManager;
-import org.apache.logging.log4j.Logger;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.Reader;
-import java.lang.reflect.Array;
-import java.net.InetAddress;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Properties;
-import java.util.Set;
-import java.util.SortedSet;
-import java.util.StringTokenizer;
-import java.util.TreeSet;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.CopyOnWriteArrayList;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicLong;
-import java.util.concurrent.atomic.AtomicReference;
 
 /**
  * The concrete implementation of {@link DistributedSystem} that provides internal-only
@@ -525,7 +503,7 @@ private InternalDistributedSystem(Properties nonDefault) {
     }
 
     ((DistributionConfigImpl) this.originalConfig).checkForDisallowedDefaults(); // throws
-                                                                                 // IllegalStateEx
+    // IllegalStateEx
     this.shareSockets = this.originalConfig.getConserveSockets();
     this.startTime = System.currentTimeMillis();
     this.grc = new GrantorRequestProcessor.GrantorRequestContext(stopper);
@@ -838,13 +816,13 @@ private void startInitLocator() throws InterruptedException {
     try {
       this.startedLocator =
           InternalLocator.createLocator(locId.getPort(), null, null, this.logWriter, // LOG:
this is
-                                                                                     // after
IDS
-                                                                                     // has
created
-                                                                                     // LogWriterLoggers
-                                                                                     // and
-                                                                                     // Appenders
+              // after IDS
+              // has created
+              // LogWriterLoggers
+              // and
+              // Appenders
               this.securityLogWriter, // LOG: this is after IDS has created LogWriterLoggers
and
-                                      // Appenders
+
               locId.getHost().getAddress(), locId.getHostnameForClients(),
               this.originalConfig.toProperties(), false);
 
@@ -1362,7 +1340,7 @@ protected void disconnect(boolean preparingForReconnect, String reason,
boolean
           InternalCache currentCache = GemFireCacheImpl.getInstance();
           if (currentCache != null && !currentCache.isClosed()) {
             disconnectListenerThread.set(Boolean.TRUE); // bug #42663 - this must be set
while
-                                                        // closing the cache
+            // closing the cache
             try {
               currentCache.close(reason, dm.getRootCause(), keepAlive, true); // fix for
42150
             } catch (VirtualMachineError e) {
@@ -1474,7 +1452,7 @@ protected void disconnect(boolean preparingForReconnect, String reason,
boolean
       // NOTE: no logging after this point :-)
 
       LoggingThreadGroup.cleanUpThreadGroups(); // bug35388 - logwriters accumulate, causing
mem
-                                                // leak
+      // leak
       EventID.unsetDS();
 
     } finally {
@@ -2530,7 +2508,7 @@ public boolean tryReconnect(boolean forcedDisconnect, String reason,
InternalCac
       return false;
     }
     synchronized (CacheFactory.class) { // bug #51335 - deadlock with app thread trying to
create a
-                                        // cache
+      // cache
       synchronized (GemFireCacheImpl.class) {
         // bug 39329: must lock reconnectLock *after* the cache
         synchronized (this.reconnectLock) {
@@ -3081,6 +3059,15 @@ public void stopReconnecting() {
     this.attemptingToReconnect = false;
   }
 
+  public Boolean isFoundInJmxBeanInputList(LocalRegion localRegion) {
+    Boolean isRegionFoundInExceptionList = false;
+    if (this.getConfig().getBeanInputList() != "") {
+      isRegionFoundInExceptionList =
+          this.getConfig().getBeanInputList().contains(localRegion.getName());
+    }
+    return isRegionFoundInExceptionList;
+  }
+
   /**
    * Provides hook for dunit to generate and store a detailed creation stack trace that includes
the
    * keys/values of DistributionConfig including security related attributes without introducing
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 2dda38c70b..d7445e5b92 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
@@ -77,7 +77,6 @@
 import com.sun.jna.Native;
 import com.sun.jna.Platform;
 import org.apache.commons.lang.StringUtils;
-import org.apache.geode.internal.security.SecurityServiceFactory;
 import org.apache.logging.log4j.Logger;
 
 import org.apache.geode.CancelCriterion;
@@ -213,6 +212,7 @@
 import org.apache.geode.internal.offheap.MemoryAllocator;
 import org.apache.geode.internal.process.ClusterConfigurationNotAvailableException;
 import org.apache.geode.internal.security.SecurityService;
+import org.apache.geode.internal.security.SecurityServiceFactory;
 import org.apache.geode.internal.sequencelog.SequenceLoggerImpl;
 import org.apache.geode.internal.tcp.ConnectionTable;
 import org.apache.geode.internal.util.concurrent.FutureResult;
@@ -3125,8 +3125,12 @@ public Pool determineDefaultPool(PoolFactory poolFactory) {
 
     invokeRegionAfter(region);
 
+    Boolean isRegionFoundInExceptionList = false;
+    isRegionFoundInExceptionList = this.system.isFoundInJmxBeanInputList(region);
+
+
     // Added for M&M . Putting the callback here to avoid creating RegionMBean in case
of Exception
-    if (!region.isInternalRegion()) {
+    if (!region.isInternalRegion() || isRegionFoundInExceptionList) {
       this.system.handleResourceEvent(ResourceEvent.REGION_CREATE, region);
     }
 
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/LocalRegion.java b/geode-core/src/main/java/org/apache/geode/internal/cache/LocalRegion.java
index 3b3047ff00..91f39b7cf3 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/LocalRegion.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/LocalRegion.java
@@ -17,6 +17,45 @@
 import static org.apache.geode.internal.lang.SystemUtils.getLineSeparator;
 import static org.apache.geode.internal.offheap.annotations.OffHeapIdentifier.ENTRY_EVENT_NEW_VALUE;
 
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.AbstractSet;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.EnumSet;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.NoSuchElementException;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+import java.util.concurrent.RejectedExecutionException;
+import java.util.concurrent.Semaphore;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.transaction.RollbackException;
+import javax.transaction.Status;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+
+import org.apache.logging.log4j.Logger;
+
 import org.apache.geode.CancelCriterion;
 import org.apache.geode.CancelException;
 import org.apache.geode.CopyHelper;
@@ -179,44 +218,6 @@
 import org.apache.geode.internal.util.concurrent.StoppableReadWriteLock;
 import org.apache.geode.pdx.JSONFormatter;
 import org.apache.geode.pdx.PdxInstance;
-import org.apache.logging.log4j.Logger;
-
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.AbstractSet;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.EnumSet;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.NoSuchElementException;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
-import java.util.concurrent.RejectedExecutionException;
-import java.util.concurrent.Semaphore;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReentrantLock;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import javax.transaction.RollbackException;
-import javax.transaction.Status;
-import javax.transaction.SystemException;
-import javax.transaction.Transaction;
 
 /**
  * Implementation of a local scoped-region. Note that this class has a different meaning
starting
@@ -710,7 +711,7 @@ Object getSizeGuard() {
       return new Object();
     } else {
       return this.fullPath; // avoids creating another sync object - could be anything unique
to
-                            // this region
+      // this region
     }
   }
 
@@ -1052,7 +1053,7 @@ private void validatedCreate(EntryEventImpl event, long startPut)
         false, // ifOld
         null, // expectedOldValue
         true // requireOldValue TODO txMerge why is oldValue required for
-             // create? I think so that the EntryExistsException will have it.
+    // create? I think so that the EntryExistsException will have it.
     )) {
       throw new EntryExistsException(event.getKey().toString(), event.getOldValue());
     } else {
@@ -2624,8 +2625,12 @@ private void recursiveDestroyRegion(Set eventSet, RegionEventImpl regionEvent,
b
 
         try {
           region.recursiveDestroyRegion(eventSet, regionEvent, cacheWrite);
-          if (!region.isInternalRegion()) {
-            InternalDistributedSystem system = region.cache.getInternalDistributedSystem();
+
+          Boolean isRegionFoundInExceptionList = false;
+          InternalDistributedSystem system = region.cache.getInternalDistributedSystem();
+          isRegionFoundInExceptionList = system.isFoundInJmxBeanInputList(region);
+
+          if (!region.isInternalRegion() || isRegionFoundInExceptionList) {
             system.handleResourceEvent(ResourceEvent.REGION_REMOVE, region);
           }
         } catch (CancelException e) {
@@ -6302,8 +6307,10 @@ void basicDestroyRegion(RegionEventImpl event, boolean cacheWrite,
boolean lock,
 
           // Added for M&M : At this point we can safely call ResourceEvent to remove
the region
           // artifacts From Management Layer
-          if (!isInternalRegion()) {
-            InternalDistributedSystem system = this.cache.getInternalDistributedSystem();
+          Boolean isRegionFoundInExceptionList = false;
+          InternalDistributedSystem system = this.cache.getInternalDistributedSystem();
+          isRegionFoundInExceptionList = system.isFoundInJmxBeanInputList(this);
+          if (!isInternalRegion() || isRegionFoundInExceptionList) {
             system.handleResourceEvent(ResourceEvent.REGION_REMOVE, this);
           }
 
diff --git a/geode-core/src/main/java/org/apache/geode/internal/i18n/LocalizedStrings.java
b/geode-core/src/main/java/org/apache/geode/internal/i18n/LocalizedStrings.java
index baad039bf9..c62696ee1d 100755
--- a/geode-core/src/main/java/org/apache/geode/internal/i18n/LocalizedStrings.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/i18n/LocalizedStrings.java
@@ -7697,6 +7697,9 @@
   public static final StringId LuceneServiceImpl_REGION_0_CANNOT_BE_DESTROYED = new StringId(6660,
       "Region {0} cannot be destroyed because it defines Lucene index(es) [{1}]. Destroy
all Lucene indexes before destroying the region.");
 
+  public static final StringId AbstractDistributionConfig_JMX_INPUT_BEAN_NAMES_0 =
+      new StringId(6651, "Names of the Beans or  internal region names. Defaults to \"{0}\".");
+
   /** Testing strings, messageId 90000-99999 **/
 
   /**
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 525f988cd3..cca006de20 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
@@ -21,6 +21,7 @@
 import static org.apache.geode.distributed.ConfigurationProperties.ENABLE_CLUSTER_CONFIGURATION;
 import static org.apache.geode.distributed.ConfigurationProperties.HTTP_SERVICE_PORT;
 import static org.apache.geode.distributed.ConfigurationProperties.HTTP_SERVICE_SSL_ENABLED;
+import static org.apache.geode.distributed.ConfigurationProperties.JMX_BEAN_INPUT_NAMES;
 import static org.apache.geode.distributed.ConfigurationProperties.JMX_MANAGER_HTTP_PORT;
 import static org.apache.geode.distributed.ConfigurationProperties.LOG_DISK_SPACE_LIMIT;
 import static org.apache.geode.distributed.ConfigurationProperties.LOG_FILE_SIZE_LIMIT;
@@ -38,21 +39,10 @@
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.any;
+import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
-import org.apache.geode.InternalGemFireException;
-import org.apache.geode.UnmodifiableException;
-import org.apache.geode.internal.ConfigSource;
-import org.apache.geode.security.TestPostProcessor;
-import org.apache.geode.security.TestSecurityManager;
-import org.apache.geode.test.junit.categories.MembershipTest;
-import org.apache.geode.test.junit.categories.UnitTest;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
 import java.io.File;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
@@ -62,6 +52,18 @@
 import java.util.Map;
 import java.util.Properties;
 
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import org.apache.geode.InternalGemFireException;
+import org.apache.geode.UnmodifiableException;
+import org.apache.geode.internal.ConfigSource;
+import org.apache.geode.security.TestPostProcessor;
+import org.apache.geode.security.TestSecurityManager;
+import org.apache.geode.test.junit.categories.MembershipTest;
+import org.apache.geode.test.junit.categories.UnitTest;
+
 @Category({UnitTest.class, MembershipTest.class})
 public class DistributionConfigJUnitTest {
 
@@ -99,7 +101,7 @@ public void before() {
   @Test
   public void testGetAttributeNames() {
     String[] attNames = AbstractDistributionConfig._getAttNames();
-    assertEquals(attNames.length, 156);
+    assertEquals(attNames.length, 157);
 
     List boolList = new ArrayList();
     List intList = new ArrayList();
@@ -135,7 +137,7 @@ public void testGetAttributeNames() {
     // are.
     assertEquals(29, boolList.size());
     assertEquals(33, intList.size());
-    assertEquals(85, stringList.size());
+    assertEquals(86, stringList.size());
     assertEquals(5, fileList.size());
     assertEquals(4, otherList.size());
   }
@@ -390,6 +392,14 @@ public void testSecurityPropsWithNoSetter() {
     assertEquals(config.getSecurityProps().size(), 4);
   }
 
+  @Test
+  public void TestGetJmxBeanInputList() {
+    Properties props = new Properties();
+    props.put(JMX_BEAN_INPUT_NAMES, "REGION_1");
+    DistributionConfig config = new DistributionConfigImpl(props);
+    assertEquals(config.getBeanInputList(), "REGION_1");
+  }
+
   @Test
   public void testSSLEnabledComponents() {
     Properties props = new Properties();
diff --git a/geode-core/src/test/java/org/apache/geode/distributed/internal/InternalDistributedSystemJUnitTest.java
b/geode-core/src/test/java/org/apache/geode/distributed/internal/InternalDistributedSystemJUnitTest.java
index 5a191bbd93..8c22059fe5 100644
--- a/geode-core/src/test/java/org/apache/geode/distributed/internal/InternalDistributedSystemJUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/distributed/internal/InternalDistributedSystemJUnitTest.java
@@ -14,8 +14,32 @@
  */
 package org.apache.geode.distributed.internal;
 
-import static org.apache.geode.distributed.ConfigurationProperties.*;
-import static org.junit.Assert.*;
+import static org.apache.geode.distributed.ConfigurationProperties.ARCHIVE_DISK_SPACE_LIMIT;
+import static org.apache.geode.distributed.ConfigurationProperties.ARCHIVE_FILE_SIZE_LIMIT;
+import static org.apache.geode.distributed.ConfigurationProperties.CACHE_XML_FILE;
+import static org.apache.geode.distributed.ConfigurationProperties.CLUSTER_SSL_ENABLED;
+import static org.apache.geode.distributed.ConfigurationProperties.GATEWAY_SSL_ENABLED;
+import static org.apache.geode.distributed.ConfigurationProperties.GROUPS;
+import static org.apache.geode.distributed.ConfigurationProperties.HTTP_SERVICE_SSL_ENABLED;
+import static org.apache.geode.distributed.ConfigurationProperties.JMX_MANAGER_SSL_ENABLED;
+import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS;
+import static org.apache.geode.distributed.ConfigurationProperties.LOG_DISK_SPACE_LIMIT;
+import static org.apache.geode.distributed.ConfigurationProperties.LOG_FILE_SIZE_LIMIT;
+import static org.apache.geode.distributed.ConfigurationProperties.LOG_LEVEL;
+import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
+import static org.apache.geode.distributed.ConfigurationProperties.MEMBERSHIP_PORT_RANGE;
+import static org.apache.geode.distributed.ConfigurationProperties.MEMBER_TIMEOUT;
+import static org.apache.geode.distributed.ConfigurationProperties.NAME;
+import static org.apache.geode.distributed.ConfigurationProperties.SERVER_SSL_ENABLED;
+import static org.apache.geode.distributed.ConfigurationProperties.SSL_ENABLED_COMPONENTS;
+import static org.apache.geode.distributed.ConfigurationProperties.START_LOCATOR;
+import static org.apache.geode.distributed.ConfigurationProperties.STATISTIC_ARCHIVE_FILE;
+import static org.apache.geode.distributed.ConfigurationProperties.STATISTIC_SAMPLE_RATE;
+import static org.apache.geode.distributed.ConfigurationProperties.STATISTIC_SAMPLING_ENABLED;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
 
 import java.io.File;
 import java.io.FileWriter;
@@ -30,24 +54,30 @@
 import java.util.Properties;
 import java.util.logging.Level;
 
-import org.apache.geode.test.junit.categories.MembershipTest;
 import org.junit.After;
 import org.junit.Assert;
-import org.junit.Ignore;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 import org.junit.rules.ExpectedException;
 
+import org.apache.geode.cache.Cache;
+import org.apache.geode.cache.CacheFactory;
+import org.apache.geode.cache.Region;
+import org.apache.geode.cache.RegionFactory;
+import org.apache.geode.cache.RegionShortcut;
 import org.apache.geode.distributed.DistributedSystem;
 import org.apache.geode.distributed.DistributedSystemDisconnectedException;
 import org.apache.geode.distributed.Locator;
 import org.apache.geode.internal.AvailablePort;
 import org.apache.geode.internal.Config;
 import org.apache.geode.internal.ConfigSource;
+import org.apache.geode.internal.cache.GemFireCacheImpl;
+import org.apache.geode.internal.cache.LocalRegion;
 import org.apache.geode.internal.i18n.LocalizedStrings;
 import org.apache.geode.internal.logging.InternalLogWriter;
 import org.apache.geode.test.junit.categories.IntegrationTest;
+import org.apache.geode.test.junit.categories.MembershipTest;
 
 /**
  * Tests the functionality of the {@link InternalDistributedSystem} class. Mostly checks
@@ -62,6 +92,8 @@
    * A connection to a distributed system created by this test
    */
   private InternalDistributedSystem system;
+  private Cache cache;
+  private Region region;
 
   /**
    * Creates a <code>DistributedSystem</code> with the given configuration properties.
@@ -72,6 +104,20 @@ protected InternalDistributedSystem createSystem(Properties props) {
     return this.system;
   }
 
+
+  public void initCache() {
+
+    try {
+      cache = CacheFactory.getAnyInstance();
+    } catch (Exception e) {
+      // ignore
+    }
+    if (null == cache) {
+      cache = (GemFireCacheImpl) new CacheFactory().set(MCAST_PORT, "0").create();
+    }
+
+  }
+
   /**
    * Disconnects any distributed system that was created by this test
    * 
@@ -82,6 +128,10 @@ public void tearDown() throws Exception {
     if (this.system != null) {
       this.system.disconnect();
     }
+    if (cache != null && !cache.isClosed()) {
+      cache.close();
+      cache = null;
+    }
   }
 
   //////// Test methods
@@ -159,6 +209,8 @@ public void testDefaultProperties() {
 
     assertEquals(DistributionConfig.DEFAULT_ENABLE_NETWORK_PARTITION_DETECTION,
         config.getEnableNetworkPartitionDetection());
+
+    assertEquals(DistributionConfig.DEFAULT_JMX_BEAN_INPUT_NAMES, config.getBeanInputList());
   }
 
   @Test
@@ -639,6 +691,42 @@ public void testValidateProps() {
     }
   }
 
+  @Test
+  public void testWhenisFoundInJmxBeanInputListReturnTrue() {
+    try {
+
+      initCache();
+      InternalDistributedSystem system = InternalDistributedSystem.getAnyInstance();
+      region = createRegion("REGION_1");
+      system.getConfig().setBeanInputList("REGION_1,REGION_2");
+      assertEquals(true, system.isFoundInJmxBeanInputList((LocalRegion) region));
+    } catch (IllegalArgumentException ex) {
+      // pass...
+    }
+
+  }
+
+  private Region createRegion(String name) {
+    RegionFactory rf;
+    rf = cache.createRegionFactory(RegionShortcut.PARTITION);
+    return rf.create(name);
+  }
+
+  @Test
+  public void testWhenisFoundInJmxBeanInputListReturnFalse() {
+    try {
+
+      initCache();
+      InternalDistributedSystem system = InternalDistributedSystem.getAnyInstance();
+      system.getConfig().setBeanInputList("REGION_1,REGION_2");
+      region = createRegion("REGION_3");
+      assertEquals(false, system.isFoundInJmxBeanInputList((LocalRegion) region));
+    } catch (IllegalArgumentException ex) {
+      // pass...
+    }
+
+  }
+
   @Test
   public void testDeprecatedSSLProps() {
     Properties props = getCommonProperties();


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> Configuration Parameter Based Registration Of internal Region over JMX
> ----------------------------------------------------------------------
>
>                 Key: GEODE-3151
>                 URL: https://issues.apache.org/jira/browse/GEODE-3151
>             Project: Geode
>          Issue Type: New Feature
>          Components: general
>            Reporter: dinesh akhand
>
> I am Adding the Configuration parameter which will have the internal region name/function
name
> which we want to register in JMX.
> currently for Internal Region Bean is not getting registered in  JMX.
> I want to make this as configurable.
> If user provided internal region names in configuration[property file ] then
> bean should get register in JMX.
> Current use: we want to register the async queue associated internal region in JMX.
> future scope: using same parameter we want to register few functions to JMX.
> output : only defined internal regions in property file are going to be show in JMX.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


Mime
View raw message