geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kl...@apache.org
Subject [17/44] incubator-geode git commit: GEODE-1037 CI failure: PdxClientServerDUnitTest.testNonPersistentServerRestart
Date Tue, 15 Mar 2016 00:24:00 GMT
GEODE-1037 CI failure: PdxClientServerDUnitTest.testNonPersistentServerRestart

Altered the test to make sure the client cache knows that the server has
shut down prior to restarting the server.  This ensures that the listener
is invoked and clears the PDX type registry.

This commit also includes some code clean-up in PDX and the client pool.


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

Branch: refs/heads/feature/GEODE-949-2
Commit: c394bf0f28fd626a3acad324ae5a507f86c7ea59
Parents: 445efdb
Author: Bruce Schuchardt <bschuchardt@pivotal.io>
Authored: Wed Mar 9 16:18:13 2016 -0800
Committer: Bruce Schuchardt <bschuchardt@pivotal.io>
Committed: Wed Mar 9 16:18:13 2016 -0800

----------------------------------------------------------------------
 .../gemfire/cache/client/internal/Endpoint.java |  2 +-
 .../internal/PdxRegistryRecoveryListener.java   |  6 +--
 .../gemfire/cache/client/internal/PoolImpl.java |  5 ++-
 .../internal/LonerDistributionManager.java      |  4 +-
 .../gemstone/gemfire/pdx/internal/PdxType.java  |  2 +-
 .../gemfire/pdx/PdxClientServerDUnitTest.java   | 46 +++++++++++++-------
 6 files changed, 42 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c394bf0f/geode-core/src/main/java/com/gemstone/gemfire/cache/client/internal/Endpoint.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/cache/client/internal/Endpoint.java
b/geode-core/src/main/java/com/gemstone/gemfire/cache/client/internal/Endpoint.java
index b4d5444..660998c 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/cache/client/internal/Endpoint.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/cache/client/internal/Endpoint.java
@@ -69,7 +69,7 @@ public class Endpoint {
   }
   
   public boolean isClosed() {
-    return closed == true;
+    return closed;
   }
 
   public ConnectionStats getStats() {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c394bf0f/geode-core/src/main/java/com/gemstone/gemfire/cache/client/internal/PdxRegistryRecoveryListener.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/cache/client/internal/PdxRegistryRecoveryListener.java
b/geode-core/src/main/java/com/gemstone/gemfire/cache/client/internal/PdxRegistryRecoveryListener.java
index 7417573..85e0317 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/cache/client/internal/PdxRegistryRecoveryListener.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/cache/client/internal/PdxRegistryRecoveryListener.java
@@ -74,14 +74,14 @@ public class PdxRegistryRecoveryListener extends EndpointManager.EndpointListene
     if (logger.isDebugEnabled()) {
       logger.debug("PdxRegistryRecoveryListener - EndpointNowInUse. Now have {} endpoints",
count);
     }
-    if(count == 1) {
+    if (count == 1) {
       GemFireCacheImpl cache = GemFireCacheImpl.getInstance();
-      if(cache == null) {
+      if (cache == null) {
         return;
       }
       TypeRegistry registry = cache.getPdxRegistry();
       
-      if(registry == null) {
+      if (registry == null) {
         return;
       }
       registry.clear();

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c394bf0f/geode-core/src/main/java/com/gemstone/gemfire/cache/client/internal/PoolImpl.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/cache/client/internal/PoolImpl.java
b/geode-core/src/main/java/com/gemstone/gemfire/cache/client/internal/PoolImpl.java
index 8aa5ce2..ccfdd6d 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/cache/client/internal/PoolImpl.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/cache/client/internal/PoolImpl.java
@@ -79,6 +79,8 @@ import com.gemstone.gemfire.internal.logging.log4j.LocalizedMessage;
  * @since 5.7
  */
 public class PoolImpl implements InternalPool {
+  public static final String ON_DISCONNECT_CLEAR_PDXTYPEIDS = "gemfire.ON_DISCONNECT_CLEAR_PDXTYPEIDS";
+
   private static final Logger logger = LogService.getLogger();
   
   public static final int HANDSHAKE_TIMEOUT = Long.getLong("gemfire.PoolImpl.HANDSHAKE_TIMEOUT",
AcceptorImpl.DEFAULT_HANDSHAKE_TIMEOUT_MS).intValue();
@@ -320,8 +322,9 @@ public class PoolImpl implements InternalPool {
     connectionFactory.start(backgroundProcessor);
     endpointManager.addListener(new InstantiatorRecoveryListener(backgroundProcessor, this));
     endpointManager.addListener(new DataSerializerRecoveryListener(backgroundProcessor, this));
-    if(Boolean.getBoolean("gemfire.ON_DISCONNECT_CLEAR_PDXTYPEIDS"))
+    if (Boolean.getBoolean(ON_DISCONNECT_CLEAR_PDXTYPEIDS)) {
       endpointManager.addListener(new PdxRegistryRecoveryListener(this));
+    }
     endpointManager.addListener(new LiveServerPinger(this));
     
     manager.start(backgroundProcessor);

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

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c394bf0f/geode-core/src/main/java/com/gemstone/gemfire/pdx/internal/PdxType.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/pdx/internal/PdxType.java b/geode-core/src/main/java/com/gemstone/gemfire/pdx/internal/PdxType.java
index 36f4cc1..00d87de 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/pdx/internal/PdxType.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/pdx/internal/PdxType.java
@@ -347,7 +347,7 @@ public class PdxType implements DataSerializable {
   public String toFormattedString() {
     StringBuffer sb = new StringBuffer("PdxType[\n    ");
     sb.append("dsid=").append(getDSId());
-    sb.append("typenum=").append(getTypeNum());
+    sb.append(", typenum=").append(getTypeNum());
     sb.append(", name=").append(this.className);
     sb.append(", fields=[");
     for (PdxField vft : fields) {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c394bf0f/geode-core/src/test/java/com/gemstone/gemfire/pdx/PdxClientServerDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/pdx/PdxClientServerDUnitTest.java
b/geode-core/src/test/java/com/gemstone/gemfire/pdx/PdxClientServerDUnitTest.java
index 7720890..3e34236 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/pdx/PdxClientServerDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/pdx/PdxClientServerDUnitTest.java
@@ -32,6 +32,7 @@ import com.gemstone.gemfire.cache.client.ClientCacheFactory;
 import com.gemstone.gemfire.cache.client.ClientRegionShortcut;
 import com.gemstone.gemfire.cache.client.PoolFactory;
 import com.gemstone.gemfire.cache.client.PoolManager;
+import com.gemstone.gemfire.cache.client.internal.PoolImpl;
 import com.gemstone.gemfire.cache.query.internal.DefaultQuery;
 import com.gemstone.gemfire.cache.server.CacheServer;
 import com.gemstone.gemfire.cache30.CacheTestCase;
@@ -92,8 +93,9 @@ public class PdxClientServerDUnitTest extends CacheTestCase {
   }
   
   /**
-   * Test of bug 47338 - what happens to the client type
-   * registry if the server is restarted.
+   * Test what happens to the client type
+   * registry if the server is restarted and PDX serialization
+   * for a class has changed.  This was reported in Pivotal bug #47338
    */
   public void testNonPersistentServerRestart() {
     Host host = Host.getHost(0);
@@ -115,6 +117,22 @@ public class PdxClientServerDUnitTest extends CacheTestCase {
     });
     
     closeCache(vm0);
+    
+    // GEODE-1037: make sure the client knows that the server
+    // is gone
+    vm1.invoke(new SerializableRunnable() {
+      public void run() throws Exception {
+        Region r = getRootRegion("testSimplePdx");
+        // make sure the client has reconnected to the server
+        // by performing a get() on a key the client cache does
+        // not contain
+        try {
+          r.get(4);
+          throw new Error("expected an exception to be thrown");
+        } catch(Exception expected) { }
+      }
+    });
+    
     createServerRegion(vm0, port);
     createClientRegion(vm2, port, false, true);
     
@@ -129,17 +147,15 @@ public class PdxClientServerDUnitTest extends CacheTestCase {
       }
     });
     
-    //See what happens when vm1 tries to read the type.
-    //If it cached the type id it will have problems.
+    // See what happens when vm1 tries to read the type.
+    // If it cached the type id it will try to read a PdxType2
+    // and fail with a ServerOperationException having a
+    // PdxSerializationException "cause" 
     vm1.invoke(new SerializableCallable() {
       public Object call() throws Exception {
         Region r = getRootRegion("testSimplePdx");
-        try {
-          r.get(4);
-        } catch(Exception expected) {
-          //The client may not have noticed the server go away and come
-          //back. Let's trigger the exception so the client will retry.
-        }
+
+        // now get object 3, which was put in the server by vm2
         PdxType1 results = (PdxType1) r.get(3);
         assertEquals(3, results.int1);
         
@@ -700,18 +716,18 @@ public class PdxClientServerDUnitTest extends CacheTestCase {
       final String ... autoSerializerPatterns) {
     SerializableCallable createRegion = new SerializableCallable() {
       public Object call() throws Exception {
-	    if(setPdxTypeClearProp) {
-		  System.setProperty("gemfire.ON_DISCONNECT_CLEAR_PDXTYPEIDS", "true");	
-		}
+        if (setPdxTypeClearProp) {
+          System.setProperty(PoolImpl.ON_DISCONNECT_CLEAR_PDXTYPEIDS, "true");	
+        }
         ClientCacheFactory cf = new ClientCacheFactory();
         cf.addPoolServer(NetworkUtils.getServerHostName(vm.getHost()), port);
         cf.setPoolThreadLocalConnections(threadLocalConnections);
-        if(autoSerializerPatterns != null && autoSerializerPatterns.length != 0)
{
+        if (autoSerializerPatterns != null && autoSerializerPatterns.length != 0)
{
           cf.setPdxSerializer(new ReflectionBasedAutoSerializer(autoSerializerPatterns));
         }
         ClientCache cache = getClientCache(cf);
         cache.createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY)
-        .create("testSimplePdx");
+          .create("testSimplePdx");
         return null;
       }
     };


Mime
View raw message