geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From upthewatersp...@apache.org
Subject incubator-geode git commit: Creating missing buckets in PartitionRepositoryManager
Date Wed, 23 Sep 2015 16:21:04 GMT
Repository: incubator-geode
Updated Branches:
  refs/heads/feature/GEODE-11 3f0c0696e -> c80e93b95


Creating missing buckets in PartitionRepositoryManager

Creating the colocated buckets if they do not yet exist in
PartitionedRepositoryManager.


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

Branch: refs/heads/feature/GEODE-11
Commit: c80e93b95f81151c8db6bb2ccf17ef2d6ab69ab0
Parents: 3f0c069
Author: Dan Smith <upthewaterspout@apache.org>
Authored: Tue Sep 22 17:07:21 2015 -0700
Committer: Dan Smith <upthewaterspout@apache.org>
Committed: Wed Sep 23 09:14:24 2015 -0700

----------------------------------------------------------------------
 .../internal/PartitionedRepositoryManager.java  |  3 +++
 .../PartitionedRepositoryManagerJUnitTest.java  | 21 ++++++++++++++++++++
 2 files changed, 24 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c80e93b9/gemfire-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/PartitionedRepositoryManager.java
----------------------------------------------------------------------
diff --git a/gemfire-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/PartitionedRepositoryManager.java
b/gemfire-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/PartitionedRepositoryManager.java
index bcec1c9..65c678c 100644
--- a/gemfire-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/PartitionedRepositoryManager.java
+++ b/gemfire-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/PartitionedRepositoryManager.java
@@ -133,6 +133,9 @@ public class PartitionedRepositoryManager implements RepositoryManager
{
    * Find the bucket in region2 that matches the bucket id from region1.
    */
   private BucketRegion getMatchingBucket(PartitionedRegion region, Integer bucketId) throws
BucketNotFoundException {
+    //Force the bucket to be created if it is not already
+    region.getOrCreateNodeForBucketWrite(bucketId, null);
+    
     BucketRegion result = region.getDataStore().getLocalBucketById(bucketId);
     if(result == null) {
       throw new BucketNotFoundException("Bucket not found for region " + region + " bucekt
id " + bucketId);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c80e93b9/gemfire-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/PartitionedRepositoryManagerJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/PartitionedRepositoryManagerJUnitTest.java
b/gemfire-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/PartitionedRepositoryManagerJUnitTest.java
index 367f4f2..a2cc75e 100644
--- a/gemfire-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/PartitionedRepositoryManagerJUnitTest.java
+++ b/gemfire-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/PartitionedRepositoryManagerJUnitTest.java
@@ -18,6 +18,8 @@ import org.junit.Before;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 import org.mockito.Mockito;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.stubbing.Answer;
 
 import com.gemstone.gemfire.cache.lucene.internal.directory.RegionDirectory;
 import com.gemstone.gemfire.cache.lucene.internal.repository.IndexRepository;
@@ -28,6 +30,7 @@ import com.gemstone.gemfire.internal.cache.BucketNotFoundException;
 import com.gemstone.gemfire.internal.cache.BucketRegion;
 import com.gemstone.gemfire.internal.cache.LocalDataSet;
 import com.gemstone.gemfire.internal.cache.PartitionedRegion;
+import com.gemstone.gemfire.internal.cache.PartitionedRegion.RetryTimeKeeper;
 import com.gemstone.gemfire.internal.cache.PartitionedRegionDataStore;
 import com.gemstone.gemfire.test.junit.categories.UnitTest;
 
@@ -118,6 +121,24 @@ public class PartitionedRepositoryManagerJUnitTest {
   }
   
   @Test
+  public void createMissingBucket() throws BucketNotFoundException {
+    PartitionedRepositoryManager repoManager = new PartitionedRepositoryManager(userRegion,
fileRegion, chunkRegion, serializer, new StandardAnalyzer());
+    BucketRegion mockBucket0 = getMockBucket(0);
+    
+    Mockito.when(fileDataStore.getLocalBucketById(eq(0))).thenReturn(null);
+    
+    Mockito.when(fileRegion.getOrCreateNodeForBucketWrite(eq(0), (RetryTimeKeeper) any())).then(new
Answer() {
+      @Override
+      public Object answer(InvocationOnMock invocation) throws Throwable {
+        Mockito.when(fileDataStore.getLocalBucketById(eq(0))).thenReturn(fileBuckets.get(0));
+        return null;
+      }
+    });
+    
+    assertNotNull(repoManager.getRepository(userRegion, 0, null));
+  }
+  
+  @Test
   public void getByRegion() throws BucketNotFoundException {
 
     PartitionedRepositoryManager repoManager = new PartitionedRepositoryManager(userRegion,
fileRegion, chunkRegion, serializer, new StandardAnalyzer());


Mime
View raw message