geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jinmeil...@apache.org
Subject [09/32] incubator-geode git commit: GEODE-11: Index and AEQ stored in the same disk store as the region
Date Tue, 05 Jul 2016 23:15:32 GMT
GEODE-11: Index and AEQ stored in the same disk store as the region

The index and AEQ were stored in the default disk store. Changed the code to set the RegionAtrributes
of
the index and AEQ to use the same Disk Store Name as the region. Added a test to verify the
disk store name.

Signed-off-by: Dan Smith <dsmith@pivotal.io>

This closes #177


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

Branch: refs/heads/feature/GEODE-1571
Commit: 6a9a83c01f42271f3208ce50224b8e4a5d3ddb8b
Parents: f8f9454
Author: Aparna Dharmakkan <adharmakkan@pivotal.io>
Authored: Tue Jun 28 18:10:40 2016 -0700
Committer: Dan Smith <upthewaterspout@apache.org>
Committed: Fri Jul 1 11:46:40 2016 -0700

----------------------------------------------------------------------
 .../LuceneIndexForPartitionedRegion.java        | 31 ++++++++------
 ...IndexCreationPersistenceIntegrationTest.java | 17 ++++++++
 .../LuceneIndexForPartitionedRegionTest.java    | 44 ++++++++++----------
 3 files changed, 58 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/6a9a83c0/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 891a658..af05e7d 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
@@ -51,10 +51,10 @@ public class LuceneIndexForPartitionedRegion extends LuceneIndexImpl {
       /* create index region */
       PartitionedRegion dataRegion = getDataRegion();
       //assert dataRegion != null;
-      RegionAttributes ra = dataRegion.getAttributes();
-      DataPolicy dp = ra.getDataPolicy();
+      RegionAttributes regionAttributes = dataRegion.getAttributes();
+      DataPolicy dp = regionAttributes.getDataPolicy();
       final boolean withPersistence = dp.withPersistence();
-      final boolean withStorage = ra.getPartitionAttributes().getLocalMaxMemory()>0;
+      final boolean withStorage = regionAttributes.getPartitionAttributes().getLocalMaxMemory()>0;
       RegionShortcut regionShortCut;
       if (withPersistence) {
         // TODO: add PartitionedRegionAttributes instead
@@ -63,8 +63,6 @@ public class LuceneIndexForPartitionedRegion extends LuceneIndexImpl {
         regionShortCut = RegionShortcut.PARTITION;
       }
 
-      // final boolean isOffHeap = ra.getOffHeap();
-
       // TODO: 1) dataRegion should be withStorage
       //       2) Persistence to Persistence
       //       3) Replicate to Replicate, Partition To Partition
@@ -77,13 +75,13 @@ public class LuceneIndexForPartitionedRegion extends LuceneIndexImpl {
       final String fileRegionName = createFileRegionName();
       PartitionAttributes partitionAttributes = dataRegion.getPartitionAttributes();
       if (!fileRegionExists(fileRegionName)) {
-        fileRegion = createFileRegion(regionShortCut, fileRegionName, partitionAttributes);
+        fileRegion = createFileRegion(regionShortCut, fileRegionName, partitionAttributes,
regionAttributes);
       }
 
       // create PR chunkRegion, but not to create its buckets for now
       final String chunkRegionName = createChunkRegionName();
       if (!chunkRegionExists(chunkRegionName)) {
-        chunkRegion = createChunkRegion(regionShortCut, fileRegionName, partitionAttributes,
chunkRegionName);
+        chunkRegion = createChunkRegion(regionShortCut, fileRegionName, partitionAttributes,
chunkRegionName, regionAttributes);
       }
       fileSystemStats.setFileSupplier(() -> (int) getFileRegion().getLocalSize());
       fileSystemStats.setChunkSupplier(() -> (int) getChunkRegion().getLocalSize());
@@ -123,6 +121,7 @@ public class LuceneIndexForPartitionedRegion extends LuceneIndexImpl {
     if(dataRegion.getAttributes().getDataPolicy().withPersistence()) {
       factory.setPersistent(true);
     }
+    factory.setDiskStoreName(dataRegion.getAttributes().getDiskStoreName());
     factory.setDiskSynchronous(dataRegion.getAttributes().isDiskSynchronous());
     factory.setForwardExpirationDestroy(true);
     return factory;
@@ -145,8 +144,9 @@ public class LuceneIndexForPartitionedRegion extends LuceneIndexImpl {
 
   Region createFileRegion(final RegionShortcut regionShortCut,
                                 final String fileRegionName,
-                                final PartitionAttributes partitionAttributes) {
-    return createRegion(fileRegionName, regionShortCut, this.regionPath, partitionAttributes);
+                                final PartitionAttributes partitionAttributes,
+                                final RegionAttributes regionAttributes) {
+    return createRegion(fileRegionName, regionShortCut, this.regionPath, partitionAttributes,
regionAttributes);
   }
 
   public String createFileRegionName() {
@@ -159,8 +159,8 @@ public class LuceneIndexForPartitionedRegion extends LuceneIndexImpl {
 
   Region<ChunkKey, byte[]> createChunkRegion(final RegionShortcut regionShortCut,
                            final String fileRegionName,
-                           final PartitionAttributes partitionAttributes, final String chunkRegionName)
{
-    return createRegion(chunkRegionName, regionShortCut, fileRegionName, partitionAttributes);
+                           final PartitionAttributes partitionAttributes, final String chunkRegionName,
final RegionAttributes regionAttributes) {
+    return createRegion(chunkRegionName, regionShortCut, fileRegionName, partitionAttributes,
regionAttributes);
   }
 
   public String createChunkRegionName() {
@@ -173,8 +173,12 @@ public class LuceneIndexForPartitionedRegion extends LuceneIndexImpl
{
     return attributesFactory;
   }
 
-  protected <K, V> Region<K, V> createRegion(final String regionName, final RegionShortcut
regionShortCut,
-      final String colocatedWithRegionName, final PartitionAttributes partitionAttributes)
{
+  protected <K, V> Region<K, V> createRegion(final String regionName,
+                                             final RegionShortcut regionShortCut,
+                                             final String colocatedWithRegionName,
+                                             final PartitionAttributes partitionAttributes,
+                                             final RegionAttributes regionAttributes)
+  {
     PartitionAttributesFactory partitionAttributesFactory = new PartitionAttributesFactory<String,
File>();
     partitionAttributesFactory.setColocatedWith(colocatedWithRegionName);
     configureLuceneRegionAttributesFactory(partitionAttributesFactory, partitionAttributes);
@@ -183,6 +187,7 @@ public class LuceneIndexForPartitionedRegion extends LuceneIndexImpl {
     RegionAttributes baseAttributes = this.cache.getRegionAttributes(regionShortCut.toString());
     AttributesFactory factory = new AttributesFactory(baseAttributes);
     factory.setPartitionAttributes(partitionAttributesFactory.create());
+    factory.setDiskStoreName(regionAttributes.getDiskStoreName());
     RegionAttributes<K, V> attributes = factory.create();
 
     return createRegion(regionName, attributes);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/6a9a83c0/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/LuceneIndexCreationPersistenceIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/LuceneIndexCreationPersistenceIntegrationTest.java
b/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/LuceneIndexCreationPersistenceIntegrationTest.java
index f2fd67c..f121694 100644
--- a/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/LuceneIndexCreationPersistenceIntegrationTest.java
+++ b/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/LuceneIndexCreationPersistenceIntegrationTest.java
@@ -159,6 +159,23 @@ public class LuceneIndexCreationPersistenceIntegrationTest extends LuceneIntegra
     });
   }
 
+  @Test
+  public void shouldStoreIndexAndQueueInTheSameDiskStoreAsTheRegion() {
+    createIndex(cache, "text");
+    cache.createDiskStoreFactory()
+      .setDiskDirs(new File[] {diskDirRule.get()})
+      .create("DiskStore");
+    cache.createRegionFactory(RegionShortcut.PARTITION_PERSISTENT)
+      .setDiskStoreName("DiskStore")
+      .create(REGION_NAME);
+    final String diskStoreName = cache.getRegion(REGION_NAME).getAttributes().getDiskStoreName();
+    verifyInternalRegions(region -> {
+      assertEquals(diskStoreName, region.getAttributes().getDiskStoreName());
+    });
+    AsyncEventQueue queue = getIndexQueue(cache);
+    assertEquals(diskStoreName, queue.getDiskStoreName());
+  }
+
   private void verifyQueryResultSize(String indexName, String regionName, String queryString,
String defaultField, int size) throws Exception {
     LuceneQuery query = luceneService.createLuceneQueryFactory().create(indexName, regionName,
queryString, defaultField);
     Awaitility.await().atMost(60, TimeUnit.SECONDS).until(() -> {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/6a9a83c0/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIndexForPartitionedRegionTest.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIndexForPartitionedRegionTest.java
b/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIndexForPartitionedRegionTest.java
index 394a2bf..6f38ff4 100644
--- a/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIndexForPartitionedRegionTest.java
+++ b/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/LuceneIndexForPartitionedRegionTest.java
@@ -214,8 +214,8 @@ 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());
-    doReturn(null).when(spy).createChunkRegion(any(), any(), any(), any());
+    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();
 
@@ -233,12 +233,12 @@ 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());
-    doReturn(null).when(spy).createChunkRegion(any(), any(), any(), any());
+    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).createChunkRegion(eq(RegionShortcut.PARTITION), eq(index.createFileRegionName()),
any(), eq(index.createChunkRegionName()));
+    verify(spy).createChunkRegion(eq(RegionShortcut.PARTITION), eq(index.createFileRegionName()),
any(), eq(index.createChunkRegionName()),any());
   }
 
   @Test
@@ -252,12 +252,12 @@ 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());
-    doReturn(null).when(spy).createChunkRegion(any(), any(), any(), any());
+    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).createFileRegion(eq(RegionShortcut.PARTITION), eq(index.createFileRegionName()),
any());
+    verify(spy).createFileRegion(eq(RegionShortcut.PARTITION), eq(index.createFileRegionName()),
any(),any());
   }
 
   @Test
@@ -265,12 +265,13 @@ public class LuceneIndexForPartitionedRegionTest {
     String name = "indexName";
     String regionPath = "regionName";
     GemFireCacheImpl cache = Fakes.cache();
+    RegionAttributes regionAttributes = mock(RegionAttributes.class);
     PartitionAttributes partitionAttributes = initializeAttributes(cache);
     LuceneIndexForPartitionedRegion index = new LuceneIndexForPartitionedRegion(name, regionPath,
cache);
     LuceneIndexForPartitionedRegion indexSpy = spy(index);
-    indexSpy.createFileRegion(RegionShortcut.PARTITION, index.createFileRegionName(), partitionAttributes);
+    indexSpy.createFileRegion(RegionShortcut.PARTITION, index.createFileRegionName(), partitionAttributes,
regionAttributes);
     String fileRegionName = index.createFileRegionName();
-    verify(indexSpy).createRegion(fileRegionName, RegionShortcut.PARTITION, regionPath, partitionAttributes);
+    verify(indexSpy).createRegion(fileRegionName, RegionShortcut.PARTITION, regionPath, partitionAttributes,
regionAttributes);
     verify(cache).createVMRegion(eq(fileRegionName), any(), any());
   }
 
@@ -280,12 +281,13 @@ public class LuceneIndexForPartitionedRegionTest {
     String regionPath = "regionName";
     GemFireCacheImpl cache = Fakes.cache();
     PartitionAttributes partitionAttributes = initializeAttributes(cache);
+    RegionAttributes regionAttributes = mock(RegionAttributes.class);
     LuceneIndexForPartitionedRegion index = new LuceneIndexForPartitionedRegion(name, regionPath,
cache);
     LuceneIndexForPartitionedRegion indexSpy = spy(index);
     String chunkRegionName = index.createChunkRegionName();
     String fileRegionName = index.createFileRegionName();
-    indexSpy.createChunkRegion(RegionShortcut.PARTITION, fileRegionName, partitionAttributes,
chunkRegionName);
-    verify(indexSpy).createRegion(chunkRegionName, RegionShortcut.PARTITION, fileRegionName,
partitionAttributes);
+    indexSpy.createChunkRegion(RegionShortcut.PARTITION, fileRegionName, partitionAttributes,
chunkRegionName, regionAttributes);
+    verify(indexSpy).createRegion(chunkRegionName, RegionShortcut.PARTITION, fileRegionName,
partitionAttributes, regionAttributes);
     verify(cache).createVMRegion(eq(chunkRegionName), any(), any());
   }
 
@@ -300,12 +302,12 @@ 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());
-    doReturn(null).when(spy).createChunkRegion(any(), any(), any(), any());
+    doReturn(null).when(spy).createFileRegion(any(), any(), any(), any());
+    doReturn(null).when(spy).createChunkRegion(any(), any(), any(), any(), any());
     doReturn(null).when(spy).createAEQ(any());
     spy.initialize();
 
-    verify(spy).createChunkRegion(eq(RegionShortcut.PARTITION_PERSISTENT), eq(index.createFileRegionName()),
any(), eq(index.createChunkRegionName()));
+    verify(spy).createChunkRegion(eq(RegionShortcut.PARTITION_PERSISTENT), eq(index.createFileRegionName()),
any(), eq(index.createChunkRegionName()), any());
   }
 
   @Test
@@ -319,12 +321,12 @@ 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());
-    doReturn(null).when(spy).createChunkRegion(any(), any(), any(), any());
+    doReturn(null).when(spy).createFileRegion(any(), any(), any(), any());
+    doReturn(null).when(spy).createChunkRegion(any(), any(), any(), any(), any());
     doReturn(null).when(spy).createAEQ(any());
     spy.initialize();
 
-    verify(spy).createFileRegion(eq(RegionShortcut.PARTITION_PERSISTENT), eq(index.createFileRegionName()),
any());
+    verify(spy).createFileRegion(eq(RegionShortcut.PARTITION_PERSISTENT), eq(index.createFileRegionName()),
any(), any());
   }
 
   @Test
@@ -338,13 +340,13 @@ 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());
-    doReturn(null).when(spy).createChunkRegion(any(), any(), any(), any());
+    doReturn(null).when(spy).createFileRegion(any(), any(), any(), any());
+    doReturn(null).when(spy).createChunkRegion(any(), any(), any(), any(), any());
     doReturn(null).when(spy).createAEQ(any());
     spy.initialize();
     spy.initialize();
 
-    verify(spy).createFileRegion(eq(RegionShortcut.PARTITION_PERSISTENT), eq(index.createFileRegionName()),
any());
+    verify(spy).createFileRegion(eq(RegionShortcut.PARTITION_PERSISTENT), eq(index.createFileRegionName()),
any(), any());
   }
 
   @Test


Mime
View raw message