You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by zh...@apache.org on 2018/11/14 22:57:55 UTC

[geode] branch feature/GEODE-6058 created (now 458ff18)

This is an automated email from the ASF dual-hosted git repository.

zhouxj pushed a change to branch feature/GEODE-6058
in repository https://gitbox.apache.org/repos/asf/geode.git.


      at 458ff18  GEODE-6058: recordVersion should allow update higher local version if for non-persistent region

This branch includes the following new commits:

     new 458ff18  GEODE-6058: recordVersion should allow update higher local version if for non-persistent region

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[geode] 01/01: GEODE-6058: recordVersion should allow update higher local version if for non-persistent region

Posted by zh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

zhouxj pushed a commit to branch feature/GEODE-6058
in repository https://gitbox.apache.org/repos/asf/geode.git

commit 458ff181f70bb86d555f2b86640f0427ad8b9411
Author: zhouxh <gz...@pivotal.io>
AuthorDate: Wed Nov 14 14:55:07 2018 -0800

    GEODE-6058: recordVersion should allow update higher local version if for non-persistent region
---
 .../cache/versions/RegionVersionVector.java        |  3 +-
 .../cache/versions/RegionVersionVectorTest.java    | 37 ++++++++++++++++++++++
 2 files changed, 39 insertions(+), 1 deletion(-)

diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/versions/RegionVersionVector.java b/geode-core/src/main/java/org/apache/geode/internal/cache/versions/RegionVersionVector.java
index 7b03d48..c68b6b8 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/versions/RegionVersionVector.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/versions/RegionVersionVector.java
@@ -648,8 +648,9 @@ public abstract class RegionVersionVector<T extends VersionSource<?>>
       // recovers. So we can only assert that the local member has already seen
       // the replayed event.
       synchronized (localExceptions) {
+
         if (this.localVersion.get() < tag.getRegionVersion() && region != null
-            && region.isInitialized()) {
+            && region.isInitialized() && region.getDataPolicy().withPersistence()) {
           Assert.fail(
               "recordVersion invoked for a local version tag that is higher than our local version. rvv="
                   + this + ", tag=" + tag + " " + region.getName());
diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/versions/RegionVersionVectorTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/versions/RegionVersionVectorTest.java
index deb7d4e..27c68ab 100644
--- a/geode-core/src/test/java/org/apache/geode/internal/cache/versions/RegionVersionVectorTest.java
+++ b/geode-core/src/test/java/org/apache/geode/internal/cache/versions/RegionVersionVectorTest.java
@@ -43,6 +43,7 @@ import org.junit.rules.ExpectedException;
 
 import org.apache.geode.DataSerializer;
 import org.apache.geode.InternalGemFireError;
+import org.apache.geode.cache.DataPolicy;
 import org.apache.geode.distributed.internal.membership.InternalDistributedMember;
 import org.apache.geode.internal.HeapDataOutputStream;
 import org.apache.geode.internal.Version;
@@ -616,6 +617,42 @@ public class RegionVersionVectorTest {
   }
 
   @Test
+  public void recordVersionIntoLocalMemberShouldFailIfRegionIsPersistent() {
+    LocalRegion mockRegion = mock(LocalRegion.class);
+    when(mockRegion.isInitialized()).thenReturn(true);
+    when(mockRegion.getDataPolicy()).thenReturn(DataPolicy.PERSISTENT_REPLICATE);
+    final String local = getIPLiteral();
+    DiskStoreID ownerId = new DiskStoreID();
+
+    DiskRegionVersionVector rvv = new DiskRegionVersionVector(ownerId, mockRegion);
+
+    DiskVersionTag tag = new DiskVersionTag();
+    tag.setRegionVersion(1);
+    tag.setMemberID(ownerId);
+
+    expectedException.expect(InternalGemFireError.class);
+    rvv.recordVersion(ownerId, tag);
+  }
+
+  @Test
+  public void recordVersionIntoLocalMemberShouldPassfRegionIsNonPersistent() {
+    LocalRegion mockRegion = mock(LocalRegion.class);
+    when(mockRegion.isInitialized()).thenReturn(true);
+    when(mockRegion.getDataPolicy()).thenReturn(DataPolicy.REPLICATE);
+    final String local = getIPLiteral();
+    InternalDistributedMember ownerId = new InternalDistributedMember(local, 101);
+    RegionVersionVector rvv = createRegionVersionVector(ownerId, mockRegion);
+
+    VMVersionTag tag = new VMVersionTag();
+    tag.setRegionVersion(1);
+    tag.setMemberID(ownerId);
+
+    rvv.recordVersion(ownerId, tag);
+    assertEquals(1, rvv.getLocalExceptions().version);
+    assertEquals(2, rvv.getNextVersion());
+  }
+
+  @Test
   public void usesNewVersionIfGreaterThanOldVersion() throws Exception {
     VersionSource<InternalDistributedMember> ownerId = mock(VersionSource.class);
     long oldVersion = 1;