From 7d4b74cc0aebaaf815b0a265439f1fa7b98bf99b Mon Sep 17 00:00:00 2001 From: zhouxh Date: Wed, 30 Jan 2019 16:13:51 -0800 Subject: [PATCH] GEODE-6344: should revert GEODE-1183 before a better fix GEODE-6344: fix CacheClientNotifierDUnitTest to remove the 2nd cacheserver --- .../tier/sockets/CacheClientNotifier.java | 36 ++++++++----------- .../wan/CacheClientNotifierDUnitTest.java | 26 ++++++++------ .../wan/Simple2CacheServerDUnitTest.java | 2 ++ 3 files changed, 32 insertions(+), 32 deletions(-) diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/CacheClientNotifier.java b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/CacheClientNotifier.java index b6997eb615d0..86181d3a9786 100755 --- a/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/CacheClientNotifier.java +++ b/geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/CacheClientNotifier.java @@ -512,33 +512,25 @@ private CacheClientProxy registerClient(Socket socket, ClientProxyMembershipID p } } else { CacheClientProxy staleClientProxy = this.getClientProxy(proxyId); - boolean toCreateNewProxy = true; if (staleClientProxy != null) { - if (staleClientProxy.isConnected() && staleClientProxy.getSocket().isConnected()) { - successful = false; - toCreateNewProxy = false; + // A proxy exists for this non-durable client. It must be closed. + if (logger.isDebugEnabled()) { + logger.debug( + "CacheClientNotifier: A proxy exists for this non-durable client. It must be closed."); + } + if (staleClientProxy.startRemoval()) { + staleClientProxy.waitRemoval(); } else { - // A proxy exists for this non-durable client. It must be closed. - if (logger.isDebugEnabled()) { - logger.debug( - "CacheClientNotifier: A proxy exists for this non-durable client. It must be closed."); - } - if (staleClientProxy.startRemoval()) { - staleClientProxy.waitRemoval(); - } else { - staleClientProxy.close(false, false); // do not check for queue, just close it - removeClientProxy(staleClientProxy); // remove old proxy from proxy set - } + staleClientProxy.close(false, false); // do not check for queue, just close it + removeClientProxy(staleClientProxy); // remove old proxy from proxy set } } // non-null stale proxy - if (toCreateNewProxy) { - // Create the new proxy for this non-durable client - l_proxy = - new CacheClientProxy(this, socket, proxyId, isPrimary, clientConflation, clientVersion, - acceptorId, notifyBySubscription, this.cache.getSecurityService(), subject); - successful = this.initializeProxy(l_proxy); - } + // Create the new proxy for this non-durable client + l_proxy = + new CacheClientProxy(this, socket, proxyId, isPrimary, clientConflation, clientVersion, + acceptorId, notifyBySubscription, this.cache.getSecurityService(), subject); + successful = this.initializeProxy(l_proxy); } if (!successful) { diff --git a/geode-wan/src/distributedTest/java/org/apache/geode/internal/cache/wan/CacheClientNotifierDUnitTest.java b/geode-wan/src/distributedTest/java/org/apache/geode/internal/cache/wan/CacheClientNotifierDUnitTest.java index fd9513082e4d..05632503b031 100644 --- a/geode-wan/src/distributedTest/java/org/apache/geode/internal/cache/wan/CacheClientNotifierDUnitTest.java +++ b/geode-wan/src/distributedTest/java/org/apache/geode/internal/cache/wan/CacheClientNotifierDUnitTest.java @@ -49,7 +49,6 @@ import org.apache.geode.internal.cache.ha.HAContainerRegion; import org.apache.geode.internal.cache.tier.sockets.CacheClientNotifier; import org.apache.geode.internal.cache.tier.sockets.CacheServerTestUtil; -import org.apache.geode.internal.logging.LogService; import org.apache.geode.test.dunit.LogWriterUtils; import org.apache.geode.test.dunit.SerializableRunnable; import org.apache.geode.test.dunit.VM; @@ -192,13 +191,17 @@ public void doMultipleCacheServer(boolean durable) throws Exception { int serverPort = createCacheServerWithCSC(vm2, true, 3, "entry", "DEFAULT"); checkCacheServer(vm2, serverPort, true, 3); - // create cache server 2 - final int serverPort2 = createCacheServerWithCSC(vm2, false, 0, null, null); - // Currently, only the first cache server's overflow attributes will take effect - // It will be enhanced in GEODE-1102 - checkCacheServer(vm2, serverPort2, true, 3); - LogService.getLogger().info("receiverPort=" + receiverPort + ",serverPort=" + serverPort - + ",serverPort2=" + serverPort2); + /* + * GEODE-6344: not to create the 2nd cacheserver on the same jvm until refix of GEODE-1183, + * otherwise the test might be hang + * // create cache server 2 + * final int serverPort2 = createCacheServerWithCSC(vm2, false, 0, null, null); + * // Currently, only the first cache server's overflow attributes will take effect + * // It will be enhanced in GEODE-1102 + * checkCacheServer(vm2, serverPort2, true, 3); + * LogService.getLogger().info("receiverPort=" + receiverPort + ",serverPort=" + serverPort + * + ",serverPort2=" + serverPort2); + */ vm3.invoke(() -> createClientWithLocator(nyPort, "localhost", getTestMethodName() + "_PR", "123", durable)); @@ -219,8 +222,11 @@ public void doMultipleCacheServer(boolean durable) throws Exception { verifyRegionSize(vm4, NUM_KEYS); verifyRegionSize(vm3, NUM_KEYS); - // close a cache server, then re-test - vm2.invoke(() -> closeACacheServer(serverPort2)); + /* + * GEODE-6344 + * // close a cache server, then re-test + * vm2.invoke(() -> closeACacheServer(serverPort2)); + */ vm5.invoke(() -> WANTestBase.doPuts(getTestMethodName() + "_PR", NUM_KEYS * 2)); diff --git a/geode-wan/src/distributedTest/java/org/apache/geode/internal/cache/wan/Simple2CacheServerDUnitTest.java b/geode-wan/src/distributedTest/java/org/apache/geode/internal/cache/wan/Simple2CacheServerDUnitTest.java index 93fcaaf37831..cb10fe8f8864 100644 --- a/geode-wan/src/distributedTest/java/org/apache/geode/internal/cache/wan/Simple2CacheServerDUnitTest.java +++ b/geode-wan/src/distributedTest/java/org/apache/geode/internal/cache/wan/Simple2CacheServerDUnitTest.java @@ -21,6 +21,7 @@ import java.util.Iterator; import java.util.List; +import org.junit.Ignore; import org.junit.Test; import org.junit.experimental.categories.Category; @@ -48,6 +49,7 @@ public Simple2CacheServerDUnitTest() { super(); } + @Ignore // wait to re-fix GEODE-1183 @Test public void testNormalClient2MultipleCacheServer() throws Exception { doMultipleCacheServer(false);