You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by bs...@apache.org on 2018/06/13 22:32:11 UTC
[geode] branch develop updated: GEODE-5320 add a test for
thread-owned connection cleanup
This is an automated email from the ASF dual-hosted git repository.
bschuchardt pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git
The following commit(s) were added to refs/heads/develop by this push:
new 3f4c33b GEODE-5320 add a test for thread-owned connection cleanup
3f4c33b is described below
commit 3f4c33b0588bfc147bdb052e45d149a7397dffe9
Author: Bruce Schuchardt <bs...@pivotal.io>
AuthorDate: Wed Jun 13 15:29:43 2018 -0700
GEODE-5320 add a test for thread-owned connection cleanup
added a unit test to ensure that thread-owned connection cleanup is
functioning properly
---
.../apache/geode/internal/tcp/ConnectionTable.java | 2 +-
.../geode/internal/tcp/ConnectionTableTest.java | 19 +++++++++++++++++++
2 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/geode-core/src/main/java/org/apache/geode/internal/tcp/ConnectionTable.java b/geode-core/src/main/java/org/apache/geode/internal/tcp/ConnectionTable.java
index 82613cb..89d7693 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/tcp/ConnectionTable.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/tcp/ConnectionTable.java
@@ -86,7 +86,7 @@ public class ConnectionTable {
* synchronized because of static cleanup.
*/
// ThreadLocal<Map>
- private final ThreadLocal threadOrderedConnMap;
+ protected final ThreadLocal<Map> threadOrderedConnMap;
/**
* List of thread-owned ordered connection maps, for cleanup
diff --git a/geode-core/src/test/java/org/apache/geode/internal/tcp/ConnectionTableTest.java b/geode-core/src/test/java/org/apache/geode/internal/tcp/ConnectionTableTest.java
index 3a7b7d6..eb87a1b 100644
--- a/geode-core/src/test/java/org/apache/geode/internal/tcp/ConnectionTableTest.java
+++ b/geode-core/src/test/java/org/apache/geode/internal/tcp/ConnectionTableTest.java
@@ -20,12 +20,15 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.net.Socket;
+import java.util.HashMap;
+import java.util.Map;
import org.junit.Before;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.apache.geode.CancelCriterion;
+import org.apache.geode.distributed.DistributedMember;
import org.apache.geode.distributed.internal.DMStats;
import org.apache.geode.distributed.internal.DistributionManager;
import org.apache.geode.distributed.internal.InternalDistributedSystem;
@@ -93,4 +96,20 @@ public class ConnectionTableTest {
connectionTable.acceptConnection(socket, factory);
assertEquals(1, connectionTable.getNumberOfReceivers());
}
+
+ @Test
+ public void testThreadOwnedSocketsAreRemoved() throws Exception {
+ Boolean wantsResources = ConnectionTable.getThreadOwnsResourcesRegistration();
+ ConnectionTable.threadWantsOwnResources();
+ try {
+ Map<DistributedMember, Connection> threadConnectionMap = new HashMap<>();
+ connectionTable.threadOrderedConnMap.set(threadConnectionMap);
+ ConnectionTable.releaseThreadsSockets();
+ assertEquals(0, threadConnectionMap.size());
+ } finally {
+ if (wantsResources != Boolean.FALSE) {
+ ConnectionTable.threadWantsSharedResources();
+ }
+ }
+ }
}
--
To stop receiving notification emails like this one, please contact
bschuchardt@apache.org.