geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kl...@apache.org
Subject [30/45] geode git commit: GEODE-2280: Allow accessors to create a lucene index
Date Wed, 11 Jan 2017 00:00:30 GMT
GEODE-2280: Allow accessors to create a lucene index

Allow peer accessors to create a lucene index and fixing the dunit tests
to actually use an accessor.


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

Branch: refs/heads/feature/GEODE-1930-2
Commit: 40c828ac81a9260794da4ed073517327df2d79b2
Parents: 262e6ee
Author: Dan Smith <upthewaterspout@apache.org>
Authored: Fri Jan 6 11:29:10 2017 -0800
Committer: Dan Smith <upthewaterspout@apache.org>
Committed: Mon Jan 9 17:28:24 2017 -0800

----------------------------------------------------------------------
 .../LuceneIndexForPartitionedRegion.java        |  6 ++--
 .../geode/cache/lucene/LuceneQueriesPRBase.java | 11 +++----
 .../lucene/LuceneQueriesPeerPRDUnitTest.java    |  4 +--
 .../LuceneQueriesPeerPROverflowDUnitTest.java   |  2 +-
 .../LuceneQueriesPeerPRRedundancyDUnitTest.java |  5 ++-
 .../LuceneIndexForPartitionedRegionTest.java    | 34 ++++++++------------
 6 files changed, 25 insertions(+), 37 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/40c828ac/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneIndexForPartitionedRegion.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneIndexForPartitionedRegion.java
b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneIndexForPartitionedRegion.java
index f8bbc41..c760726 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneIndexForPartitionedRegion.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneIndexForPartitionedRegion.java
@@ -60,10 +60,8 @@ public class LuceneIndexForPartitionedRegion extends LuceneIndexImpl {
     // 3) Replicate to Replicate, Partition To Partition
     // 4) Offheap to Offheap
     if (!withStorage) {
-      throw new IllegalStateException(
-          "The data region to create lucene index should be with storage");
-    }
-    if (withPersistence) {
+      regionShortCut = RegionShortcut.PARTITION_PROXY;
+    } else if (withPersistence) {
       // TODO: add PartitionedRegionAttributes instead
       regionShortCut = RegionShortcut.PARTITION_PERSISTENT;
     } else {

http://git-wip-us.apache.org/repos/asf/geode/blob/40c828ac/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneQueriesPRBase.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneQueriesPRBase.java
b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneQueriesPRBase.java
index 8e62c85..1e965da 100644
--- a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneQueriesPRBase.java
+++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneQueriesPRBase.java
@@ -32,11 +32,6 @@ import org.apache.geode.cache.Region;
 import org.apache.geode.cache.control.RebalanceOperation;
 import org.apache.geode.cache.control.RebalanceResults;
 import org.apache.geode.cache.lucene.test.IndexRepositorySpy;
-import org.apache.geode.cache.lucene.internal.IndexRepositoryFactory;
-import org.apache.geode.cache.lucene.internal.LuceneIndexImpl;
-import org.apache.geode.cache.lucene.internal.PartitionedRepositoryManager;
-import org.apache.geode.cache.lucene.internal.repository.IndexRepository;
-import org.apache.geode.cache.lucene.internal.repository.serializer.LuceneSerializer;
 import org.apache.geode.cache.lucene.test.LuceneTestUtilities;
 import org.apache.geode.cache.partition.PartitionRegionHelper;
 import org.apache.geode.distributed.DistributedMember;
@@ -127,9 +122,11 @@ public abstract class LuceneQueriesPRBase extends LuceneQueriesBase {
     executeTextSearch(accessor, "world", "text", NUM_BUCKETS);
   }
 
-  protected PartitionAttributes getPartitionAttributes() {
+  protected PartitionAttributes getPartitionAttributes(final boolean isAccessor) {
     PartitionAttributesFactory factory = new PartitionAttributesFactory();
-    factory.setLocalMaxMemory(100);
+    if (!isAccessor) {
+      factory.setLocalMaxMemory(100);
+    }
     factory.setTotalNumBuckets(NUM_BUCKETS);
     return factory.create();
   }

http://git-wip-us.apache.org/repos/asf/geode/blob/40c828ac/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneQueriesPeerPRDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneQueriesPeerPRDUnitTest.java
b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneQueriesPeerPRDUnitTest.java
index ffab354..f65777f 100644
--- a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneQueriesPeerPRDUnitTest.java
+++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneQueriesPeerPRDUnitTest.java
@@ -29,13 +29,13 @@ public class LuceneQueriesPeerPRDUnitTest extends LuceneQueriesPRBase
{
   protected void initDataStore(final SerializableRunnableIF createIndex) throws Exception
{
     createIndex.run();
     getCache().createRegionFactory(RegionShortcut.PARTITION)
-        .setPartitionAttributes(getPartitionAttributes()).create(REGION_NAME);
+        .setPartitionAttributes(getPartitionAttributes(false)).create(REGION_NAME);
   }
 
   @Override
   protected void initAccessor(final SerializableRunnableIF createIndex) throws Exception
{
     createIndex.run();
     getCache().createRegionFactory(RegionShortcut.PARTITION_PROXY)
-        .setPartitionAttributes(getPartitionAttributes()).create(REGION_NAME);
+        .setPartitionAttributes(getPartitionAttributes(true)).create(REGION_NAME);
   }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/40c828ac/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneQueriesPeerPROverflowDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneQueriesPeerPROverflowDUnitTest.java
b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneQueriesPeerPROverflowDUnitTest.java
index b9aa0b7..254156f 100644
--- a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneQueriesPeerPROverflowDUnitTest.java
+++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneQueriesPeerPROverflowDUnitTest.java
@@ -33,7 +33,7 @@ public class LuceneQueriesPeerPROverflowDUnitTest extends LuceneQueriesPRBase
{
     EvictionAttributes evicAttr =
         EvictionAttributes.createLRUEntryAttributes(1, EvictionAction.OVERFLOW_TO_DISK);
     getCache().createRegionFactory(RegionShortcut.PARTITION_OVERFLOW)
-        .setPartitionAttributes(getPartitionAttributes()).setEvictionAttributes(evicAttr)
+        .setPartitionAttributes(getPartitionAttributes(false)).setEvictionAttributes(evicAttr)
         .create(REGION_NAME);
   }
 

http://git-wip-us.apache.org/repos/asf/geode/blob/40c828ac/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneQueriesPeerPRRedundancyDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneQueriesPeerPRRedundancyDUnitTest.java
b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneQueriesPeerPRRedundancyDUnitTest.java
index d645d5e..59c14a2 100644
--- a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneQueriesPeerPRRedundancyDUnitTest.java
+++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneQueriesPeerPRRedundancyDUnitTest.java
@@ -19,7 +19,6 @@ import static org.apache.geode.cache.lucene.test.LuceneTestUtilities.*;
 import static org.junit.Assert.*;
 
 import java.util.concurrent.TimeUnit;
-import java.util.function.Consumer;
 
 import org.apache.geode.cache.Region;
 import org.apache.geode.cache.RegionShortcut;
@@ -48,14 +47,14 @@ public class LuceneQueriesPeerPRRedundancyDUnitTest extends LuceneQueriesPRBase
   protected void initDataStore(final SerializableRunnableIF createIndex) throws Exception
{
     createIndex.run();
     Region region = getCache().createRegionFactory(RegionShortcut.PARTITION_REDUNDANT)
-        .setPartitionAttributes(getPartitionAttributes()).create(REGION_NAME);
+        .setPartitionAttributes(getPartitionAttributes(false)).create(REGION_NAME);
   }
 
   @Override
   protected void initAccessor(final SerializableRunnableIF createIndex) throws Exception
{
     createIndex.run();
     Region region = getCache().createRegionFactory(RegionShortcut.PARTITION_PROXY_REDUNDANT)
-        .setPartitionAttributes(getPartitionAttributes()).create(REGION_NAME);
+        .setPartitionAttributes(getPartitionAttributes(true)).create(REGION_NAME);
   }
 
   @Test

http://git-wip-us.apache.org/repos/asf/geode/blob/40c828ac/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/LuceneIndexForPartitionedRegionTest.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/LuceneIndexForPartitionedRegionTest.java
b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/LuceneIndexForPartitionedRegionTest.java
index cec3734..5c0c0a0 100644
--- a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/LuceneIndexForPartitionedRegionTest.java
+++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/LuceneIndexForPartitionedRegionTest.java
@@ -213,18 +213,16 @@ public class LuceneIndexForPartitionedRegionTest {
   }
 
   @Test
-  public void initializeWithNoLocalMemoryThrowsException() {
-    expectedExceptions.expect(IllegalStateException.class);
-    expectedExceptions
-        .expectMessage("The data region to create lucene index should be with storage");
+  public void initializeWithNoLocalMemoryShouldSucceed() {
     boolean withPersistence = false;
     String name = "indexName";
     String regionPath = "regionName";
     Cache cache = Fakes.cache();
-    initializeScenario(withPersistence, regionPath, cache, 0);
+    Region region = initializeScenario(withPersistence, regionPath, cache, 0);
     LuceneIndexForPartitionedRegion index =
         new LuceneIndexForPartitionedRegion(name, regionPath, cache);
-    index.initialize();
+    LuceneIndexForPartitionedRegion spy = setupSpy(region, index);
+    spy.initialize();
   }
 
   @Test
@@ -237,14 +235,20 @@ public class LuceneIndexForPartitionedRegionTest {
 
     LuceneIndexForPartitionedRegion index =
         new LuceneIndexForPartitionedRegion(name, regionPath, cache);
+    LuceneIndexForPartitionedRegion spy = setupSpy(region, index);
+
+    verify(spy).createAEQ(eq(region));
+  }
+
+  protected LuceneIndexForPartitionedRegion setupSpy(final Region region,
+      final LuceneIndexForPartitionedRegion index) {
     index.setSearchableFields(new String[] {"field"});
     LuceneIndexForPartitionedRegion spy = spy(index);
     doReturn(null).when(spy).createFileRegion(any(), any(), any(), any());
     doReturn(null).when(spy).createChunkRegion(any(), any(), any(), any(), any());
     doReturn(null).when(spy).createAEQ(eq(region));
     spy.initialize();
-
-    verify(spy).createAEQ(eq(region));
+    return spy;
   }
 
   @Test
@@ -257,12 +261,7 @@ public class LuceneIndexForPartitionedRegionTest {
 
     LuceneIndexForPartitionedRegion index =
         new LuceneIndexForPartitionedRegion(name, regionPath, cache);
-    index.setSearchableFields(new String[] {"field"});
-    LuceneIndexForPartitionedRegion spy = spy(index);
-    doReturn(null).when(spy).createFileRegion(any(), any(), any(), any());
-    doReturn(null).when(spy).createChunkRegion(any(), any(), any(), any(), any());
-    doReturn(null).when(spy).createAEQ(eq(region));
-    spy.initialize();
+    LuceneIndexForPartitionedRegion spy = setupSpy(region, index);
 
     verify(spy).createChunkRegion(eq(RegionShortcut.PARTITION), eq(index.createFileRegionName()),
         any(), eq(index.createChunkRegionName()), any());
@@ -278,12 +277,7 @@ public class LuceneIndexForPartitionedRegionTest {
 
     LuceneIndexForPartitionedRegion index =
         new LuceneIndexForPartitionedRegion(name, regionPath, cache);
-    index.setSearchableFields(new String[] {"field"});
-    LuceneIndexForPartitionedRegion spy = spy(index);
-    doReturn(null).when(spy).createFileRegion(any(), any(), any(), any());
-    doReturn(null).when(spy).createChunkRegion(any(), any(), any(), any(), any());
-    doReturn(null).when(spy).createAEQ(eq(region));
-    spy.initialize();
+    LuceneIndexForPartitionedRegion spy = setupSpy(region, index);
 
     verify(spy).createFileRegion(eq(RegionShortcut.PARTITION), eq(index.createFileRegionName()),
         any(), any());


Mime
View raw message