You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by ja...@apache.org on 2018/03/08 22:52:42 UTC

[geode] branch develop updated: GEODE-4778: Code clean up and refactor (#1553)

This is an automated email from the ASF dual-hosted git repository.

jasonhuynh pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git


The following commit(s) were added to refs/heads/develop by this push:
     new eaeb8d0  GEODE-4778: Code clean up and refactor (#1553)
eaeb8d0 is described below

commit eaeb8d09a848b8344a76095ea2f5caeeea8bfd3d
Author: Jason Huynh <hu...@gmail.com>
AuthorDate: Thu Mar 8 14:52:39 2018 -0800

    GEODE-4778: Code clean up and refactor (#1553)
    
    * code clean up
    * Removed unused aeq lookup
    * Removed/collapsed AbstractRepositoryManager
    * Reduced references to LuceneIndexImpl into InternalLuceneIndex
---
 .../AbstractPartitionedRepositoryManager.java      | 156 ---------------------
 .../lucene/internal/IndexRepositoryFactory.java    |  10 +-
 .../cache/lucene/internal/InternalLuceneIndex.java |   7 +
 .../lucene/internal/LuceneBucketListener.java      |   4 +-
 .../internal/LuceneIndexForPartitionedRegion.java  |  15 +-
 .../cache/lucene/internal/LuceneIndexImpl.java     |  61 ++++----
 .../cache/lucene/internal/LuceneRawIndex.java      |   5 +-
 .../lucene/internal/LuceneRegionListener.java      |   2 +-
 .../cache/lucene/internal/LuceneServiceImpl.java   |  16 +--
 .../internal/PartitionedRepositoryManager.java     | 142 +++++++++++++++++--
 .../lucene/internal/RawIndexRepositoryFactory.java |   2 +-
 .../internal/RawLuceneRepositoryManager.java       |   4 +-
 .../cache/lucene/internal/StringQueryProvider.java |   1 -
 .../internal/distributed/LuceneQueryFunction.java  |  19 +--
 .../internal/management/LuceneServiceBridge.java   |   9 +-
 .../LuceneIndexForPartitionedRegionTest.java       |  41 ++----
 .../internal/LuceneServiceImplJUnitTest.java       |   5 +-
 .../PartitionedRepositoryManagerJUnitTest.java     |   4 +-
 .../RawLuceneRepositoryManagerJUnitTest.java       |   2 +-
 .../cache/lucene/test/IndexRepositorySpy.java      |  10 +-
 20 files changed, 218 insertions(+), 297 deletions(-)

diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/AbstractPartitionedRepositoryManager.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/AbstractPartitionedRepositoryManager.java
deleted file mode 100755
index ca8ebb7..0000000
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/AbstractPartitionedRepositoryManager.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
- * agreements. See the NOTICE file distributed with this work for additional information regarding
- * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License. You may obtain a
- * copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- * or implied. See the License for the specific language governing permissions and limitations under
- * the License.
- */
-package org.apache.geode.cache.lucene.internal;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.CountDownLatch;
-
-import org.apache.geode.InternalGemFireError;
-import org.apache.geode.cache.Region;
-import org.apache.geode.cache.execute.RegionFunctionContext;
-import org.apache.geode.cache.lucene.LuceneIndexDestroyedException;
-import org.apache.geode.cache.lucene.LuceneSerializer;
-import org.apache.geode.cache.lucene.internal.repository.IndexRepository;
-import org.apache.geode.cache.lucene.internal.repository.RepositoryManager;
-import org.apache.geode.internal.cache.BucketNotFoundException;
-import org.apache.geode.internal.cache.BucketRegion;
-import org.apache.geode.internal.cache.PartitionedRegion;
-import org.apache.geode.internal.cache.execute.InternalRegionFunctionContext;
-
-public abstract class AbstractPartitionedRepositoryManager implements RepositoryManager {
-
-  /**
-   * map of the parent bucket region to the index repository
-   *
-   * This is based on the BucketRegion in case a bucket is rebalanced, we don't want to return a
-   * stale index repository. If a bucket moves off of this node and comes back, it will have a new
-   * BucketRegion object.
-   *
-   * It is weak so that the old BucketRegion will be garbage collected.
-   */
-  protected final ConcurrentHashMap<Integer, IndexRepository> indexRepositories =
-      new ConcurrentHashMap<Integer, IndexRepository>();
-
-  /** The user region for this index */
-  protected PartitionedRegion userRegion = null;
-  protected final LuceneSerializer serializer;
-  protected final LuceneIndexImpl index;
-  protected volatile boolean closed;
-  private final CountDownLatch isDataRegionReady = new CountDownLatch(1);
-
-  public AbstractPartitionedRepositoryManager(LuceneIndexImpl index, LuceneSerializer serializer) {
-    this.index = index;
-    this.serializer = serializer;
-    this.closed = false;
-  }
-
-  public void setUserRegionForRepositoryManager() {
-    this.userRegion = (PartitionedRegion) index.getCache().getRegion(index.getRegionPath());
-  }
-
-  @Override
-  public IndexRepository getRepository(Region region, Object key, Object callbackArg)
-      throws BucketNotFoundException {
-    BucketRegion userBucket = userRegion.getBucketRegion(key, callbackArg);
-    if (userBucket == null) {
-      throw new BucketNotFoundException("User bucket was not found for region " + region + "key "
-          + key + " callbackarg " + callbackArg);
-    }
-
-    return getRepository(userBucket.getId());
-  }
-
-  @Override
-  public Collection<IndexRepository> getRepositories(RegionFunctionContext ctx)
-      throws BucketNotFoundException {
-    Region<Object, Object> region = ctx.getDataSet();
-    Set<Integer> buckets = ((InternalRegionFunctionContext) ctx).getLocalBucketSet(region);
-    ArrayList<IndexRepository> repos = new ArrayList<IndexRepository>(buckets.size());
-    for (Integer bucketId : buckets) {
-      BucketRegion userBucket = userRegion.getDataStore().getLocalBucketById(bucketId);
-      if (userBucket == null) {
-        throw new BucketNotFoundException(
-            "User bucket was not found for region " + region + "bucket id " + bucketId);
-      } else {
-        repos.add(getRepository(userBucket.getId()));
-      }
-    }
-
-    return repos;
-  }
-
-  public abstract IndexRepository computeRepository(final Integer bucketId,
-      LuceneSerializer serializer, LuceneIndexImpl index, PartitionedRegion userRegion,
-      IndexRepository oldRepository) throws IOException;
-
-  protected IndexRepository computeRepository(Integer bucketId) {
-    try {
-      isDataRegionReady.await();
-    } catch (InterruptedException e) {
-      throw new InternalGemFireError("Unable to create index repository", e);
-    }
-    IndexRepository repo = indexRepositories.compute(bucketId, (key, oldRepository) -> {
-      try {
-        if (closed) {
-          if (oldRepository != null) {
-            oldRepository.cleanup();
-          }
-          throw new LuceneIndexDestroyedException(index.getName(), index.getRegionPath());
-        }
-        return computeRepository(bucketId, serializer, index, userRegion, oldRepository);
-      } catch (IOException e) {
-        throw new InternalGemFireError("Unable to create index repository", e);
-      }
-    });
-    return repo;
-  }
-
-  protected void allowRepositoryComputation() {
-    isDataRegionReady.countDown();
-  }
-
-  /**
-   * Return the repository for a given user bucket
-   */
-  protected IndexRepository getRepository(Integer bucketId) throws BucketNotFoundException {
-    IndexRepository repo = indexRepositories.get(bucketId);
-    if (repo != null && !repo.isClosed()) {
-      return repo;
-    }
-
-    repo = computeRepository(bucketId);
-
-    if (repo == null) {
-      throw new BucketNotFoundException(
-          "Unable to find lucene index because no longer primary for bucket " + bucketId);
-    }
-    return repo;
-  }
-
-  @Override
-  public void close() {
-    this.closed = true;
-    for (Integer bucketId : indexRepositories.keySet()) {
-      try {
-        computeRepository(bucketId);
-      } catch (LuceneIndexDestroyedException e) {
-        /* expected exception */}
-    }
-  }
-}
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 5df2617..2bbe05c 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
@@ -50,7 +50,7 @@ public class IndexRepositoryFactory {
   public IndexRepositoryFactory() {}
 
   public IndexRepository computeIndexRepository(final Integer bucketId, LuceneSerializer serializer,
-      LuceneIndexImpl index, PartitionedRegion userRegion, final IndexRepository oldRepository)
+      InternalLuceneIndex index, PartitionedRegion userRegion, final IndexRepository oldRepository)
       throws IOException {
     LuceneIndexForPartitionedRegion indexForPR = (LuceneIndexForPartitionedRegion) index;
     final PartitionedRegion fileRegion = indexForPR.getFileAndChunkRegion();
@@ -112,8 +112,7 @@ public class IndexRepositoryFactory {
         success = true;
         return repo;
       } else {
-        success =
-            reindexUserDataRegion(bucketId, userRegion, fileRegion, dataBucket, success, repo);
+        success = reindexUserDataRegion(bucketId, userRegion, fileRegion, dataBucket, repo);
       }
       return repo;
     } catch (IOException e) {
@@ -133,7 +132,7 @@ public class IndexRepositoryFactory {
   }
 
   private boolean reindexUserDataRegion(Integer bucketId, PartitionedRegion userRegion,
-      PartitionedRegion fileRegion, BucketRegion dataBucket, boolean success, IndexRepository repo)
+      PartitionedRegion fileRegion, BucketRegion dataBucket, IndexRepository repo)
       throws IOException {
     Set<IndexRepository> affectedRepos = new HashSet<IndexRepository>();
 
@@ -154,8 +153,7 @@ public class IndexRepositoryFactory {
     }
     // fileRegion ops (get/put) need bucketId as a callbackArg for PartitionResolver
     fileRegion.put(APACHE_GEODE_INDEX_COMPLETE, APACHE_GEODE_INDEX_COMPLETE, bucketId);
-    success = true;
-    return success;
+    return true;
   }
 
   private Object getValue(Region.Entry entry) {
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/InternalLuceneIndex.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/InternalLuceneIndex.java
index 72d2c9a..74e4ac8 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/InternalLuceneIndex.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/InternalLuceneIndex.java
@@ -15,6 +15,7 @@
 
 package org.apache.geode.cache.lucene.internal;
 
+import org.apache.geode.cache.Cache;
 import org.apache.geode.cache.lucene.LuceneIndex;
 import org.apache.geode.cache.lucene.internal.repository.RepositoryManager;
 
@@ -32,4 +33,10 @@ public interface InternalLuceneIndex extends LuceneIndex {
    */
   void destroy(boolean initiator);
 
+  LuceneIndexStats getIndexStats();
+
+  Cache getCache();
+
+  void initialize();
+
 }
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneBucketListener.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneBucketListener.java
index 3da4064..5830337 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneBucketListener.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneBucketListener.java
@@ -24,10 +24,10 @@ import org.apache.geode.internal.logging.LogService;
 
 public class LuceneBucketListener extends PartitionListenerAdapter {
   private static final Logger logger = LogService.getLogger();
-  private AbstractPartitionedRepositoryManager lucenePartitionRepositoryManager;
+  private PartitionedRepositoryManager lucenePartitionRepositoryManager;
   private final DistributionManager dm;
 
-  public LuceneBucketListener(AbstractPartitionedRepositoryManager partitionedRepositoryManager,
+  public LuceneBucketListener(PartitionedRepositoryManager partitionedRepositoryManager,
       final DistributionManager dm) {
     lucenePartitionRepositoryManager = partitionedRepositoryManager;
     this.dm = dm;
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 aee2e3e..577bdef 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
@@ -67,8 +67,8 @@ public class LuceneIndexForPartitionedRegion extends LuceneIndexImpl {
   }
 
   protected void createLuceneListenersAndFileChunkRegions(
-      AbstractPartitionedRepositoryManager partitionedRepositoryManager) {
-    partitionedRepositoryManager.setUserRegionForRepositoryManager();
+      PartitionedRepositoryManager partitionedRepositoryManager) {
+    partitionedRepositoryManager.setUserRegionForRepositoryManager((PartitionedRegion) dataRegion);
     RegionShortcut regionShortCut;
     final boolean withPersistence = withPersistence();
     RegionAttributes regionAttributes = dataRegion.getAttributes();
@@ -95,8 +95,8 @@ public class LuceneIndexForPartitionedRegion extends LuceneIndexImpl {
         new LuceneBucketListener(partitionedRepositoryManager, dm);
 
     if (!fileRegionExists(fileRegionName)) {
-      fileAndChunkRegion = createFileRegion(regionShortCut, fileRegionName, partitionAttributes,
-          regionAttributes, lucenePrimaryBucketListener);
+      fileAndChunkRegion = createRegion(fileRegionName, regionShortCut, this.regionPath,
+          partitionAttributes, regionAttributes, lucenePrimaryBucketListener);
     }
 
     fileSystemStats
@@ -116,13 +116,6 @@ public class LuceneIndexForPartitionedRegion extends LuceneIndexImpl {
     return cache.getRegion(fileRegionName) != null;
   }
 
-  Region createFileRegion(final RegionShortcut regionShortCut, final String fileRegionName,
-      final PartitionAttributes partitionAttributes, final RegionAttributes regionAttributes,
-      PartitionListener listener) {
-    return createRegion(fileRegionName, regionShortCut, this.regionPath, partitionAttributes,
-        regionAttributes, listener);
-  }
-
   public String createFileRegionName() {
     return LuceneServiceImpl.getUniqueIndexRegionName(indexName, regionPath, FILES_REGION_SUFFIX);
   }
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneIndexImpl.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneIndexImpl.java
index fd4d060..6536844 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneIndexImpl.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneIndexImpl.java
@@ -24,8 +24,6 @@ import org.apache.lucene.analysis.standard.StandardAnalyzer;
 import org.apache.geode.InternalGemFireError;
 import org.apache.geode.cache.Cache;
 import org.apache.geode.cache.DataPolicy;
-import org.apache.geode.cache.EvictionAlgorithm;
-import org.apache.geode.cache.EvictionAttributes;
 import org.apache.geode.cache.Region;
 import org.apache.geode.cache.RegionAttributes;
 import org.apache.geode.cache.asyncqueue.AsyncEventQueue;
@@ -50,8 +48,6 @@ public abstract class LuceneIndexImpl implements InternalLuceneIndex {
   protected final InternalCache cache;
   protected final LuceneIndexStats indexStats;
 
-  protected boolean hasInitialized = false;
-  protected boolean hasInitializedAEQ = false;
   protected Map<String, Analyzer> fieldAnalyzers;
   protected String[] searchableFieldNames;
   protected RepositoryManager repositoryManager;
@@ -78,10 +74,14 @@ public abstract class LuceneIndexImpl implements InternalLuceneIndex {
     return this.regionPath;
   }
 
-  protected LocalRegion getDataRegion() {
+  protected LocalRegion assignDataRegion() {
     return (LocalRegion) cache.getRegion(regionPath);
   }
 
+  protected LocalRegion getDataRegion() {
+    return dataRegion;
+  }
+
   protected boolean withPersistence() {
     RegionAttributes ra = dataRegion.getAttributes();
     DataPolicy dp = ra.getDataPolicy();
@@ -140,22 +140,11 @@ public abstract class LuceneIndexImpl implements InternalLuceneIndex {
     return indexStats;
   }
 
-  protected void initialize() {
-    if (!hasInitialized) {
-      /* create index region */
-      dataRegion = getDataRegion();
-      createLuceneListenersAndFileChunkRegions(
-          (AbstractPartitionedRepositoryManager) repositoryManager);
-      addExtension(dataRegion);
-      hasInitialized = true;
-    }
-  }
-
-  protected void setupAEQ(RegionAttributes attributes, String aeqId) {
-    if (!hasInitializedAEQ) {
-      createAEQ(attributes, aeqId);
-      hasInitializedAEQ = true;
-    }
+  public void initialize() {
+    /* create index region */
+    dataRegion = assignDataRegion();
+    createLuceneListenersAndFileChunkRegions((PartitionedRepositoryManager) repositoryManager);
+    addExtension(dataRegion);
   }
 
   protected void setupRepositoryManager(LuceneSerializer luceneSerializer) {
@@ -165,7 +154,7 @@ public abstract class LuceneIndexImpl implements InternalLuceneIndex {
   protected abstract RepositoryManager createRepositoryManager(LuceneSerializer luceneSerializer);
 
   protected abstract void createLuceneListenersAndFileChunkRegions(
-      AbstractPartitionedRepositoryManager partitionedRepositoryManager);
+      PartitionedRepositoryManager partitionedRepositoryManager);
 
   protected AsyncEventQueue createAEQ(Region dataRegion) {
     String aeqId = LuceneServiceImpl.getUniqueIndexName(getName(), regionPath);
@@ -173,18 +162,26 @@ public abstract class LuceneIndexImpl implements InternalLuceneIndex {
   }
 
   protected AsyncEventQueue createAEQ(RegionAttributes attributes, String aeqId) {
+    if (attributes.getPartitionAttributes() != null) {
+      if (attributes.getPartitionAttributes().getLocalMaxMemory() == 0) {
+        // accessor will not create AEQ
+        return null;
+      }
+    }
     return createAEQ(createAEQFactory(attributes), aeqId);
   }
 
+  private AsyncEventQueue createAEQ(AsyncEventQueueFactoryImpl factory, String aeqId) {
+    LuceneEventListener listener = new LuceneEventListener(repositoryManager);
+    factory.setGatewayEventSubstitutionListener(new LuceneEventSubstitutionFilter());
+    AsyncEventQueue indexQueue = factory.create(aeqId, listener);
+    return indexQueue;
+  }
+
   private AsyncEventQueueFactoryImpl createAEQFactory(final RegionAttributes attributes) {
     AsyncEventQueueFactoryImpl factory =
         (AsyncEventQueueFactoryImpl) cache.createAsyncEventQueueFactory();
     if (attributes.getPartitionAttributes() != null) {
-
-      if (attributes.getPartitionAttributes().getLocalMaxMemory() == 0) {
-        // accessor will not create AEQ
-        return null;
-      }
       factory.setParallel(true); // parallel AEQ for PR
     } else {
       factory.setParallel(false); // TODO: not sure if serial AEQ working or not
@@ -202,16 +199,6 @@ public abstract class LuceneIndexImpl implements InternalLuceneIndex {
     return factory;
   }
 
-  private AsyncEventQueue createAEQ(AsyncEventQueueFactoryImpl factory, String aeqId) {
-    if (factory == null) {
-      return null;
-    }
-    LuceneEventListener listener = new LuceneEventListener(repositoryManager);
-    factory.setGatewayEventSubstitutionListener(new LuceneEventSubstitutionFilter());
-    AsyncEventQueue indexQueue = factory.create(aeqId, listener);
-    return indexQueue;
-  }
-
   /**
    * Register an extension with the region so that xml will be generated for this index.
    */
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneRawIndex.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneRawIndex.java
index 85229ce..d4168bd 100755
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneRawIndex.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneRawIndex.java
@@ -18,6 +18,7 @@ import org.apache.geode.cache.lucene.LuceneSerializer;
 import org.apache.geode.cache.lucene.internal.repository.RepositoryManager;
 import org.apache.geode.cache.lucene.internal.repository.serializer.HeterogeneousLuceneSerializer;
 import org.apache.geode.internal.cache.InternalCache;
+import org.apache.geode.internal.cache.PartitionedRegion;
 
 public class LuceneRawIndex extends LuceneIndexImpl {
 
@@ -38,8 +39,8 @@ public class LuceneRawIndex extends LuceneIndexImpl {
 
   @Override
   protected void createLuceneListenersAndFileChunkRegions(
-      AbstractPartitionedRepositoryManager partitionedRepositoryManager) {
-    partitionedRepositoryManager.setUserRegionForRepositoryManager();
+      PartitionedRepositoryManager partitionedRepositoryManager) {
+    partitionedRepositoryManager.setUserRegionForRepositoryManager((PartitionedRegion) dataRegion);
   }
 
   @Override
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneRegionListener.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneRegionListener.java
index bec0dd2..7313a82 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneRegionListener.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneRegionListener.java
@@ -46,7 +46,7 @@ public class LuceneRegionListener implements RegionListener {
 
   private LuceneSerializer serializer;
 
-  private LuceneIndexImpl luceneIndex;
+  private InternalLuceneIndex luceneIndex;
 
   private AtomicBoolean beforeCreateInvoked = new AtomicBoolean();
 
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneServiceImpl.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneServiceImpl.java
index b5987e2..b2c2412 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneServiceImpl.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneServiceImpl.java
@@ -240,10 +240,10 @@ public class LuceneServiceImpl implements InternalLuceneService {
   }
 
   protected boolean createLuceneIndexOnDataRegion(final PartitionedRegion userRegion,
-      final LuceneIndexImpl luceneIndex) {
+      final InternalLuceneIndex luceneIndex) {
     try {
-      AbstractPartitionedRepositoryManager repositoryManager =
-          (AbstractPartitionedRepositoryManager) luceneIndex.getRepositoryManager();
+      PartitionedRepositoryManager repositoryManager =
+          (PartitionedRepositoryManager) luceneIndex.getRepositoryManager();
       if (userRegion.getDataStore() == null) {
         return true;
       }
@@ -307,17 +307,15 @@ public class LuceneServiceImpl implements InternalLuceneService {
    *
    * Public because this is called by the Xml parsing code
    */
-  public void afterDataRegionCreated(LuceneIndexImpl index) {
+  public void afterDataRegionCreated(InternalLuceneIndex index) {
     index.initialize();
     registerIndex(index);
     if (this.managementListener != null) {
       this.managementListener.afterIndexCreated(index);
     }
 
-    String aeqId = LuceneServiceImpl.getUniqueIndexName(index.getName(), index.getRegionPath());
-    AsyncEventQueueImpl aeq = (AsyncEventQueueImpl) cache.getAsyncEventQueue(aeqId);
-    AbstractPartitionedRepositoryManager repositoryManager =
-        (AbstractPartitionedRepositoryManager) index.getRepositoryManager();
+    PartitionedRepositoryManager repositoryManager =
+        (PartitionedRepositoryManager) index.getRepositoryManager();
     repositoryManager.allowRepositoryComputation();
 
   }
@@ -332,7 +330,7 @@ public class LuceneServiceImpl implements InternalLuceneService {
     index.setFieldAnalyzers(fieldAnalyzers);
     index.setLuceneSerializer(serializer);
     index.setupRepositoryManager(serializer);
-    index.setupAEQ(attributes, aeqId);
+    index.createAEQ(attributes, aeqId);
     return index;
 
   }
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/PartitionedRepositoryManager.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/PartitionedRepositoryManager.java
old mode 100644
new mode 100755
index 5fd942d..9e90e95
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/PartitionedRepositoryManager.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/PartitionedRepositoryManager.java
@@ -12,34 +12,150 @@
  * or implied. See the License for the specific language governing permissions and limitations under
  * the License.
  */
-
 package org.apache.geode.cache.lucene.internal;
 
 import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.CountDownLatch;
 
+import org.apache.geode.InternalGemFireError;
+import org.apache.geode.cache.Region;
+import org.apache.geode.cache.execute.RegionFunctionContext;
+import org.apache.geode.cache.lucene.LuceneIndexDestroyedException;
 import org.apache.geode.cache.lucene.LuceneSerializer;
 import org.apache.geode.cache.lucene.internal.repository.IndexRepository;
+import org.apache.geode.cache.lucene.internal.repository.RepositoryManager;
+import org.apache.geode.internal.cache.BucketNotFoundException;
+import org.apache.geode.internal.cache.BucketRegion;
 import org.apache.geode.internal.cache.PartitionedRegion;
+import org.apache.geode.internal.cache.execute.InternalRegionFunctionContext;
 
-/**
- * Manages index repositories for partitioned regions.
- *
- * This class lazily creates the IndexRepository for each individual bucket. If a Bucket is
- * rebalanced, this class will create a new index repository when the bucket returns to this node.
- */
-public class PartitionedRepositoryManager extends AbstractPartitionedRepositoryManager {
-
+public class PartitionedRepositoryManager implements RepositoryManager {
   public static IndexRepositoryFactory indexRepositoryFactory = new IndexRepositoryFactory();
+  /**
+   * map of the parent bucket region to the index repository
+   *
+   * This is based on the BucketRegion in case a bucket is rebalanced, we don't want to return a
+   * stale index repository. If a bucket moves off of this node and comes back, it will have a new
+   * BucketRegion object.
+   *
+   * It is weak so that the old BucketRegion will be garbage collected.
+   */
+  protected final ConcurrentHashMap<Integer, IndexRepository> indexRepositories =
+      new ConcurrentHashMap<Integer, IndexRepository>();
+
+  /** The user region for this index */
+  protected PartitionedRegion userRegion = null;
+  protected final LuceneSerializer serializer;
+  protected final InternalLuceneIndex index;
+  protected volatile boolean closed;
+  private final CountDownLatch isDataRegionReady = new CountDownLatch(1);
+
+  public PartitionedRepositoryManager(InternalLuceneIndex index, LuceneSerializer serializer) {
+    this.index = index;
+    this.serializer = serializer;
+    this.closed = false;
+  }
 
-  public PartitionedRepositoryManager(LuceneIndexImpl index, LuceneSerializer serializer) {
-    super(index, serializer);
+  public void setUserRegionForRepositoryManager(PartitionedRegion userRegion) {
+    this.userRegion = userRegion;
   }
 
   @Override
-  public IndexRepository computeRepository(Integer bucketId, LuceneSerializer serializer,
-      LuceneIndexImpl index, PartitionedRegion userRegion, IndexRepository oldRepository)
+  public Collection<IndexRepository> getRepositories(RegionFunctionContext ctx)
+      throws BucketNotFoundException {
+    Region<Object, Object> region = ctx.getDataSet();
+    Set<Integer> buckets = ((InternalRegionFunctionContext) ctx).getLocalBucketSet(region);
+    ArrayList<IndexRepository> repos = new ArrayList<IndexRepository>(buckets.size());
+    for (Integer bucketId : buckets) {
+      BucketRegion userBucket = userRegion.getDataStore().getLocalBucketById(bucketId);
+      if (userBucket == null) {
+        throw new BucketNotFoundException(
+            "User bucket was not found for region " + region + "bucket id " + bucketId);
+      } else {
+        repos.add(getRepository(userBucket.getId()));
+      }
+    }
+
+    return repos;
+  }
+
+  @Override
+  public IndexRepository getRepository(Region region, Object key, Object callbackArg)
+      throws BucketNotFoundException {
+    BucketRegion userBucket = userRegion.getBucketRegion(key, callbackArg);
+    if (userBucket == null) {
+      throw new BucketNotFoundException("User bucket was not found for region " + region + "key "
+          + key + " callbackarg " + callbackArg);
+    }
+
+    return getRepository(userBucket.getId());
+  }
+
+  /**
+   * Return the repository for a given user bucket
+   */
+  protected IndexRepository getRepository(Integer bucketId) throws BucketNotFoundException {
+    IndexRepository repo = indexRepositories.get(bucketId);
+    if (repo != null && !repo.isClosed()) {
+      return repo;
+    }
+
+    repo = computeRepository(bucketId);
+
+    if (repo == null) {
+      throw new BucketNotFoundException(
+          "Unable to find lucene index because no longer primary for bucket " + bucketId);
+    }
+    return repo;
+  }
+
+  protected IndexRepository computeRepository(Integer bucketId, LuceneSerializer serializer,
+      InternalLuceneIndex index, PartitionedRegion userRegion, IndexRepository oldRepository)
       throws IOException {
     return indexRepositoryFactory.computeIndexRepository(bucketId, serializer, index, userRegion,
         oldRepository);
   }
+
+
+  protected IndexRepository computeRepository(Integer bucketId) {
+    try {
+      isDataRegionReady.await();
+    } catch (InterruptedException e) {
+      throw new InternalGemFireError("Unable to create index repository", e);
+    }
+    IndexRepository repo = indexRepositories.compute(bucketId, (key, oldRepository) -> {
+      try {
+        if (closed) {
+          if (oldRepository != null) {
+            oldRepository.cleanup();
+          }
+          throw new LuceneIndexDestroyedException(index.getName(), index.getRegionPath());
+        }
+        return computeRepository(bucketId, serializer, index, userRegion, oldRepository);
+      } catch (IOException e) {
+        throw new InternalGemFireError("Unable to create index repository", e);
+      }
+    });
+    return repo;
+  }
+
+  protected void allowRepositoryComputation() {
+    isDataRegionReady.countDown();
+  }
+
+
+  @Override
+  public void close() {
+    this.closed = true;
+    for (Integer bucketId : indexRepositories.keySet()) {
+      try {
+        computeRepository(bucketId);
+      } catch (LuceneIndexDestroyedException e) {
+        /* expected exception */}
+    }
+  }
 }
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/RawIndexRepositoryFactory.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/RawIndexRepositoryFactory.java
index c303713..8f8e09e 100755
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/RawIndexRepositoryFactory.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/RawIndexRepositoryFactory.java
@@ -34,7 +34,7 @@ public class RawIndexRepositoryFactory extends IndexRepositoryFactory {
 
   @Override
   public IndexRepository computeIndexRepository(final Integer bucketId, LuceneSerializer serializer,
-      LuceneIndexImpl index, PartitionedRegion userRegion, IndexRepository oldRepository)
+      InternalLuceneIndex index, PartitionedRegion userRegion, IndexRepository oldRepository)
       throws IOException {
     final IndexRepository repo;
     if (oldRepository != null) {
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/RawLuceneRepositoryManager.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/RawLuceneRepositoryManager.java
index 987c8ee..f47e11e 100755
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/RawLuceneRepositoryManager.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/RawLuceneRepositoryManager.java
@@ -21,7 +21,7 @@ import org.apache.geode.cache.lucene.internal.repository.IndexRepository;
 import org.apache.geode.internal.cache.BucketNotFoundException;
 import org.apache.geode.internal.cache.PartitionedRegion;
 
-public class RawLuceneRepositoryManager extends AbstractPartitionedRepositoryManager {
+public class RawLuceneRepositoryManager extends PartitionedRepositoryManager {
   public static IndexRepositoryFactory indexRepositoryFactory = new RawIndexRepositoryFactory();
 
   public RawLuceneRepositoryManager(LuceneIndexImpl index, LuceneSerializer serializer) {
@@ -48,7 +48,7 @@ public class RawLuceneRepositoryManager extends AbstractPartitionedRepositoryMan
 
   @Override
   public IndexRepository computeRepository(Integer bucketId, LuceneSerializer serializer,
-      LuceneIndexImpl index, PartitionedRegion userRegion, IndexRepository oldRepository)
+      InternalLuceneIndex index, PartitionedRegion userRegion, IndexRepository oldRepository)
       throws IOException {
     return indexRepositoryFactory.computeIndexRepository(bucketId, serializer, index, userRegion,
         oldRepository);
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/StringQueryProvider.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/StringQueryProvider.java
index 3d3f760..f0626b5 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/StringQueryProvider.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/StringQueryProvider.java
@@ -64,7 +64,6 @@ public class StringQueryProvider implements LuceneQueryProvider, DataSerializabl
   @Override
   public synchronized Query getQuery(LuceneIndex index) throws LuceneQueryException {
     if (luceneQuery == null) {
-      String[] fields = index.getFieldNames();
       LuceneIndexImpl indexImpl = (LuceneIndexImpl) index;
       StandardQueryParser parser = new StandardQueryParser(indexImpl.getAnalyzer());
       parser.setAllowLeadingWildcard(true);
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/distributed/LuceneQueryFunction.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/distributed/LuceneQueryFunction.java
index e460533..135abec 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/distributed/LuceneQueryFunction.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/distributed/LuceneQueryFunction.java
@@ -28,12 +28,13 @@ import org.apache.geode.cache.execute.FunctionContext;
 import org.apache.geode.cache.execute.FunctionException;
 import org.apache.geode.cache.execute.RegionFunctionContext;
 import org.apache.geode.cache.execute.ResultSender;
+import org.apache.geode.cache.lucene.LuceneIndex;
 import org.apache.geode.cache.lucene.LuceneIndexNotFoundException;
 import org.apache.geode.cache.lucene.LuceneQueryException;
 import org.apache.geode.cache.lucene.LuceneQueryProvider;
 import org.apache.geode.cache.lucene.LuceneService;
 import org.apache.geode.cache.lucene.LuceneServiceProvider;
-import org.apache.geode.cache.lucene.internal.LuceneIndexImpl;
+import org.apache.geode.cache.lucene.internal.InternalLuceneIndex;
 import org.apache.geode.cache.lucene.internal.LuceneIndexStats;
 import org.apache.geode.cache.lucene.internal.LuceneServiceImpl;
 import org.apache.geode.cache.lucene.internal.repository.IndexRepository;
@@ -75,7 +76,7 @@ public class LuceneQueryFunction implements InternalFunction<LuceneFunctionConte
       throw new IllegalArgumentException("Missing query provider");
     }
 
-    LuceneIndexImpl index = getLuceneIndex(region, searchContext);
+    InternalLuceneIndex index = getLuceneIndex(region, searchContext);
     if (index == null) {
       throw new LuceneIndexNotFoundException(searchContext.getIndexName(), region.getFullPath());
     }
@@ -124,13 +125,13 @@ public class LuceneQueryFunction implements InternalFunction<LuceneFunctionConte
     }
   }
 
-  private LuceneIndexImpl getLuceneIndex(final Region region,
+  private InternalLuceneIndex getLuceneIndex(final Region region,
       final LuceneFunctionContext<IndexResultCollector> searchContext) {
     LuceneService service = LuceneServiceProvider.get(region.getCache());
-    LuceneIndexImpl index = null;
+    InternalLuceneIndex index = null;
     try {
-      index =
-          (LuceneIndexImpl) service.getIndex(searchContext.getIndexName(), region.getFullPath());
+      index = (InternalLuceneIndex) service.getIndex(searchContext.getIndexName(),
+          region.getFullPath());
       if (index == null) {
         while (service instanceof LuceneServiceImpl && (((LuceneServiceImpl) service)
             .getDefinedIndex(searchContext.getIndexName(), region.getFullPath()) != null)) {
@@ -141,8 +142,8 @@ public class LuceneQueryFunction implements InternalFunction<LuceneFunctionConte
           }
           region.getCache().getCancelCriterion().checkCancelInProgress(null);
         }
-        index =
-            (LuceneIndexImpl) service.getIndex(searchContext.getIndexName(), region.getFullPath());
+        index = (InternalLuceneIndex) service.getIndex(searchContext.getIndexName(),
+            region.getFullPath());
       }
     } catch (CacheClosedException e) {
       throw new InternalFunctionInvocationTargetException(
@@ -152,7 +153,7 @@ public class LuceneQueryFunction implements InternalFunction<LuceneFunctionConte
     return index;
   }
 
-  private Query getQuery(final LuceneQueryProvider queryProvider, final LuceneIndexImpl index) {
+  private Query getQuery(final LuceneQueryProvider queryProvider, final LuceneIndex index) {
     Query query = null;
     try {
       query = queryProvider.getQuery(index);
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/management/LuceneServiceBridge.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/management/LuceneServiceBridge.java
index db9c604..34e0159 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/management/LuceneServiceBridge.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/management/LuceneServiceBridge.java
@@ -23,7 +23,6 @@ import java.util.concurrent.ConcurrentHashMap;
 import org.apache.geode.cache.Region;
 import org.apache.geode.cache.lucene.LuceneIndex;
 import org.apache.geode.cache.lucene.LuceneService;
-import org.apache.geode.cache.lucene.internal.LuceneIndexImpl;
 import org.apache.geode.cache.lucene.management.LuceneIndexMetrics;
 
 public class LuceneServiceBridge {
@@ -50,7 +49,7 @@ public class LuceneServiceBridge {
     LuceneIndexMetrics[] indexMetrics = new LuceneIndexMetrics[indexes.size()];
     int i = 0;
     for (LuceneIndex index : this.service.getAllIndexes()) {
-      indexMetrics[i++] = getIndexMetrics((LuceneIndexImpl) index);
+      indexMetrics[i++] = getIndexMetrics(index);
     }
     return indexMetrics;
   }
@@ -62,14 +61,14 @@ public class LuceneServiceBridge {
     List<LuceneIndexMetrics> indexMetrics = new ArrayList();
     for (LuceneIndex index : this.service.getAllIndexes()) {
       if (index.getRegionPath().equals(regionPath)) {
-        indexMetrics.add(getIndexMetrics((LuceneIndexImpl) index));
+        indexMetrics.add(getIndexMetrics(index));
       }
     }
     return indexMetrics.toArray(new LuceneIndexMetrics[indexMetrics.size()]);
   }
 
   public LuceneIndexMetrics listIndexMetrics(String regionPath, String indexName) {
-    LuceneIndexImpl index = (LuceneIndexImpl) this.service.getIndex(indexName, regionPath);
+    LuceneIndex index = this.service.getIndex(indexName, regionPath);
     return index == null ? null : getIndexMetrics(index);
   }
 
@@ -77,7 +76,7 @@ public class LuceneServiceBridge {
     return index.getRegionPath() + "_" + index.getName();
   }
 
-  private LuceneIndexMetrics getIndexMetrics(LuceneIndexImpl index) {
+  private LuceneIndexMetrics getIndexMetrics(LuceneIndex index) {
     LuceneIndexStatsMonitor monitor = this.monitors.get(getMonitorKey(index));
     return monitor.getIndexMetrics(index);
   }
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 146743a..9ebde2c 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
@@ -253,10 +253,10 @@ public class LuceneIndexForPartitionedRegionTest {
       final LuceneIndexForPartitionedRegion index, final String aeq) {
     index.setSearchableFields(new String[] {"field"});
     LuceneIndexForPartitionedRegion spy = spy(index);
-    doReturn(null).when(spy).createFileRegion(any(), any(), any(), any(), any());
+    doReturn(null).when(spy).createRegion(any(), any(), any(), any(), any(), any());
     doReturn(null).when(spy).createAEQ(any(), any());
     spy.setupRepositoryManager(null);
-    spy.setupAEQ(region.getAttributes(), aeq);
+    spy.createAEQ(region.getAttributes(), aeq);
     spy.initialize();
     return spy;
   }
@@ -273,7 +273,7 @@ public class LuceneIndexForPartitionedRegionTest {
         new LuceneIndexForPartitionedRegion(name, regionPath, cache);
     LuceneIndexForPartitionedRegion spy = setupSpy(region, index, "aeq");
 
-    verify(spy).createFileRegion(eq(RegionShortcut.PARTITION), eq(index.createFileRegionName()),
+    verify(spy).createRegion(eq(index.createFileRegionName()), eq(RegionShortcut.PARTITION), any(),
         any(), any(), any());
   }
 
@@ -289,7 +289,7 @@ public class LuceneIndexForPartitionedRegionTest {
     LuceneIndexForPartitionedRegion index =
         new LuceneIndexForPartitionedRegion(name, regionPath, cache);
     LuceneIndexForPartitionedRegion indexSpy = spy(index);
-    indexSpy.createFileRegion(RegionShortcut.PARTITION, index.createFileRegionName(),
+    indexSpy.createRegion(index.createFileRegionName(), RegionShortcut.PARTITION, regionPath,
         partitionAttributes, regionAttributes, null);
     String fileRegionName = index.createFileRegionName();
     verify(indexSpy).createRegion(fileRegionName, RegionShortcut.PARTITION, regionPath,
@@ -309,37 +309,14 @@ public class LuceneIndexForPartitionedRegionTest {
         new LuceneIndexForPartitionedRegion(name, regionPath, cache);
     index.setSearchableFields(new String[] {"field"});
     LuceneIndexForPartitionedRegion spy = spy(index);
-    doReturn(null).when(spy).createFileRegion(any(), any(), any(), any(), any());
+    doReturn(null).when(spy).createRegion(any(), any(), any(), any(), any(), any());
     doReturn(null).when(spy).createAEQ((RegionAttributes) any(), any());
     spy.setupRepositoryManager(null);
-    spy.setupAEQ(any(), any());
+    spy.createAEQ(any(), any());
     spy.initialize();
 
-    verify(spy).createFileRegion(eq(RegionShortcut.PARTITION_PERSISTENT),
-        eq(index.createFileRegionName()), any(), any(), any());
-  }
-
-  @Test
-  public void initializeWhenCalledMultipleTimesShouldNotCreateMultipleFileRegions() {
-    boolean withPersistence = true;
-    String name = "indexName";
-    String regionPath = "regionName";
-    InternalCache cache = Fakes.cache();
-    initializeScenario(withPersistence, regionPath, cache);
-
-    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(), any());
-    doReturn(null).when(spy).createAEQ(any(), any());
-    spy.setupRepositoryManager(null);
-    spy.setupAEQ(any(), any());
-    spy.initialize();
-    spy.initialize();
-
-    verify(spy).createFileRegion(eq(RegionShortcut.PARTITION_PERSISTENT),
-        eq(index.createFileRegionName()), any(), any(), any());
+    verify(spy).createRegion(eq(index.createFileRegionName()),
+        eq(RegionShortcut.PARTITION_PERSISTENT), any(), any(), any(), any());
   }
 
   @Test
@@ -360,7 +337,7 @@ public class LuceneIndexForPartitionedRegionTest {
     when(index.getFieldNames()).thenReturn(fields);
     doReturn(aeq).when(index).createAEQ(any(), any());
     index.setupRepositoryManager(null);
-    index.setupAEQ(cache.getRegionAttributes(regionPath), aeq.getId());
+    index.createAEQ(cache.getRegionAttributes(regionPath), aeq.getId());
     index.initialize();
     PartitionedRegion region = (PartitionedRegion) cache.getRegion(regionPath);
     ResultCollector collector = mock(ResultCollector.class);
diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/LuceneServiceImplJUnitTest.java b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/LuceneServiceImplJUnitTest.java
index 680fcb5..07c2d6c 100644
--- a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/LuceneServiceImplJUnitTest.java
+++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/LuceneServiceImplJUnitTest.java
@@ -14,7 +14,8 @@
  */
 package org.apache.geode.cache.lucene.internal;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.anyBoolean;
 import static org.mockito.ArgumentMatchers.anyString;
@@ -152,7 +153,7 @@ public class LuceneServiceImplJUnitTest {
   private class TestLuceneServiceImpl extends LuceneServiceImpl {
 
     @Override
-    public void afterDataRegionCreated(LuceneIndexImpl index) {
+    public void afterDataRegionCreated(InternalLuceneIndex index) {
       PartitionedRegion userRegion =
           (PartitionedRegion) index.getCache().getRegion(index.getRegionPath());
       verify(userRegion, never()).addAsyncEventQueueId(anyString(), anyBoolean());
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 4edce44..bd7f720 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
@@ -92,7 +92,7 @@ public class PartitionedRepositoryManagerJUnitTest {
   protected LuceneIndexStats indexStats;
   protected FileSystemStats fileSystemStats;
   protected LuceneIndexImpl indexForPR;
-  protected AbstractPartitionedRepositoryManager repoManager;
+  protected PartitionedRepositoryManager repoManager;
   protected GemFireCacheImpl cache;
 
   @Before
@@ -141,7 +141,7 @@ public class PartitionedRepositoryManagerJUnitTest {
     PowerMockito.mockStatic(PartitionedRegionHelper.class);
     PowerMockito.when(PartitionedRegionHelper.getPRRoot(cache)).thenReturn(prRoot);
     repoManager = new PartitionedRepositoryManager(indexForPR, serializer);
-    repoManager.setUserRegionForRepositoryManager();
+    repoManager.setUserRegionForRepositoryManager(userRegion);
     repoManager.allowRepositoryComputation();
   }
 
diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/RawLuceneRepositoryManagerJUnitTest.java b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/RawLuceneRepositoryManagerJUnitTest.java
index eac390e..a000d2f 100644
--- a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/RawLuceneRepositoryManagerJUnitTest.java
+++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/RawLuceneRepositoryManagerJUnitTest.java
@@ -67,7 +67,7 @@ public class RawLuceneRepositoryManagerJUnitTest extends PartitionedRepositoryMa
     when(indexForPR.getRegionPath()).thenReturn("/testRegion");
     when(indexForPR.withPersistence()).thenReturn(true);
     repoManager = new RawLuceneRepositoryManager(indexForPR, serializer);
-    repoManager.setUserRegionForRepositoryManager();
+    repoManager.setUserRegionForRepositoryManager(userRegion);
     repoManager.allowRepositoryComputation();
   }
 
diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/test/IndexRepositorySpy.java b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/test/IndexRepositorySpy.java
index 2746567..d80ca63 100644
--- a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/test/IndexRepositorySpy.java
+++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/test/IndexRepositorySpy.java
@@ -14,7 +14,9 @@
  */
 package org.apache.geode.cache.lucene.test;
 
-import static org.mockito.Mockito.*;
+import static org.mockito.Mockito.any;
+import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.mockingDetails;
 
 import java.io.IOException;
 import java.util.function.Consumer;
@@ -24,8 +26,7 @@ import org.mockito.stubbing.Answer;
 
 import org.apache.geode.cache.lucene.LuceneSerializer;
 import org.apache.geode.cache.lucene.internal.IndexRepositoryFactory;
-import org.apache.geode.cache.lucene.internal.LuceneIndexForPartitionedRegion;
-import org.apache.geode.cache.lucene.internal.LuceneIndexImpl;
+import org.apache.geode.cache.lucene.internal.InternalLuceneIndex;
 import org.apache.geode.cache.lucene.internal.PartitionedRepositoryManager;
 import org.apache.geode.cache.lucene.internal.repository.IndexRepository;
 import org.apache.geode.internal.cache.PartitionedRegion;
@@ -49,9 +50,8 @@ public class IndexRepositorySpy extends IndexRepositoryFactory {
 
   @Override
   public IndexRepository computeIndexRepository(final Integer bucketId, LuceneSerializer serializer,
-      LuceneIndexImpl index, PartitionedRegion userRegion, IndexRepository oldRepository)
+      InternalLuceneIndex index, PartitionedRegion userRegion, IndexRepository oldRepository)
       throws IOException {
-    LuceneIndexForPartitionedRegion indexForPR = (LuceneIndexForPartitionedRegion) index;
     final IndexRepository indexRepo =
         super.computeIndexRepository(bucketId, serializer, index, userRegion, oldRepository);
     if (indexRepo == null) {

-- 
To stop receiving notification emails like this one, please contact
jasonhuynh@apache.org.