You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by hi...@apache.org on 2016/06/07 19:06:57 UTC
[38/55] [abbrv] incubator-geode git commit: Geode-11: Exception
thrown when attempting to create lucene index on region with eviction
Geode-11: Exception thrown when attempting to create lucene index on region with eviction
Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/a3a721a1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/a3a721a1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/a3a721a1
Branch: refs/heads/feature/GEODE-1372
Commit: a3a721a18c6f510470de84db6ca980c303c8250a
Parents: 1aa3917
Author: Jason Huynh <hu...@gmail.com>
Authored: Wed Jun 1 10:44:32 2016 -0700
Committer: Jason Huynh <hu...@gmail.com>
Committed: Thu Jun 2 10:50:46 2016 -0700
----------------------------------------------------------------------
.../lucene/internal/LuceneServiceImpl.java | 11 +++++++++
.../LuceneIndexCreationIntegrationTest.java | 24 ++++++++++----------
2 files changed, 23 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/a3a721a1/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneServiceImpl.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneServiceImpl.java b/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneServiceImpl.java
index f9bb8ba..67edc6d 100644
--- a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneServiceImpl.java
+++ b/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/LuceneServiceImpl.java
@@ -28,6 +28,8 @@ import org.apache.lucene.analysis.standard.StandardAnalyzer;
import com.gemstone.gemfire.cache.AttributesFactory;
import com.gemstone.gemfire.cache.Cache;
+import com.gemstone.gemfire.cache.EvictionAlgorithm;
+import com.gemstone.gemfire.cache.EvictionAttributes;
import com.gemstone.gemfire.cache.Region;
import com.gemstone.gemfire.cache.RegionAttributes;
import com.gemstone.gemfire.cache.execute.FunctionService;
@@ -181,6 +183,15 @@ public class LuceneServiceImpl implements InternalLuceneService {
regionPath = dataregion.getFullPath();
LuceneIndexImpl index = null;
+
+ //For now we cannot support eviction with local destroy.
+ //Eviction with overflow to disk still needs to be supported
+ EvictionAttributes evictionAttributes = dataregion.getAttributes().getEvictionAttributes();
+ EvictionAlgorithm evictionAlgorithm = evictionAttributes.getAlgorithm();
+ if (evictionAlgorithm != EvictionAlgorithm.NONE && evictionAttributes.getAction().isLocalDestroy()) {
+ throw new UnsupportedOperationException("Lucene indexes on regions with eviction and action local destroy are not supported");
+ }
+
if (dataregion instanceof PartitionedRegion) {
// partitioned region
index = new LuceneIndexForPartitionedRegion(indexName, regionPath, cache);
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/a3a721a1/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/LuceneIndexCreationIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/LuceneIndexCreationIntegrationTest.java b/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/LuceneIndexCreationIntegrationTest.java
index d1cd8ac..dc08f69 100644
--- a/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/LuceneIndexCreationIntegrationTest.java
+++ b/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/LuceneIndexCreationIntegrationTest.java
@@ -33,11 +33,13 @@ import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
+import com.gemstone.gemfire.cache.EvictionAction;
import com.gemstone.gemfire.cache.EvictionAttributes;
import com.gemstone.gemfire.cache.ExpirationAttributes;
import com.gemstone.gemfire.cache.FixedPartitionAttributes;
import com.gemstone.gemfire.cache.PartitionAttributesFactory;
import com.gemstone.gemfire.cache.Region;
+import com.gemstone.gemfire.cache.RegionFactory;
import com.gemstone.gemfire.cache.RegionShortcut;
import com.gemstone.gemfire.cache.lucene.test.LuceneTestUtilities;
import com.gemstone.gemfire.cache.lucene.test.TestObject;
@@ -109,18 +111,6 @@ public class LuceneIndexCreationIntegrationTest extends LuceneIntegrationTest {
}
@Test
- public void shouldNotUseEvictionForInternalRegionsWhenUserRegionHasEviction() {
- createIndex("text");
- cache.createRegionFactory(RegionShortcut.PARTITION)
- .setEvictionAttributes(EvictionAttributes.createLRUEntryAttributes(1))
- .create(REGION_NAME);
-
- verifyInternalRegions(region -> {
- assertEquals(true, region.getAttributes().getEvictionAttributes().getAction().isNone());
- });
- }
-
- @Test
public void shouldNotUseIdleTimeoutForInternalRegionsWhenUserRegionHasIdleTimeout() {
createIndex("text");
cache.createRegionFactory(RegionShortcut.PARTITION)
@@ -176,6 +166,16 @@ public class LuceneIndexCreationIntegrationTest extends LuceneIntegrationTest {
this.cache.createRegionFactory(RegionShortcut.REPLICATE).create(REGION_NAME);
}
+ @Test
+ public void cannotCreateLuceneIndexForRegionWithEviction() throws IOException, ParseException {
+ expectedException.expect(UnsupportedOperationException.class);
+ expectedException.expectMessage("Lucene indexes on regions with eviction and action local destroy are not supported");
+ createIndex("field1", "field2", "field3");
+ RegionFactory regionFactory = this.cache.createRegionFactory(RegionShortcut.PARTITION);
+ regionFactory.setEvictionAttributes(EvictionAttributes.createLIFOEntryAttributes(100, EvictionAction.LOCAL_DESTROY));
+ regionFactory.create(REGION_NAME);
+ }
+
private void verifyInternalRegions(Consumer<LocalRegion> verify) {
LuceneTestUtilities.verifyInternalRegions(luceneService, cache, verify);
}