@Override public Collection<IndexRepository> getRepositories(RegionFunctionContext ctx, boolean waitForRepository) 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 { if (index.isIndexAvailable(userBucket.getId()) || userBucket.isEmpty() || waitForRepository) { repos.add(getRepository(userBucket.getId())); } else { waitingThreadPoolFromDM.execute(() -> { try { getRepository(userBucket.getId()); } catch (Exception e) { logger.debug("Lucene Index creation in progress.", e); } }); throw new LuceneIndexCreationInProgressException( "Lucene Index creation in progress for bucket: " + userBucket.getId()); } } } return repos; }
when(userRegionDataStore.getLocalBucketById(1)).thenReturn(userBucket); when(userBucket.isEmpty()).thenReturn(false);
@Override public boolean isIndexingInProgress() { PartitionedRegion userRegion = (PartitionedRegion) cache.getRegion(this.getRegionPath()); Set<Integer> fileRegionPrimaryBucketIds = this.getFileAndChunkRegion().getDataStore().getAllLocalPrimaryBucketIds(); for (Integer bucketId : fileRegionPrimaryBucketIds) { BucketRegion userBucket = userRegion.getDataStore().getLocalBucketById(bucketId); if (!userBucket.isEmpty() && !this.isIndexAvailable(bucketId)) { return true; } } return false; }
if (r != null) { invokeBucketReadHook(); if (!r.isEmpty() || (allowTombstones && r.getTombstoneCount() > 0)) { ret = r.getKeysWithInterest(interestType, interestArg, allowTombstones);