You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by bo...@apache.org on 2018/01/18 18:17:09 UTC

[geode] branch feature/GEODE-4306 created (now ed3d076)

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

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


      at ed3d076  GEODE-4306: Added concurrent checks enabled test to event time

This branch includes the following new commits:

     new ed3d076  GEODE-4306: Added concurrent checks enabled test to event time

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.


-- 
To stop receiving notification emails like this one, please contact
['"commits@geode.apache.org" <co...@geode.apache.org>'].

[geode] 01/01: GEODE-4306: Added concurrent checks enabled test to event time

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

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

commit ed3d07695279632266b6f6d27e71b59b28d8cf57
Author: Barry Oglesby <bo...@pivotal.io>
AuthorDate: Wed Jan 17 16:31:16 2018 -0800

    GEODE-4306: Added concurrent checks enabled test to event time
---
 .../geode/internal/cache/EntryEventImpl.java       |  2 +-
 .../geode/internal/cache/EntryEventImplTest.java   | 65 ++++++++++++++++++++++
 2 files changed, 66 insertions(+), 1 deletion(-)

diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/EntryEventImpl.java b/geode-core/src/main/java/org/apache/geode/internal/cache/EntryEventImpl.java
index 575417a..836aff7 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/EntryEventImpl.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/EntryEventImpl.java
@@ -2546,7 +2546,7 @@ public class EntryEventImpl
    */
   public long getEventTime(long suggestedTime) {
     long result = suggestedTime;
-    if (this.versionTag != null) {
+    if (this.versionTag != null && getRegion().getConcurrencyChecksEnabled()) {
       if (suggestedTime != 0) {
         this.versionTag.setVersionTimeStamp(suggestedTime);
       } else {
diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/EntryEventImplTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/EntryEventImplTest.java
index eb3e804..7097ba1 100644
--- a/geode-core/src/test/java/org/apache/geode/internal/cache/EntryEventImplTest.java
+++ b/geode-core/src/test/java/org/apache/geode/internal/cache/EntryEventImplTest.java
@@ -14,6 +14,7 @@
  */
 package org.apache.geode.internal.cache;
 
+import static org.assertj.core.api.Assertions.assertThat;
 import static org.junit.Assert.*;
 import static org.mockito.Mockito.*;
 
@@ -27,8 +28,10 @@ import org.junit.experimental.categories.Category;
 
 import org.apache.geode.cache.Operation;
 import org.apache.geode.cache.SerializedCacheValue;
+import org.apache.geode.distributed.internal.membership.InternalDistributedMember;
 import org.apache.geode.internal.cache.EntryEventImpl.NewValueImporter;
 import org.apache.geode.internal.cache.EntryEventImpl.OldValueImporter;
+import org.apache.geode.internal.cache.versions.VersionTag;
 import org.apache.geode.internal.offheap.StoredObject;
 import org.apache.geode.test.junit.categories.UnitTest;
 
@@ -657,6 +660,68 @@ public class EntryEventImplTest {
     }
   }
 
+  @Test
+  public void testGetEventTimeWithNullVersionTag() {
+    long timestamp = System.currentTimeMillis();
+    LocalRegion region = mock(LocalRegion.class);
+    when(region.cacheTimeMillis()).thenReturn(timestamp);
+    EntryEventImpl e = createEntryEvent(region, null);
+    assertThat(e.getEventTime(0l)).isEqualTo(timestamp);
+  }
+
+  @Test
+  public void testGetEventTimeWithVersionTagConcurrencyChecksEnabled() {
+    long timestamp = System.currentTimeMillis();
+    LocalRegion region = mock(LocalRegion.class);
+    when(region.getConcurrencyChecksEnabled()).thenReturn(true);
+    EntryEventImpl e = createEntryEvent(region, null);
+    VersionTag tag = VersionTag.create(mock(InternalDistributedMember.class));
+    tag.setVersionTimeStamp(timestamp);
+    e.setVersionTag(tag);
+    assertThat(e.getEventTime(0l)).isEqualTo(timestamp);
+  }
+
+  @Test
+  public void testGetEventTimeWithVersionTagConcurrencyChecksEnabledWithSuggestedTime() {
+    long timestamp = System.currentTimeMillis();
+    long timestampPlus1 = timestamp + 1000l;
+    long timestampPlus2 = timestamp + 2000l;
+    LocalRegion region = mock(LocalRegion.class);
+    when(region.getConcurrencyChecksEnabled()).thenReturn(true);
+    when(region.cacheTimeMillis()).thenReturn(timestamp);
+    EntryEventImpl e = createEntryEvent(region, null);
+    VersionTag tag = VersionTag.create(mock(InternalDistributedMember.class));
+    tag.setVersionTimeStamp(timestampPlus1);
+    e.setVersionTag(tag);
+    assertThat(e.getEventTime(timestampPlus2)).isEqualTo(timestampPlus2);
+    assertThat(tag.getVersionTimeStamp()).isEqualTo(timestampPlus2);
+  }
+
+  @Test
+  public void testGetEventTimeWithVersionTagConcurrencyChecksDisabledNoSuggestedTime() {
+    long timestamp = System.currentTimeMillis();
+    LocalRegion region = mock(LocalRegion.class);
+    when(region.getConcurrencyChecksEnabled()).thenReturn(false);
+    when(region.cacheTimeMillis()).thenReturn(timestamp);
+    EntryEventImpl e = createEntryEvent(region, null);
+    VersionTag tag = VersionTag.create(mock(InternalDistributedMember.class));
+    tag.setVersionTimeStamp(timestamp + 1000l);
+    e.setVersionTag(tag);
+    assertThat(e.getEventTime(0l)).isEqualTo(timestamp);
+  }
+
+  @Test
+  public void testGetEventTimeWithVersionTagConcurrencyChecksDisabledWithSuggestedTime() {
+    long timestamp = System.currentTimeMillis();
+    LocalRegion region = mock(LocalRegion.class);
+    when(region.getConcurrencyChecksEnabled()).thenReturn(false);
+    EntryEventImpl e = createEntryEvent(region, null);
+    VersionTag tag = VersionTag.create(mock(InternalDistributedMember.class));
+    tag.setVersionTimeStamp(timestamp + 1000l);
+    e.setVersionTag(tag);
+    assertThat(e.getEventTime(timestamp)).isEqualTo(timestamp);
+  }
+
   private static class EntryEventImplWithOldValuesDisabled extends EntryEventImpl {
     @Override
     protected boolean areOldValuesEnabled() {

-- 
To stop receiving notification emails like this one, please contact
"commits@geode.apache.org" <co...@geode.apache.org>.