geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bschucha...@apache.org
Subject incubator-geode git commit: GEODE-841: ClientMembershipDUnitTest.testGetNotifiedClients failed
Date Fri, 05 Feb 2016 20:19:33 GMT
Repository: incubator-geode
Updated Branches:
  refs/heads/develop f3dd3353d -> c4591fa1c


GEODE-841: ClientMembershipDUnitTest.testGetNotifiedClients failed

This test threw an exception when it received a client identifier with a
numeric IP address instead of a host name.  On the servers these IDs are
deserialized and a canonical host name is picked up from SocketCreator,
but this is accessing a static cache of host names that may have been
initialized during a test that turned of DNS name lookup altogether in
order to avoid network delays and possible hangs.

The fix is to just clear the cache between tests.


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

Branch: refs/heads/develop
Commit: c4591fa1cabed90edf045d9e24e6f4100a84d4a6
Parents: f3dd335
Author: Bruce Schuchardt <bschuchardt@pivotal.io>
Authored: Fri Feb 5 12:18:07 2016 -0800
Committer: Bruce Schuchardt <bschuchardt@pivotal.io>
Committed: Fri Feb 5 12:19:17 2016 -0800

----------------------------------------------------------------------
 .../distributed/internal/LonerDistributionManager.java    |  4 ++--
 .../internal/membership/InternalDistributedMember.java    |  2 +-
 .../java/com/gemstone/gemfire/internal/SocketCreator.java | 10 +++++++++-
 .../gemfire/internal/i18n/ParentLocalizedStrings.java     |  2 +-
 .../gemfire/cache30/ClientMembershipDUnitTest.java        |  9 ++++++++-
 .../gemstone/gemfire/internal/AvailablePortJUnitTest.java |  1 +
 .../gemstone/gemfire/test/dunit/DistributedTestCase.java  |  3 +--
 7 files changed, 23 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c4591fa1/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/LonerDistributionManager.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/LonerDistributionManager.java
b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/LonerDistributionManager.java
index b55fe88..419c096 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/LonerDistributionManager.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/LonerDistributionManager.java
@@ -842,10 +842,10 @@ public class LonerDistributionManager implements DM {
    * @param newPort the new port to use
    */
   public void updateLonerPort(int newPort) {
-    this.logger.config(LocalizedStrings.LonerDistributionmanager_CHANGING_PORT_FROM_TO,
-        new Object[]{this.lonerPort, newPort});
     this.lonerPort = newPort;
     this.getId().setPort(this.lonerPort);
+    this.logger.config(LocalizedStrings.LonerDistributionmanager_CHANGING_PORT_FROM_TO,
+        new Object[]{this.lonerPort, newPort, getId()});
   }
   public boolean isCurrentMember(InternalDistributedMember p_id) {
     return getId().equals(p_id);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c4591fa1/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/InternalDistributedMember.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/InternalDistributedMember.java
b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/InternalDistributedMember.java
index 46c2eb3..8b5c279 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/InternalDistributedMember.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/InternalDistributedMember.java
@@ -784,7 +784,7 @@ public final class InternalDistributedMember
         sb.append(vmStr);
         sb.append(")");
       }
-      if (netMbr.preferredForCoordinator()) {
+      if (vmKind != DistributionManager.LONER_DM_TYPE && netMbr.preferredForCoordinator())
{
         sb.append("<ec>");
       }
       if (this.vmViewId >= 0) {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c4591fa1/gemfire-core/src/main/java/com/gemstone/gemfire/internal/SocketCreator.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/SocketCreator.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/SocketCreator.java
index 3ee22c1..9a74abd 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/SocketCreator.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/SocketCreator.java
@@ -133,7 +133,7 @@ public class SocketCreator {
   private static boolean useIPv6Addresses = !Boolean.getBoolean("java.net.preferIPv4Stack")
&&
   		Boolean.getBoolean("java.net.preferIPv6Addresses");
   
-  private static final Map hostNames = new HashMap();
+  private static final Map<InetAddress, String> hostNames = new HashMap<>();
   
   /** flag to force always using DNS (regardless of the fact that these lookups can hang)
*/
   public static final boolean FORCE_DNS_USE = Boolean.getBoolean("gemfire.forceDnsUse");
@@ -376,6 +376,14 @@ public class SocketCreator {
     }
     return result;
   }
+  
+  /**
+   * Reset the hostNames caches
+   */
+  public static synchronized void resetHostNameCache() {
+    hostNames.clear();
+  }
+  
   // -------------------------------------------------------------------------
   //   Initializers (change SocketCreator state)
   // -------------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c4591fa1/gemfire-core/src/main/java/com/gemstone/gemfire/internal/i18n/ParentLocalizedStrings.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/i18n/ParentLocalizedStrings.java
b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/i18n/ParentLocalizedStrings.java
index c0ef60d..248353f 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/i18n/ParentLocalizedStrings.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/i18n/ParentLocalizedStrings.java
@@ -1020,7 +1020,7 @@ class ParentLocalizedStrings {
   public static final StringId SystemAdmin_MONITOR_OPTION_HELP = new StringId(2005, "-monitor
Causes the stats command to keep periodically checking its statistic archives for updates.");
 
   public static final StringId CacheFactory_0_EXISTING_CACHE_WITH_DIFFERENT_CACHE_CONFIG
=  new StringId(2006, "Existing cache has different cache configuration, it has:\n{0}");
-  public static final StringId LonerDistributionmanager_CHANGING_PORT_FROM_TO = new StringId(2007,
"Updating membership port.  Port changed from {0} to {1}.");
+  public static final StringId LonerDistributionmanager_CHANGING_PORT_FROM_TO = new StringId(2007,
"Updating membership port.  Port changed from {0} to {1}.  ID is now {2}");
   public static final StringId ManagerLogWriter_ROLLING_CURRENT_LOG_TO_0 = new StringId(2008,
"Rolling current log to {0}");
   
   public static final StringId ExecuteFunction66_TRANSACTIONAL_FUNCTION_WITHOUT_RESULT =
new StringId(2009, " Function invoked within transactional context, but hasResults() is false;
ordering of transactional operations cannot be guaranteed.  This message is only issued once
by a server.");

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c4591fa1/gemfire-core/src/test/java/com/gemstone/gemfire/cache30/ClientMembershipDUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/cache30/ClientMembershipDUnitTest.java
b/gemfire-core/src/test/java/com/gemstone/gemfire/cache30/ClientMembershipDUnitTest.java
old mode 100644
new mode 100755
index 5589453..9251a56
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/cache30/ClientMembershipDUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/cache30/ClientMembershipDUnitTest.java
@@ -45,6 +45,7 @@ import com.gemstone.gemfire.distributed.DistributedMember;
 import com.gemstone.gemfire.distributed.DurableClientAttributes;
 import com.gemstone.gemfire.distributed.internal.DistributionConfig;
 import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem;
+import com.gemstone.gemfire.internal.SocketCreator;
 import com.gemstone.gemfire.internal.cache.tier.InternalClientMembership;
 import com.gemstone.gemfire.internal.cache.tier.sockets.AcceptorImpl;
 import com.gemstone.gemfire.internal.cache.tier.sockets.ServerConnection;
@@ -80,7 +81,6 @@ public class ClientMembershipDUnitTest extends ClientServerTestCase {
 
   public void setUp() throws Exception {
     super.setUp();
-    getSystem();
   }
   
   public void tearDown2() throws Exception {
@@ -225,6 +225,7 @@ public class ClientMembershipDUnitTest extends ClientServerTestCase {
   }
 
   public void testSynchronousEvents() throws Exception {
+    getSystem();
     InternalClientMembership.setForceSynchronous(true);
     try {
       doTestBasicEvents();
@@ -238,6 +239,7 @@ public class ClientMembershipDUnitTest extends ClientServerTestCase {
    * Tests event notification methods on ClientMembership.
    */
   public void testBasicEvents() throws Exception {
+    getSystem();
     doTestBasicEvents();
   }
   
@@ -419,6 +421,8 @@ public class ClientMembershipDUnitTest extends ClientServerTestCase {
     final String[] memberId = new String[1];
     final boolean[] isClient = new boolean[1];
     
+    getSystem();
+
     ClientMembershipListener listener = new ClientMembershipListener() {
       public synchronized void memberJoined(ClientMembershipEvent event) {
         fired[0] = true;
@@ -471,6 +475,8 @@ public class ClientMembershipDUnitTest extends ClientServerTestCase {
     final String[] memberId = new String[NUM_LISTENERS];
     final boolean[] isClient = new boolean[NUM_LISTENERS];
     
+    getSystem();
+
     final ClientMembershipListener[] listeners = new ClientMembershipListener[NUM_LISTENERS];
     for (int i = 0; i < NUM_LISTENERS; i++) {
       final int whichListener = i;
@@ -727,6 +733,7 @@ public class ClientMembershipDUnitTest extends ClientServerTestCase {
    * crashes or departs gracefully, the client will detect this as a crash.
    */
   public void testClientMembershipEventsInClient() throws Exception {
+    getSystem();
     addExpectedException("IOException");
     final boolean[] fired = new boolean[3];
     final DistributedMember[] member = new DistributedMember[3];

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c4591fa1/gemfire-core/src/test/java/com/gemstone/gemfire/internal/AvailablePortJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/AvailablePortJUnitTest.java
b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/AvailablePortJUnitTest.java
index 6ba91b8..103e465 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/AvailablePortJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/AvailablePortJUnitTest.java
@@ -67,6 +67,7 @@ public class AvailablePortJUnitTest {
     socket = new ServerSocket();
     int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
     socket.bind(new InetSocketAddress((InetAddress)null, port));
+    System.out.println("bind addr="+System.getProperty("gemfire.bind-address"));
     assertFalse(AvailablePort.isPortAvailable(port, AvailablePort.SOCKET));
   }
   

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c4591fa1/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/DistributedTestCase.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/DistributedTestCase.java
b/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/DistributedTestCase.java
index d238dcd..2bf013d 100755
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/DistributedTestCase.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/test/dunit/DistributedTestCase.java
@@ -755,6 +755,7 @@ public abstract class DistributedTestCase extends TestCase implements
java.io.Se
     closeCache();
     
     SocketCreator.resolve_dns = true;
+    SocketCreator.resetHostNameCache();
     CacheCreation.clearThreadLocals();
     System.getProperties().remove("gemfire.log-level");
     System.getProperties().remove("jgroups.resolve_dns");
@@ -774,8 +775,6 @@ public abstract class DistributedTestCase extends TestCase implements
java.io.Se
     DistributionMessageObserver.setInstance(null);
     QueryObserverHolder.reset();
     DiskStoreObserver.setInstance(null);
-    System.getProperties().remove("gemfire.log-level");
-    System.getProperties().remove("jgroups.resolve_dns");
     
     if (InternalDistributedSystem.systemAttemptingReconnect != null) {
       InternalDistributedSystem.systemAttemptingReconnect.stopReconnecting();


Mime
View raw message