geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aging...@apache.org
Subject incubator-geode git commit: GEODE-11: Added changes to Lucene AEQ, to propagate expiration destroy events (by setting the flag forwardExpirationDestroy()).
Date Mon, 20 Jun 2016 18:26:39 GMT
Repository: incubator-geode
Updated Branches:
  refs/heads/develop b53d28ff6 -> 029647616


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/develop
Commit: 02964761656928b61eb8abb6e6029ef12e05733c
Parents: b53d28f
Author: Anil <agingade@pivotal.io>
Authored: Mon Jun 20 11:22:41 2016 -0700
Committer: Anil <agingade@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);
   }


Mime
View raw message