You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by js...@apache.org on 2017/03/13 17:42:31 UTC

[04/50] [abbrv] geode git commit: GEODE-2589, GEODE-2590 lucene index region attributes should be based on data region

GEODE-2589, GEODE-2590 lucene index region attributes should be based on data region

- lucene index region now inherits recoveryDelay and startupRecoveryDelay from data region
- lucene index region now only sets diskStoreName (in RegionAttributes) when data region has persistence.


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

Branch: refs/heads/GEODE-2290
Commit: 24d02a5862851ceffa715233f245c46651776cf4
Parents: 21a9b5e
Author: Lynn Hughes-Godfrey <lh...@pivotal.io>
Authored: Fri Mar 3 13:11:53 2017 -0800
Committer: Lynn Hughes-Godfrey <lh...@pivotal.io>
Committed: Fri Mar 3 13:11:53 2017 -0800

----------------------------------------------------------------------
 .../LuceneIndexForPartitionedRegion.java        |  6 ++-
 ...IndexCreationPersistenceIntegrationTest.java | 44 +++++++++++++++++++-
 2 files changed, 48 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/24d02a58/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 f45d94d..4aa24b5 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
@@ -158,6 +158,8 @@ public class LuceneIndexForPartitionedRegion extends LuceneIndexImpl {
     attributesFactory.setTotalNumBuckets(dataRegionAttributes.getTotalNumBuckets());
     attributesFactory.setRedundantCopies(dataRegionAttributes.getRedundantCopies());
     attributesFactory.setPartitionResolver(getPartitionResolver(dataRegionAttributes));
+    attributesFactory.setRecoveryDelay(dataRegionAttributes.getRecoveryDelay());
+    attributesFactory.setStartupRecoveryDelay(dataRegionAttributes.getStartupRecoveryDelay());
     return attributesFactory;
   }
 
@@ -185,7 +187,9 @@ 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());
+    if (regionAttributes.getDataPolicy().withPersistence()) {
+      factory.setDiskStoreName(regionAttributes.getDiskStoreName());
+    }
     RegionAttributes<K, V> attributes = factory.create();
 
     return createRegion(regionName, attributes);

http://git-wip-us.apache.org/repos/asf/geode/blob/24d02a58/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneIndexCreationPersistenceIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneIndexCreationPersistenceIntegrationTest.java b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneIndexCreationPersistenceIntegrationTest.java
index 81e76f5..4b27ee6 100644
--- a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneIndexCreationPersistenceIntegrationTest.java
+++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneIndexCreationPersistenceIntegrationTest.java
@@ -31,7 +31,7 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 import org.junit.runner.RunWith;
-
+import org.apache.geode.cache.PartitionAttributesFactory;
 import org.apache.geode.cache.Region;
 import org.apache.geode.cache.RegionShortcut;
 import org.apache.geode.cache.asyncqueue.AsyncEventQueue;
@@ -69,6 +69,48 @@ public class LuceneIndexCreationPersistenceIntegrationTest extends LuceneIntegra
   }
 
   @Test
+  public void shouldInheritRecoveryDelayFromUserRegion() {
+    createIndex(cache, "text");
+
+    PartitionAttributesFactory paf = new PartitionAttributesFactory();
+    paf.setRecoveryDelay(0);
+
+    cache.createRegionFactory(RegionShortcut.PARTITION).setPartitionAttributes(paf.create())
+        .create(REGION_NAME);
+    verifyInternalRegions(region -> {
+      assertEquals(0, region.getAttributes().getPartitionAttributes().getRecoveryDelay());
+    });
+  }
+
+  @Test
+  public void shouldInheritStartupRecoveryDelayFromUserRegion() {
+    createIndex(cache, "text");
+
+    PartitionAttributesFactory paf = new PartitionAttributesFactory();
+    paf.setStartupRecoveryDelay(1);
+
+    cache.createRegionFactory(RegionShortcut.PARTITION).setPartitionAttributes(paf.create())
+        .create(REGION_NAME);
+    verifyInternalRegions(region -> {
+      assertEquals(1, region.getAttributes().getPartitionAttributes().getStartupRecoveryDelay());
+    });
+  }
+
+  @Test
+  public void shouldNotUseDiskStoreWhenUserRegionIsNotPersistent() {
+    createIndex(cache, "text");
+    String diskStoreName = "diskStore";
+    cache.createDiskStoreFactory().setDiskDirs(new File[] {diskDirRule.get()})
+        .create(diskStoreName);
+    cache.createRegionFactory(RegionShortcut.PARTITION_OVERFLOW).setDiskStoreName(diskStoreName)
+        .create(REGION_NAME);
+    verifyInternalRegions(region -> {
+      assertTrue(region.getAttributes().getDiskStoreName() == null);
+      assertTrue(region.getAttributes().getEvictionAttributes().getAction().isNone());
+    });
+  }
+
+  @Test
   @Parameters({"true", "false"})
   public void shouldUseDiskSynchronousWhenUserRegionHasDiskSynchronous(boolean synchronous) {
     createIndex(cache, "text");