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 2015/08/14 22:40:25 UTC

[36/50] [abbrv] incubator-geode git commit: GEODE-191 fix for transactional region.size()

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/b1e7466c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/b1e7466c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/b1e7466c

Branch: refs/heads/feature/GEODE-77
Commit: b1e7466cb64fd6413c4658026498e5e6f4b8a7c8
Parents: fcb42ad
Author: Swapnil Bawaskar <sb...@pivotal.io>
Authored: Fri Aug 7 13:48:22 2015 -0700
Committer: Swapnil Bawaskar <sb...@pivotal.io>
Committed: Fri Aug 7 13:48:22 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/b1e7466c/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/b1e7466c/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/b1e7466c/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();