geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dschnei...@apache.org
Subject [2/3] incubator-geode git commit: The closer on CacheClientNotifier now waits 50ms for the asyncClose request to complete. The unit tests now configure a closer much like the one used by the notifier.
Date Tue, 22 Sep 2015 23:39:36 GMT
The closer on CacheClientNotifier now waits 50ms for the asyncClose request to complete.
The unit tests now configure a closer much like the one used by the notifier.


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

Branch: refs/heads/feature/GEODE-332
Commit: b317428c35005f8c2827fe45d6e154c2b6d69669
Parents: 193dd38
Author: Darrel Schneider <dschneider@pivotal.io>
Authored: Tue Sep 22 16:20:05 2015 -0700
Committer: Darrel Schneider <dschneider@pivotal.io>
Committed: Tue Sep 22 16:20:05 2015 -0700

----------------------------------------------------------------------
 .../java/com/gemstone/gemfire/internal/SocketCloser.java     | 8 ++++++--
 .../internal/cache/tier/sockets/CacheClientNotifier.java     | 2 +-
 .../com/gemstone/gemfire/internal/SocketCloserJUnitTest.java | 5 +++--
 .../gemfire/internal/SocketCloserWithWaitJUnitTest.java      | 3 ++-
 4 files changed, 12 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b317428c/gemfire-core/src/main/java/com/gemstone/gemfire/internal/SocketCloser.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/SocketCloser.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/SocketCloser.java
index be98db7..8468daa 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/SocketCloser.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/SocketCloser.java
@@ -56,8 +56,8 @@ public class SocketCloser {
   public SocketCloser() {
     this(ASYNC_CLOSE_POOL_KEEP_ALIVE_SECONDS, ASYNC_CLOSE_POOL_MAX_THREADS, ASYNC_CLOSE_WAIT_MILLISECONDS,
TimeUnit.MILLISECONDS);
   }
-  public SocketCloser(int asyncClosePoolMaxThreads) {
-    this(ASYNC_CLOSE_POOL_KEEP_ALIVE_SECONDS, asyncClosePoolMaxThreads, ASYNC_CLOSE_WAIT_MILLISECONDS,
TimeUnit.MILLISECONDS);
+  public SocketCloser(int asyncClosePoolMaxThreads, long asyncCloseWaitMillis) {
+    this(ASYNC_CLOSE_POOL_KEEP_ALIVE_SECONDS, asyncClosePoolMaxThreads, asyncCloseWaitMillis,
TimeUnit.MILLISECONDS);
   }
   public SocketCloser(long asyncClosePoolKeepAliveSeconds, int asyncClosePoolMaxThreads,
long asyncCloseWaitTime, TimeUnit asyncCloseWaitUnits) {
     this.asyncClosePoolKeepAliveSeconds = asyncClosePoolKeepAliveSeconds;
@@ -65,6 +65,10 @@ public class SocketCloser {
     this.asyncCloseWaitTime = asyncCloseWaitTime;
     this.asyncCloseWaitUnits = asyncCloseWaitUnits;
   }
+  
+  public int getMaxThreads() {
+    return this.asyncClosePoolMaxThreads;
+  }
 
   private ThreadPoolExecutor getAsyncThreadExecutor(String address) {
     synchronized (asyncCloseExecutors) {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b317428c/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/CacheClientNotifier.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/CacheClientNotifier.java
b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/CacheClientNotifier.java
index d23e1d7..deddfd1 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/CacheClientNotifier.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/tier/sockets/CacheClientNotifier.java
@@ -2123,7 +2123,7 @@ public class CacheClientNotifier {
     // Set the Cache
     this.setCache((GemFireCacheImpl)cache);
     this.acceptorStats = acceptorStats;
-    this.socketCloser = new SocketCloser(1); // we only need one thread per client
+    this.socketCloser = new SocketCloser(1, 50); // we only need one thread per client and
wait 50ms for close
 
     // Set the LogWriter
     this.logWriter = (InternalLogWriter)cache.getLogger();

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b317428c/gemfire-core/src/test/java/com/gemstone/gemfire/internal/SocketCloserJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/SocketCloserJUnitTest.java
b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/SocketCloserJUnitTest.java
index 681b2a7..0b66ec5 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/SocketCloserJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/SocketCloserJUnitTest.java
@@ -97,12 +97,13 @@ public class SocketCloserJUnitTest {
     // Each thread pool (one for A and one for B) has a max of 8 threads.
     // So verify that this many are currently waiting on cdl.
     {
+      final int maxThreads = this.socketCloser.getMaxThreads();
       WaitCriterion wc = new WaitCriterion() {
         public boolean done() {
-          return waitingToClose.get() == 2*8;
+          return waitingToClose.get() == 2*maxThreads;
         }
         public String description() {
-          return "expected 16 waiters but found only " + waitingToClose.get();
+          return "expected " + 2*maxThreads + " waiters but found only " + waitingToClose.get();
         }
       };
       DistributedTestCase.waitForCriterion(wc, 5000, 10, true);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/b317428c/gemfire-core/src/test/java/com/gemstone/gemfire/internal/SocketCloserWithWaitJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/SocketCloserWithWaitJUnitTest.java
b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/SocketCloserWithWaitJUnitTest.java
index 5f3eb5b..9e63743 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/SocketCloserWithWaitJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/SocketCloserWithWaitJUnitTest.java
@@ -8,6 +8,7 @@ import com.gemstone.gemfire.test.junit.categories.UnitTest;
 
 /**
  * Tests SocketCloser with a wait time. The default SocketCloser does not wait.
+ * This test configures a closer much like the one used by CacheClientNotifier.
  */
 @Category(UnitTest.class)
 public class SocketCloserWithWaitJUnitTest extends SocketCloserJUnitTest {
@@ -15,7 +16,7 @@ public class SocketCloserWithWaitJUnitTest extends SocketCloserJUnitTest
{
   protected SocketCloser createSocketCloser() {
     return new SocketCloser(
         SocketCloser.ASYNC_CLOSE_POOL_KEEP_ALIVE_SECONDS,
-        SocketCloser.ASYNC_CLOSE_POOL_MAX_THREADS,
+        1, // max threads
         1, TimeUnit.NANOSECONDS);
   }
 }


Mime
View raw message