public LuceneIndexMetrics listIndexMetrics(String regionPath, String indexName) { LuceneIndex index = this.service.getIndex(indexName, regionPath); return index == null ? null : getIndexMetrics(index); }
public static void verifyInternalRegions(LuceneService luceneService, Cache cache, Consumer<LocalRegion> verify) { // Get index LuceneIndexForPartitionedRegion index = (LuceneIndexForPartitionedRegion) luceneService.getIndex(INDEX_NAME, REGION_NAME); LocalRegion fileRegion = (LocalRegion) cache.getRegion(index.createFileRegionName()); verify.accept(fileRegion); }
public static void verifyIndexFinishFlushing(Cache cache, String indexName, String regionName) throws InterruptedException { LuceneService luceneService = LuceneServiceProvider.get(cache); LuceneIndex index = luceneService.getIndex(indexName, regionName); boolean flushed = luceneService.waitUntilFlushed(indexName, regionName, 60000, TimeUnit.MILLISECONDS); assertTrue(flushed); }
LuceneService service = LuceneServiceProvider.get(ctx.getDataSet().getCache()); InternalLuceneIndex index = (InternalLuceneIndex) service.getIndex(indexName, region.getFullPath()); if (index == null) { throw new IllegalStateException(
@Override public void execute(FunctionContext<Object> context) { RegionFunctionContext ctx = (RegionFunctionContext) context; ResultSender<Boolean> resultSender = ctx.getResultSender(); Region region = ctx.getDataSet(); Cache cache = region.getCache(); String indexName = (String) ctx.getArguments(); if (indexName == null) { throw new IllegalArgumentException("Missing index name"); } LuceneService luceneService = LuceneServiceProvider.get(cache); LuceneIndex luceneIndex = luceneService.getIndex(indexName, region.getFullPath()); if (luceneIndex == null) { resultSender.lastResult(false); } else { resultSender.lastResult(luceneIndex.isIndexingInProgress()); } }
private InternalLuceneIndex getLuceneIndex(final Region region, final LuceneFunctionContext<IndexResultCollector> searchContext) { LuceneService service = LuceneServiceProvider.get(region.getCache()); InternalLuceneIndex index = null; try { index = (InternalLuceneIndex) service.getIndex(searchContext.getIndexName(), region.getFullPath()); if (index == null) { while (service instanceof LuceneServiceImpl && (((LuceneServiceImpl) service) .getDefinedIndex(searchContext.getIndexName(), region.getFullPath()) != null)) { try { Thread.sleep(10); } catch (InterruptedException e) { return null; } region.getCache().getCancelCriterion().checkCancelInProgress(null); } index = (InternalLuceneIndex) service.getIndex(searchContext.getIndexName(), region.getFullPath()); } } catch (CacheClosedException e) { throw new InternalFunctionInvocationTargetException( "Cache is closed when attempting to retrieve index:" + region.getFullPath(), e); } return index; }
if (luceneService.getIndex(queryInfo.getIndexName(), queryInfo.getRegionPath()) == null) { throw new Exception("Index " + queryInfo.getIndexName() + " not found on region " + queryInfo.getRegionPath());
/** * @inheritDoc */ @Override public LuceneIndex getObject() throws Exception { if (this.luceneIndex == null) { setLuceneIndex(Optional.ofNullable(resolveLuceneService()) .map((luceneService) -> luceneService.getIndex(getIndexName(), resolveRegionPath())) .orElse(null)); } return this.luceneIndex; }
/** * @inheritDoc */ @Override public LuceneIndex getObject() throws Exception { if (this.luceneIndex == null) { setLuceneIndex(Optional.ofNullable(resolveLuceneService()) .map((luceneService) -> luceneService.getIndex(getIndexName(), resolveRegionPath())) .orElse(null)); } return this.luceneIndex; }
when(mockLuceneService.getIndex(anyString(), anyString())).thenAnswer(invocation -> {
/** * Attempts to resolve a {@link LuceneIndex} by the given {@link String indexName} first then attempts to create * the {@link LuceneIndex} with the given {@link Region#getFullPath() Region path}. * * @param indexName {@link String name} of the {@link LuceneIndex} to resolve. * @param regionPath {@link Region#getFullPath() Region path} on which the {@link LuceneIndex} is applied. * @return the resolved {@link LuceneIndex} by the given {@link String indexName} or the created {@link LuceneIndex} * with the given {@link Region#getFullPath() Region path} if the {@link LuceneIndex} could not be resolved by * {@link String indexName}. * @see org.apache.geode.cache.lucene.LuceneService#getIndex(String, String) * @see #createLuceneIndex(String, String) * @see #getLuceneIndex() */ protected LuceneIndex resolveLuceneIndex(String indexName, String regionPath) { Supplier<LuceneIndex> luceneIndexSupplier = () -> Optional.ofNullable(resolveLuceneService()) .map(luceneService -> luceneService.getIndex(indexName, regionPath)) .orElseGet(() -> postProcess(createLuceneIndex(indexName, regionPath))); return getLuceneIndex().orElseGet(luceneIndexSupplier); }
/** * Attempts to resolve a {@link LuceneIndex} by the given {@link String indexName} first then attempts to create * the {@link LuceneIndex} with the given {@link Region#getFullPath() Region path}. * * @param indexName {@link String name} of the {@link LuceneIndex} to resolve. * @param regionPath {@link Region#getFullPath() Region path} on which the {@link LuceneIndex} is applied. * @return the resolved {@link LuceneIndex} by the given {@link String indexName} or the created {@link LuceneIndex} * with the given {@link Region#getFullPath() Region path} if the {@link LuceneIndex} could not be resolved by * {@link String indexName}. * @see org.apache.geode.cache.lucene.LuceneService#getIndex(String, String) * @see #createLuceneIndex(String, String) * @see #getLuceneIndex() */ protected LuceneIndex resolveLuceneIndex(String indexName, String regionPath) { Supplier<LuceneIndex> luceneIndexSupplier = () -> Optional.ofNullable(resolveLuceneService()) .map(luceneService -> luceneService.getIndex(indexName, regionPath)) .orElseGet(() -> postProcess(createLuceneIndex(indexName, regionPath))); return getLuceneIndex().orElseGet(luceneIndexSupplier); }
indexFactory.create(indexName, regionPath); return luceneService.getIndex(indexName, regionPath);
indexFactory.create(indexName, regionPath); return luceneService.getIndex(indexName, regionPath);