geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bschucha...@apache.org
Subject [10/50] [abbrv] incubator-geode git commit: GEODE-77 added a test for DistributionMessage.isPreciousThread()
Date Fri, 20 Nov 2015 21:02:04 GMT
GEODE-77 added a test for DistributionMessage.isPreciousThread()

This method wasn't correctly determining that a JGroups thread should
not be used for dispatching a cache operation message.  I corrected the
check and added a unit test.


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

Branch: refs/heads/develop
Commit: a68ed7d032c0db1c26a72ccc777a749cabd71718
Parents: b4d083e
Author: Bruce Schuchardt <bschuchardt@pivotal.io>
Authored: Thu Oct 22 14:26:30 2015 -0700
Committer: Bruce Schuchardt <bschuchardt@pivotal.io>
Committed: Thu Oct 22 14:26:30 2015 -0700

----------------------------------------------------------------------
 .../distributed/internal/DistributionMessage.java  |  2 +-
 .../membership/gms/messenger/Transport.java        | 13 +++++++++----
 .../gms/messenger/JGroupsMessengerJUnitTest.java   | 17 +++++++++++++++++
 3 files changed, 27 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/a68ed7d0/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionMessage.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionMessage.java
b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionMessage.java
index ac6d66e..4383f1f 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionMessage.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionMessage.java
@@ -485,7 +485,7 @@ public abstract class DistributionMessage
    */
   public static boolean isPreciousThread() {
     String thrname = Thread.currentThread().getName();
-    return thrname.startsWith("GEODE UDP");
+    return thrname.startsWith("Geode UDP");
   }
 
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/a68ed7d0/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/Transport.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/Transport.java
b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/Transport.java
index 4027437..adb49b9 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/Transport.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/Transport.java
@@ -7,6 +7,11 @@ import org.jgroups.util.DefaultThreadFactory;
 import org.jgroups.util.LazyThreadFactory;
 
 public class Transport extends UDP {
+
+  /**
+   * This is the initial part of the name of all JGroups threads that deliver messages
+   */
+  public static final String PRECIOUS_THREAD_NAME_PREFIX = "Geode UDP";
   
   /*
    * (non-Javadoc)
@@ -49,10 +54,10 @@ public class Transport extends UDP {
   @Override
   public void init() throws Exception {
     global_thread_factory=new DefaultThreadFactory("Geode ", true);
-    timer_thread_factory=new LazyThreadFactory("Geode UDP Timer", true, true);
-    default_thread_factory=new DefaultThreadFactory("Geode UDP Incoming", true, true);
-    oob_thread_factory=new DefaultThreadFactory("Geode UDP OOB", true, true);
-    internal_thread_factory=new DefaultThreadFactory("Geode UDP INT", true, true);
+    timer_thread_factory=new LazyThreadFactory(PRECIOUS_THREAD_NAME_PREFIX + " Timer", true,
true);
+    default_thread_factory=new DefaultThreadFactory(PRECIOUS_THREAD_NAME_PREFIX + " Incoming",
true, true);
+    oob_thread_factory=new DefaultThreadFactory(PRECIOUS_THREAD_NAME_PREFIX + " OOB", true,
true);
+    internal_thread_factory=new DefaultThreadFactory(PRECIOUS_THREAD_NAME_PREFIX + " INT",
true, true);
     super.init();
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/a68ed7d0/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessengerJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessengerJUnitTest.java
b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessengerJUnitTest.java
index e2c6700..2b9d451 100755
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessengerJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessengerJUnitTest.java
@@ -31,6 +31,7 @@ import com.gemstone.gemfire.distributed.internal.DMStats;
 import com.gemstone.gemfire.distributed.internal.DistributionConfig;
 import com.gemstone.gemfire.distributed.internal.DistributionConfigImpl;
 import com.gemstone.gemfire.distributed.internal.DistributionManager;
+import com.gemstone.gemfire.distributed.internal.DistributionMessage;
 import com.gemstone.gemfire.distributed.internal.SerialAckedMessage;
 import com.gemstone.gemfire.distributed.internal.membership.InternalDistributedMember;
 import com.gemstone.gemfire.distributed.internal.membership.NetView;
@@ -352,6 +353,22 @@ public class JGroupsMessengerJUnitTest {
     assertFalse(messenger.myChannel.isConnected());
   }
   
+  /**
+   * Test whether DistributionMessage.isPreciousThread() recognizes
+   * that a UDP transport thread is "precious"
+   * @throws Exception
+   */
+  @Test
+  public void testPreciousThread() throws Exception {
+    String name = Thread.currentThread().getName();
+    try {
+      Thread.currentThread().setName(Transport.PRECIOUS_THREAD_NAME_PREFIX + " test thread");
+      assertTrue(DistributionMessage.isPreciousThread());
+    } finally {
+      Thread.currentThread().setName(name);
+    }
+  }
+  
   @Test
   public void testChannelClosedAfterEmergencyCloseNotForcedDisconnectWithAutoReconnect()
throws Exception {
     initMocks(false);


Mime
View raw message