geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From upthewatersp...@apache.org
Subject geode git commit: Switching the bucket targeting map to go directly to the bucket region
Date Wed, 15 Feb 2017 01:24:47 GMT
Repository: geode
Updated Branches:
  refs/heads/feature/GEODE-2402 70d0320e9 -> 31190029b


Switching the bucket targeting map to go directly to the bucket region

With this change, operations will throw a PrimaryBucketException if the
primary has moved, rather than get forwarded to the new primary.


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

Branch: refs/heads/feature/GEODE-2402
Commit: 31190029bf3e44e188588cb45bd8a4d01ffca95d
Parents: 70d0320
Author: Dan Smith <upthewaterspout@apache.org>
Authored: Tue Feb 14 17:21:44 2017 -0800
Committer: Dan Smith <upthewaterspout@apache.org>
Committed: Tue Feb 14 17:21:44 2017 -0800

----------------------------------------------------------------------
 .../geode/cache/lucene/internal/IndexRepositoryFactory.java   | 6 +++---
 .../cache/lucene/internal/partition/BucketTargetingMap.java   | 5 +++--
 .../internal/PartitionedRepositoryManagerJUnitTest.java       | 6 ++++--
 .../lucene/internal/partition/BucketTargetingMapTest.java     | 7 +++----
 4 files changed, 13 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/31190029/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/IndexRepositoryFactory.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/IndexRepositoryFactory.java
b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/IndexRepositoryFactory.java
index b5ab942..6861c96 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/IndexRepositoryFactory.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/IndexRepositoryFactory.java
@@ -80,8 +80,8 @@ public class IndexRepositoryFactory {
 
     final IndexRepository repo;
     try {
-      RegionDirectory dir = new RegionDirectory(getBucketTargetingMap(fileRegion, bucketId),
-          getBucketTargetingMap(chunkRegion, bucketId), indexForPR.getFileSystemStats());
+      RegionDirectory dir = new RegionDirectory(getBucketTargetingMap(fileBucket, bucketId),
+          getBucketTargetingMap(chunkBucket, bucketId), indexForPR.getFileSystemStats());
       IndexWriterConfig config = new IndexWriterConfig(indexForPR.getAnalyzer());
       IndexWriter writer = new IndexWriter(dir, config);
       repo = new IndexRepositoryImpl(fileBucket, writer, serializer, indexForPR.getIndexStats(),
@@ -100,7 +100,7 @@ public class IndexRepositoryFactory {
 
   }
 
-  private Map getBucketTargetingMap(PartitionedRegion region, int bucketId) {
+  private Map getBucketTargetingMap(BucketRegion region, int bucketId) {
     return new BucketTargetingMap(region, bucketId);
   }
 

http://git-wip-us.apache.org/repos/asf/geode/blob/31190029/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/partition/BucketTargetingMap.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/partition/BucketTargetingMap.java
b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/partition/BucketTargetingMap.java
index e2467ac..19fb4dc 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/partition/BucketTargetingMap.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/partition/BucketTargetingMap.java
@@ -17,6 +17,7 @@ package org.apache.geode.cache.lucene.internal.partition;
 import org.apache.geode.cache.EntryExistsException;
 import org.apache.geode.cache.EntryNotFoundException;
 import org.apache.geode.cache.Region;
+import org.apache.geode.internal.cache.BucketRegion;
 import org.apache.geode.internal.cache.LocalDataSet;
 import org.apache.geode.internal.cache.PartitionedRegion;
 
@@ -29,9 +30,9 @@ public class BucketTargetingMap<K, V> extends AbstractMap<K, V>
{
   private final Region<K, V> region;
   public Object callbackArg;
 
-  public BucketTargetingMap(PartitionedRegion region, int bucketId) {
+  public BucketTargetingMap(BucketRegion region, int bucketId) {
     this.callbackArg = bucketId;
-    this.region = new LocalDataSet(region, Collections.singleton(bucketId));
+    this.region = region;
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/geode/blob/31190029/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/PartitionedRepositoryManagerJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/PartitionedRepositoryManagerJUnitTest.java
b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/PartitionedRepositoryManagerJUnitTest.java
index bb8e0b4..df0b62c 100644
--- a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/PartitionedRepositoryManagerJUnitTest.java
+++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/PartitionedRepositoryManagerJUnitTest.java
@@ -241,9 +241,9 @@ public class PartitionedRepositoryManagerJUnitTest {
   protected void checkRepository(IndexRepositoryImpl repo0, int bucketId) {
     IndexWriter writer0 = repo0.getWriter();
     RegionDirectory dir0 = (RegionDirectory) writer0.getDirectory();
-    assertEquals(new BucketTargetingMap(fileRegion, bucketId),
+    assertEquals(new BucketTargetingMap(fileBuckets.get(bucketId), bucketId),
         dir0.getFileSystem().getFileRegion());
-    assertEquals(new BucketTargetingMap(chunkRegion, bucketId),
+    assertEquals(new BucketTargetingMap(chunkBuckets.get(bucketId), bucketId),
         dir0.getFileSystem().getChunkRegion());
     assertEquals(serializer, repo0.getSerializer());
   }
@@ -253,7 +253,9 @@ public class PartitionedRepositoryManagerJUnitTest {
     BucketRegion fileBucket = Mockito.mock(BucketRegion.class);
     // Allowing the fileBucket to behave like a map so that the IndexWriter operations don't
fail
     Fakes.addMapBehavior(fileBucket);
+    when(fileBucket.getFullPath()).thenReturn("File" + id);
     BucketRegion chunkBucket = Mockito.mock(BucketRegion.class);
+    when(chunkBucket.getFullPath()).thenReturn("Chunk" + id);
     when(mockBucket.getId()).thenReturn(id);
     when(userRegion.getBucketRegion(eq(id), eq(null))).thenReturn(mockBucket);
     when(userDataStore.getLocalBucketById(eq(id))).thenReturn(mockBucket);

http://git-wip-us.apache.org/repos/asf/geode/blob/31190029/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/partition/BucketTargetingMapTest.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/partition/BucketTargetingMapTest.java
b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/partition/BucketTargetingMapTest.java
index 468fd04..8850f45 100644
--- a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/partition/BucketTargetingMapTest.java
+++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/partition/BucketTargetingMapTest.java
@@ -21,6 +21,7 @@ import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
+import org.apache.geode.internal.cache.BucketRegion;
 import org.apache.geode.internal.cache.PartitionedRegion;
 import org.apache.geode.test.junit.categories.IntegrationTest;
 import org.apache.geode.test.junit.categories.UnitTest;
@@ -32,14 +33,12 @@ import org.mockito.Mock;
 @Category(UnitTest.class)
 public class BucketTargetingMapTest {
 
-  private PartitionedRegion region;
+  private BucketRegion region;
 
   @Before
   public void initMocks() {
-    region = mock(PartitionedRegion.class);
+    region = mock(BucketRegion.class);
     final BucketTargetingResolver resolver = new BucketTargetingResolver();
-    when(region.getPartitionResolver()).thenReturn(resolver);
-    when(region.getTotalNumberOfBuckets()).thenReturn(5);
   }
 
   @Test


Mime
View raw message