@Override public IndexRepository computeIndexRepository(final Integer bucketId, LuceneSerializer serializer, InternalLuceneIndex index, PartitionedRegion userRegion, IndexRepository oldRepository, PartitionedRepositoryManager partitionedRepositoryManager) throws IOException { final IndexRepository repo; if (oldRepository != null) { oldRepository.cleanup(); } LuceneRawIndex indexForRaw = (LuceneRawIndex) index; BucketRegion dataBucket = getMatchingBucket(userRegion, bucketId); Directory dir = null; if (indexForRaw.withPersistence()) { String bucketLocation = LuceneServiceImpl.getUniqueIndexName(index.getName(), index.getRegionPath() + "_" + bucketId); File location = new File(index.getName(), bucketLocation); if (!location.exists()) { location.mkdirs(); } dir = new NIOFSDirectory(location.toPath()); } else { dir = new RAMDirectory(); } IndexWriterConfig config = new IndexWriterConfig(indexForRaw.getAnalyzer()); IndexWriter writer = new IndexWriter(dir, config); return new IndexRepositoryImpl(null, writer, serializer, indexForRaw.getIndexStats(), dataBucket, null, "", indexForRaw); } }
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; }