geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kl...@apache.org
Subject [12/21] incubator-geode git commit: GEODE-191 fix for transactional region.size()
Date Thu, 24 Sep 2015 22:44:49 GMT
GEODE-191 fix for transactional region.size()

In the merge from sga2 branch, entryCount() no longer consulted the dataView() which led to
getting wrong size when a transaction is hosted on a remote member.


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

Branch: refs/heads/feature/GEODE-189
Commit: e0cd532c123c98d66b968f241d906ea79852a0de
Parents: e0d7f46
Author: Swapnil Bawaskar <sbawaskar@pivotal.io>
Authored: Fri Aug 7 13:48:22 2015 -0700
Committer: Kirk Lund <klund@pivotal.io>
Committed: Thu Aug 13 11:39:44 2015 -0700

----------------------------------------------------------------------
 .../gemfire/internal/cache/LocalRegion.java     |  2 +-
 .../cache/ClientServerTransactionDUnitTest.java |  6 ++-
 .../cache/RemoteTransactionDUnitTest.java       | 41 ++++++++++++++++----
 3 files changed, 39 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e0cd532c/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/LocalRegion.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/LocalRegion.java
b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/LocalRegion.java
index 495e992..617a7ec 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/LocalRegion.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/LocalRegion.java
@@ -2234,7 +2234,7 @@ public class LocalRegion extends AbstractRegion
    * author David Whitlock
    */
   public final int entryCount() {
-    return entryCount(null);
+    return getDataView().entryCount(this);
   }
 
   public int entryCount(Set<Integer> buckets) {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e0cd532c/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/ClientServerTransactionDUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/ClientServerTransactionDUnitTest.java
b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/ClientServerTransactionDUnitTest.java
index d80f6bb..51a8dea 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/ClientServerTransactionDUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/ClientServerTransactionDUnitTest.java
@@ -2130,7 +2130,11 @@ public void testClientCommitAndDataStoreGetsEvent() throws Exception
{
   }
 
   @Override
-  public void testSize() {
+  public void testSizeForTXHostedOnRemoteNode() {
+  }
+
+  @Override
+  public void testSizeOnAccessor() {
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e0cd532c/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/RemoteTransactionDUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/RemoteTransactionDUnitTest.java
b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/RemoteTransactionDUnitTest.java
index a78fab4..5834622 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/RemoteTransactionDUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/cache/RemoteTransactionDUnitTest.java
@@ -1721,14 +1721,24 @@ public class RemoteTransactionDUnitTest extends CacheTestCase {
     });
   }
 
-  public void testSize() {
+  public void testSizeForTXHostedOnRemoteNode() {
+    doSizeTest(false);
+  }
+
+  public void testSizeOnAccessor() {
+    doSizeTest(true);
+  }
+
+  private void doSizeTest(final boolean isAccessor) {
     Host host = Host.getHost(0);
     VM accessor = host.getVM(0);
     VM datastore1 = host.getVM(1);
     VM datastore2 = host.getVM(2);
     initAccessorAndDataStore(accessor, datastore1, datastore2, 0);
 
-    accessor.invoke(new SerializableCallable() {
+    VM taskVM = isAccessor ? accessor : datastore1;
+
+    taskVM.invoke(new SerializableCallable() {
       public Object call() throws Exception {
         Region custRegion = getCache().getRegion(CUSTOMER);
         TXManagerImpl mgr = getGemfireCache().getTxManager();
@@ -1741,16 +1751,31 @@ public class RemoteTransactionDUnitTest extends CacheTestCase {
     datastore1.invoke(verifyNoTxState);
     datastore2.invoke(verifyNoTxState);
     
-    accessor.invoke(new SerializableCallable() {
+    taskVM.invoke(new SerializableCallable() {
       public Object call() throws Exception {
         Region custRegion = getCache().getRegion(CUSTOMER);
         Region orderRegion = getCache().getRegion(ORDER);
         TXManagerImpl mgr = getGemfireCache().getTxManager();
+        TransactionId txId = mgr.suspend();
+        PartitionedRegion custPR = (PartitionedRegion)custRegion;
+        int remoteKey = -1;
+        for (int i=100; i<200; i++) {
+          DistributedMember myId = custPR.getMyId();
+          if (!myId.equals(custPR.getOwnerForKey(custPR.getKeyInfo(new CustId(i))))) {
+            remoteKey = i;
+            break;
+          }
+        }
+        if (remoteKey == -1) {
+          throw new IllegalStateException("expected non-negative key");
+        }
+        mgr.resume(txId);
         assertNotNull(mgr.getTXState());
-        CustId custId = new CustId(5);
-        OrderId orderId = new OrderId(5, custId);
-        custRegion.put(custId, new Customer("customer5", "address5"));
-        orderRegion.put(orderId, new Order("order5"));
+        CustId custId = new CustId(remoteKey);
+        OrderId orderId = new OrderId(remoteKey, custId);
+        custRegion.put(custId, new Customer("customer"+remoteKey, "address"+remoteKey));
+        getCache().getLogger().info("Putting "+custId+", keyInfo:"+custPR.getKeyInfo(new
CustId(remoteKey)));
+        orderRegion.put(orderId, new Order("order"+remoteKey));
         assertEquals(6, custRegion.size());
         return mgr.getTransactionId();
       }
@@ -1759,7 +1784,7 @@ public class RemoteTransactionDUnitTest extends CacheTestCase {
     final Integer txOnDatastore2 = (Integer)datastore2.invoke(getNumberOfTXInProgress);
     assertEquals(1, txOnDatastore1+txOnDatastore2);
 
-    accessor.invoke(new SerializableCallable() {
+    taskVM.invoke(new SerializableCallable() {
       public Object call() throws Exception {
         CacheTransactionManager mgr = getGemfireCache().getTxManager();
         mgr.commit();


Mime
View raw message