geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bogle...@apache.org
Subject [geode] branch develop updated: GEODE-4306: Added concurrent checks enabled test to event time
Date Mon, 22 Jan 2018 22:44:08 GMT
This is an automated email from the ASF dual-hosted git repository.

boglesby pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git


The following commit(s) were added to refs/heads/develop by this push:
     new ea77216  GEODE-4306: Added concurrent checks enabled test to event time
ea77216 is described below

commit ea7721613a4d3ccde904a3ad820ecd2b4f9f5527
Author: Barry Oglesby <boglesby@users.noreply.github.com>
AuthorDate: Mon Jan 22 14:44:05 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 2312bf6..5b0f704 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
boglesby@apache.org.

Mime
View raw message