You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by ji...@apache.org on 2016/04/08 18:26:28 UTC

[10/36] incubator-geode git commit: GEODE-1061: Synchronized update operations and executeCQ happens before updates

GEODE-1061: Synchronized update operations and executeCQ happens before updates

* Moved function execution of executeCQ before region updates because if all the updates finish before executeCQ, the test will fail because the cache map size will be zero. This is a feature for PR regions.
* Made all update operations to be synchronous rather than using sleep and infinite while loop to wait.

This closes #121


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

Branch: refs/heads/feature/GEODE-17-2
Commit: 80af53d91053facb803a616e7b32bfdb52302e6d
Parents: e92bf70
Author: nabarun <nn...@pivotal.io>
Authored: Thu Mar 31 13:47:59 2016 -0700
Committer: Jason Huynh <hu...@gmail.com>
Committed: Tue Apr 5 13:58:01 2016 -0700

----------------------------------------------------------------------
 .../cache/query/internal/cq/ServerCQImpl.java   |  7 +++++-
 .../cq/dunit/CqResultSetUsingPoolDUnitTest.java | 24 ++++----------------
 2 files changed, 10 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/80af53d9/geode-cq/src/main/java/com/gemstone/gemfire/cache/query/internal/cq/ServerCQImpl.java
----------------------------------------------------------------------
diff --git a/geode-cq/src/main/java/com/gemstone/gemfire/cache/query/internal/cq/ServerCQImpl.java b/geode-cq/src/main/java/com/gemstone/gemfire/cache/query/internal/cq/ServerCQImpl.java
index 1acb23c..57cd650 100644
--- a/geode-cq/src/main/java/com/gemstone/gemfire/cache/query/internal/cq/ServerCQImpl.java
+++ b/geode-cq/src/main/java/com/gemstone/gemfire/cache/query/internal/cq/ServerCQImpl.java
@@ -69,7 +69,12 @@ public class ServerCQImpl extends CqQueryImpl implements DataSerializable, Serve
    * This holds the keys that are part of the CQ query results.
    * Using this CQ engine can determine whether to execute 
    * query on old value from EntryEvent, which is an expensive
-   * operation. 
+   * operation.
+   *
+   * NOTE:
+   * In case of RR this map is populated and used as intended.
+   * In case of PR this map will not be populated. If executeCQ happens after update operations
+   * this map will remain empty.
    */
   private volatile HashMap<Object, Object> cqResultKeys;
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/80af53d9/geode-cq/src/test/java/com/gemstone/gemfire/cache/query/cq/dunit/CqResultSetUsingPoolDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-cq/src/test/java/com/gemstone/gemfire/cache/query/cq/dunit/CqResultSetUsingPoolDUnitTest.java b/geode-cq/src/test/java/com/gemstone/gemfire/cache/query/cq/dunit/CqResultSetUsingPoolDUnitTest.java
index 37b7949..a94b72b 100644
--- a/geode-cq/src/test/java/com/gemstone/gemfire/cache/query/cq/dunit/CqResultSetUsingPoolDUnitTest.java
+++ b/geode-cq/src/test/java/com/gemstone/gemfire/cache/query/cq/dunit/CqResultSetUsingPoolDUnitTest.java
@@ -764,9 +764,11 @@ public class CqResultSetUsingPoolDUnitTest extends CacheTestCase {
         }
       }
     });
-    
+
+    cqDUnitTest.executeCQ(client, cqName, true, null);
+
     // Keep updating region (async invocation).
-    server2.invokeAsync(new CacheSerializableRunnable("Update Region"){
+    server2.invoke(new CacheSerializableRunnable("Update Region"){
       public void run2()throws CacheException {
         Region region = getCache().getRegion("/root/" + cqDUnitTest.regions[0]);
         // Update (totalObjects - 1) entries.
@@ -790,10 +792,6 @@ public class CqResultSetUsingPoolDUnitTest extends CacheTestCase {
       }
     });
 
-    // Execute CQ.
-    // While region operation is in progress execute CQ.
-    cqDUnitTest.executeCQ(client, cqName, true, null);
-    
     // Verify CQ Cache results.
     server1.invoke(new CacheSerializableRunnable("Verify CQ Cache results"){
       public void run2()throws CacheException {
@@ -804,20 +802,6 @@ public class CqResultSetUsingPoolDUnitTest extends CacheTestCase {
           LogWriterUtils.getLogWriter().info("Failed to get the internal CqService.", ex);
           Assert.fail ("Failed to get the internal CqService.", ex);
         }
-        
-        // Wait till all the region update is performed.
-        Region region = getCache().getRegion("/root/" + cqDUnitTest.regions[0]);
-        while(true){
-          if (region.get(""+ totalObjects) == null){
-            try {
-              Thread.sleep(50);
-            } catch (Exception ex){
-              //ignore.
-            }
-            continue;
-          }
-          break;
-        }
         Collection<? extends InternalCqQuery> cqs = cqService.getAllCqs();
         for (InternalCqQuery cq: cqs){
           ServerCQImpl cqQuery = (ServerCQImpl)cq;