You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by sa...@apache.org on 2016/06/23 17:25:27 UTC

[03/15] incubator-geode git commit: GEODE-11: Added changes to Lucene AEQ, to propagate expiration destroy events (by setting the flag forwardExpirationDestroy()).

GEODE-11: Added changes to Lucene AEQ, to propagate expiration destroy events (by setting the flag forwardExpirationDestroy()).


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

Branch: refs/heads/feature/GEODE-1573
Commit: 02964761656928b61eb8abb6e6029ef12e05733c
Parents: b53d28f
Author: Anil <ag...@pivotal.io>
Authored: Mon Jun 20 11:22:41 2016 -0700
Committer: Anil <ag...@pivotal.io>
Committed: Mon Jun 20 11:22:51 2016 -0700

----------------------------------------------------------------------
 .../LuceneIndexForPartitionedRegion.java        |  1 +
 .../LuceneIndexMaintenanceIntegrationTest.java  | 35 ++++++++++++++++++++
 2 files changed, 36 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/02964761/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIndexForPartitionedRegion.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIndexForPartitionedRegion.java b/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIndexForPartitionedRegion.java
index d283e29..891a658 100644
--- a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIndexForPartitionedRegion.java
+++ b/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIndexForPartitionedRegion.java
@@ -124,6 +124,7 @@ public class LuceneIndexForPartitionedRegion extends LuceneIndexImpl {
       factory.setPersistent(true);
     }
     factory.setDiskSynchronous(dataRegion.getAttributes().isDiskSynchronous());
+    factory.setForwardExpirationDestroy(true);
     return factory;
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/02964761/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/LuceneIndexMaintenanceIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/LuceneIndexMaintenanceIntegrationTest.java b/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/LuceneIndexMaintenanceIntegrationTest.java
index 05b6990..352c6b9 100644
--- a/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/LuceneIndexMaintenanceIntegrationTest.java
+++ b/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/LuceneIndexMaintenanceIntegrationTest.java
@@ -25,9 +25,12 @@ import java.io.Serializable;
 import java.util.concurrent.TimeUnit;
 
 import com.jayway.awaitility.Awaitility;
+
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
+import com.gemstone.gemfire.cache.ExpirationAction;
+import com.gemstone.gemfire.cache.ExpirationAttributes;
 import com.gemstone.gemfire.cache.Region;
 import com.gemstone.gemfire.cache.RegionShortcut;
 import com.gemstone.gemfire.cache.lucene.internal.LuceneIndexForPartitionedRegion;
@@ -132,6 +135,38 @@ public class LuceneIndexMaintenanceIntegrationTest extends LuceneIntegrationTest
     await(() -> assertTrue(fileSystemStats.getBytes() > 0));
   }
 
+  @Test
+  public void indexShouldBeUpdatedWithRegionExpirationDestroyOperation() throws Exception {
+    luceneService.createIndex(INDEX_NAME, REGION_NAME, "title", "description");
+
+    // Configure PR with expiration operation set to destroy
+    Region region = cache.createRegionFactory(RegionShortcut.PARTITION)
+        .setEntryTimeToLive(new ExpirationAttributes(1, ExpirationAction.DESTROY))
+        .create(REGION_NAME);
+    populateRegion(region);
+    // Wait for expiration to destroy region entries. The region should be
+    // left with zero entries.
+    Awaitility.await().atMost(60, TimeUnit.SECONDS).until(() -> {
+      assertEquals(0, region.size());
+    });
+
+    LuceneIndex index = luceneService.getIndex(INDEX_NAME, REGION_NAME);
+    // Wait for events to be flushed from AEQ.
+    index.waitUntilFlushed(WAIT_FOR_FLUSH_TIME);
+    // Execute query to fetch all the values for "description" field.
+    LuceneQuery query = luceneService.createLuceneQueryFactory().create(INDEX_NAME, REGION_NAME, "description:\"hello world\"", DEFAULT_FIELD);
+    LuceneQueryResults<Integer, TestObject> results = query.search();
+    // The query should return 0 results.
+    assertEquals(0, results.size());
+  }
+
+  private void populateRegion(Region region) {
+    region.put("object-1", new TestObject("title 1", "hello world"));
+    region.put("object-2", new TestObject("title 2", "this will not match"));
+    region.put("object-3", new TestObject("title 3", "hello world"));
+    region.put("object-4", new TestObject("hello world", "hello world"));
+  }
+
   private void await(Runnable runnable) {
     Awaitility.await().atMost(30, TimeUnit.SECONDS).until(runnable);
   }