geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jasonhu...@apache.org
Subject [geode] branch develop updated: GEODE-3653: Remove testHook from AbstractGatewaySenderEventProcessor (#1217)
Date Thu, 01 Feb 2018 18:03:31 GMT
This is an automated email from the ASF dual-hosted git repository.

jasonhuynh 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 329e0c5  GEODE-3653: Remove testHook from AbstractGatewaySenderEventProcessor (#1217)
329e0c5 is described below

commit 329e0c506d347b507aabfb55687912ef9207cf5e
Author: Juan José Ramos <jujoramos@users.noreply.github.com>
AuthorDate: Thu Feb 1 18:03:28 2018 +0000

    GEODE-3653: Remove testHook from AbstractGatewaySenderEventProcessor (#1217)
    
    - `numEventsDispatched` is being used only by test classes
    - Updated `ConcurrentParallelGatewaySenderDUnitTest`, removed unused
      imports and verified that current tests finish correctly.
---
 .../wan/AbstractGatewaySenderEventProcessor.java   | 15 +++--
 .../ConcurrentParallelGatewaySenderDUnitTest.java  | 76 ++++++----------------
 2 files changed, 30 insertions(+), 61 deletions(-)

diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/wan/AbstractGatewaySenderEventProcessor.java
b/geode-core/src/main/java/org/apache/geode/internal/cache/wan/AbstractGatewaySenderEventProcessor.java
index 7a2cee1..7e67e9b 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/wan/AbstractGatewaySenderEventProcessor.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/wan/AbstractGatewaySenderEventProcessor.java
@@ -71,8 +71,6 @@ public abstract class AbstractGatewaySenderEventProcessor extends Thread
{
 
   private static final Logger logger = LogService.getLogger();
 
-  public static boolean TEST_HOOK = false;
-
   protected RegionQueue queue;
 
   protected GatewaySenderEventDispatcher dispatcher;
@@ -133,6 +131,9 @@ public abstract class AbstractGatewaySenderEventProcessor extends Thread
{
 
   private volatile boolean resetLastPeekedEvents;
 
+  /**
+   * Cumulative count of events dispatched by this event processor.
+   */
   private long numEventsDispatched;
 
   /**
@@ -640,9 +641,8 @@ public abstract class AbstractGatewaySenderEventProcessor extends Thread
{
             for (GatewaySenderEventImpl pdxGatewaySenderEvent : pdxEventsToBeDispatched)
{
               pdxGatewaySenderEvent.isDispatched = true;
             }
-            if (TEST_HOOK) {
-              this.numEventsDispatched += conflatedEventsToBeDispatched.size();
-            }
+
+            increaseNumEventsDispatched(conflatedEventsToBeDispatched.size());
           } // successful batch
           else { // The batch was unsuccessful.
             if (this.dispatcher instanceof GatewaySenderEventCallbackDispatcher) {
@@ -1255,10 +1255,15 @@ public abstract class AbstractGatewaySenderEventProcessor extends
Thread {
     }
   }
 
+
   public long getNumEventsDispatched() {
     return numEventsDispatched;
   }
 
+  public void increaseNumEventsDispatched(long newEventsDispatched) {
+    this.numEventsDispatched += newEventsDispatched;
+  }
+
   public void clear(PartitionedRegion pr, int bucketId) {
     ((ParallelGatewaySenderQueue) this.queue).clear(pr, bucketId);
   }
diff --git a/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/concurrent/ConcurrentParallelGatewaySenderDUnitTest.java
b/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/concurrent/ConcurrentParallelGatewaySenderDUnitTest.java
index 3f4d58b..4db1d01 100644
--- a/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/concurrent/ConcurrentParallelGatewaySenderDUnitTest.java
+++ b/geode-wan/src/test/java/org/apache/geode/internal/cache/wan/concurrent/ConcurrentParallelGatewaySenderDUnitTest.java
@@ -17,7 +17,6 @@ package org.apache.geode.internal.cache.wan.concurrent;
 import static org.junit.Assert.assertEquals;
 
 import java.net.SocketException;
-import java.util.Set;
 import java.util.concurrent.TimeUnit;
 
 import org.awaitility.Awaitility;
@@ -26,12 +25,9 @@ import org.junit.experimental.categories.Category;
 
 import org.apache.geode.cache.EntryExistsException;
 import org.apache.geode.cache.client.ServerOperationException;
-import org.apache.geode.cache.wan.GatewaySender;
 import org.apache.geode.cache.wan.GatewaySender.OrderPolicy;
-import org.apache.geode.internal.cache.wan.AbstractGatewaySender;
 import org.apache.geode.internal.cache.wan.BatchException70;
 import org.apache.geode.internal.cache.wan.WANTestBase;
-import org.apache.geode.internal.cache.wan.parallel.ConcurrentParallelGatewaySenderEventProcessor;
 import org.apache.geode.test.dunit.AsyncInvocation;
 import org.apache.geode.test.dunit.IgnoredException;
 import org.apache.geode.test.dunit.LogWriterUtils;
@@ -96,40 +92,26 @@ public class ConcurrentParallelGatewaySenderDUnitTest extends WANTestBase
{
     vm6.invoke(() -> WANTestBase.waitForSenderRunningState("ln"));
     vm7.invoke(() -> WANTestBase.waitForSenderRunningState("ln"));
 
-    try {
-      // set the test hook to find out dispatched events by each of the
-      // concurrent dispatcher
-      vm4.invoke(() -> ConcurrentParallelGatewaySenderDUnitTest.setTestHook("ln", Boolean.TRUE));
-      vm5.invoke(() -> ConcurrentParallelGatewaySenderDUnitTest.setTestHook("ln", Boolean.TRUE));
-      vm6.invoke(() -> ConcurrentParallelGatewaySenderDUnitTest.setTestHook("ln", Boolean.TRUE));
-      vm7.invoke(() -> ConcurrentParallelGatewaySenderDUnitTest.setTestHook("ln", Boolean.TRUE));
-
-      vm4.invoke(() -> WANTestBase.doPuts(getTestMethodName() + "_PR", 1000));
-
-      // verify all buckets drained on all sender nodes.
-      vm4.invoke(() -> WANTestBase.validateParallelSenderQueueAllBucketsDrained("ln"));
-      vm5.invoke(() -> WANTestBase.validateParallelSenderQueueAllBucketsDrained("ln"));
-      vm6.invoke(() -> WANTestBase.validateParallelSenderQueueAllBucketsDrained("ln"));
-      vm7.invoke(() -> WANTestBase.validateParallelSenderQueueAllBucketsDrained("ln"));
-
-      vm2.invoke(() -> WANTestBase.validateRegionSize(getTestMethodName() + "_PR", 1000));
-
-      int dispatched1 = (Integer) vm4
-          .invoke(() -> WANTestBase.verifyAndGetEventsDispatchedByConcurrentDispatchers("ln"));
-      int dispatched2 = (Integer) vm5
-          .invoke(() -> WANTestBase.verifyAndGetEventsDispatchedByConcurrentDispatchers("ln"));
-      int dispatched3 = (Integer) vm6
-          .invoke(() -> WANTestBase.verifyAndGetEventsDispatchedByConcurrentDispatchers("ln"));
-      int dispatched4 = (Integer) vm7
-          .invoke(() -> WANTestBase.verifyAndGetEventsDispatchedByConcurrentDispatchers("ln"));
-
-      assertEquals(1000, dispatched1 + dispatched2 + dispatched3 + dispatched4);
-    } finally {
-      vm4.invoke(() -> ConcurrentParallelGatewaySenderDUnitTest.setTestHook("ln", Boolean.FALSE));
-      vm5.invoke(() -> ConcurrentParallelGatewaySenderDUnitTest.setTestHook("ln", Boolean.FALSE));
-      vm6.invoke(() -> ConcurrentParallelGatewaySenderDUnitTest.setTestHook("ln", Boolean.FALSE));
-      vm7.invoke(() -> ConcurrentParallelGatewaySenderDUnitTest.setTestHook("ln", Boolean.FALSE));
-    }
+    vm4.invoke(() -> WANTestBase.doPuts(getTestMethodName() + "_PR", 1000));
+
+    // verify all buckets drained on all sender nodes.
+    vm4.invoke(() -> WANTestBase.validateParallelSenderQueueAllBucketsDrained("ln"));
+    vm5.invoke(() -> WANTestBase.validateParallelSenderQueueAllBucketsDrained("ln"));
+    vm6.invoke(() -> WANTestBase.validateParallelSenderQueueAllBucketsDrained("ln"));
+    vm7.invoke(() -> WANTestBase.validateParallelSenderQueueAllBucketsDrained("ln"));
+
+    vm2.invoke(() -> WANTestBase.validateRegionSize(getTestMethodName() + "_PR", 1000));
+
+    int dispatched1 = (Integer) vm4
+        .invoke(() -> WANTestBase.verifyAndGetEventsDispatchedByConcurrentDispatchers("ln"));
+    int dispatched2 = (Integer) vm5
+        .invoke(() -> WANTestBase.verifyAndGetEventsDispatchedByConcurrentDispatchers("ln"));
+    int dispatched3 = (Integer) vm6
+        .invoke(() -> WANTestBase.verifyAndGetEventsDispatchedByConcurrentDispatchers("ln"));
+    int dispatched4 = (Integer) vm7
+        .invoke(() -> WANTestBase.verifyAndGetEventsDispatchedByConcurrentDispatchers("ln"));
+
+    assertEquals(1000, dispatched1 + dispatched2 + dispatched3 + dispatched4);
   }
 
   /**
@@ -720,22 +702,4 @@ public class ConcurrentParallelGatewaySenderDUnitTest extends WANTestBase
{
 
     vm2.invoke(() -> WANTestBase.validateRegionSize_PDX(getTestMethodName() + "_PR", 40));
   }
-
-  public static void setTestHook(String senderId, boolean hook) {
-    Set<GatewaySender> senders = cache.getGatewaySenders();
-    GatewaySender sender = null;
-    for (GatewaySender s : senders) {
-      if (s.getId().equals(senderId)) {
-        sender = s;
-        break;
-      }
-    }
-    ConcurrentParallelGatewaySenderEventProcessor cProc =
-        (ConcurrentParallelGatewaySenderEventProcessor) ((AbstractGatewaySender) sender)
-            .getEventProcessor();
-    if (cProc == null)
-      return;
-    cProc.TEST_HOOK = hook;
-  }
-
 }

-- 
To stop receiving notification emails like this one, please contact
jasonhuynh@apache.org.

Mime
View raw message