use of org.apache.geode.cache.lucene.internal.LuceneIndexImpl in project geode by apache.
the class LuceneDescribeIndexFunction method execute.
public void execute(final FunctionContext context) {
LuceneIndexDetails result = null;
final Cache cache = getCache();
final String serverName = cache.getDistributedSystem().getDistributedMember().getName();
final LuceneIndexInfo indexInfo = (LuceneIndexInfo) context.getArguments();
LuceneServiceImpl service = (LuceneServiceImpl) LuceneServiceProvider.get(cache);
LuceneIndex index = service.getIndex(indexInfo.getIndexName(), indexInfo.getRegionPath());
LuceneIndexCreationProfile profile = service.getDefinedIndex(indexInfo.getIndexName(), indexInfo.getRegionPath());
if (index != null) {
result = new LuceneIndexDetails((LuceneIndexImpl) index, serverName);
} else if (profile != null) {
result = new LuceneIndexDetails(profile, serverName);
}
context.getResultSender().lastResult(result);
}
use of org.apache.geode.cache.lucene.internal.LuceneIndexImpl in project geode by apache.
the class LuceneServiceBridge method listIndexMetrics.
public LuceneIndexMetrics[] listIndexMetrics() {
Collection<LuceneIndex> indexes = this.service.getAllIndexes();
LuceneIndexMetrics[] indexMetrics = new LuceneIndexMetrics[indexes.size()];
int i = 0;
for (LuceneIndex index : this.service.getAllIndexes()) {
indexMetrics[i++] = getIndexMetrics((LuceneIndexImpl) index);
}
return indexMetrics;
}
use of org.apache.geode.cache.lucene.internal.LuceneIndexImpl in project geode by apache.
the class LuceneListIndexFunction method execute.
public void execute(final FunctionContext context) {
final Set<LuceneIndexDetails> indexDetailsSet = new HashSet<>();
final Cache cache = getCache();
final String serverName = cache.getDistributedSystem().getDistributedMember().getName();
LuceneServiceImpl service = (LuceneServiceImpl) LuceneServiceProvider.get(cache);
for (LuceneIndex index : service.getAllIndexes()) {
indexDetailsSet.add(new LuceneIndexDetails((LuceneIndexImpl) index, serverName));
}
for (LuceneIndexCreationProfile profile : service.getAllDefinedIndexes()) {
indexDetailsSet.add(new LuceneIndexDetails(profile, serverName));
}
context.getResultSender().lastResult(indexDetailsSet);
}
use of org.apache.geode.cache.lucene.internal.LuceneIndexImpl in project geode by apache.
the class LuceneDescribeIndexFunctionJUnitTest method getMockLuceneIndex.
private LuceneIndexImpl getMockLuceneIndex(final String indexName) {
String[] searchableFields = { "field1", "field2" };
Map<String, Analyzer> fieldAnalyzers = new HashMap<>();
fieldAnalyzers.put("field1", new StandardAnalyzer());
fieldAnalyzers.put("field2", new KeywordAnalyzer());
LuceneIndexImpl index = mock(LuceneIndexImpl.class);
when(index.getName()).thenReturn(indexName);
when(index.getRegionPath()).thenReturn("/region");
when(index.getFieldNames()).thenReturn(searchableFields);
when(index.getFieldAnalyzers()).thenReturn(fieldAnalyzers);
return index;
}
use of org.apache.geode.cache.lucene.internal.LuceneIndexImpl in project geode by apache.
the class IndexRepositorySpy method computeIndexRepository.
@Override
public IndexRepository computeIndexRepository(final Integer bucketId, LuceneSerializer serializer, LuceneIndexImpl index, PartitionedRegion userRegion, IndexRepository oldRepository) throws IOException {
LuceneIndexForPartitionedRegion indexForPR = (LuceneIndexForPartitionedRegion) index;
final IndexRepository indexRepo = super.computeIndexRepository(bucketId, serializer, index, userRegion, oldRepository);
if (indexRepo == null) {
return null;
}
if (mockingDetails(indexRepo).isSpy()) {
return indexRepo;
}
final IndexRepository spy = Mockito.spy(indexRepo);
Answer invokeBeforeWrite = invocation -> {
beforeWrite.accept(invocation.getArgumentAt(0, Object.class));
return invocation.callRealMethod();
};
doAnswer(invokeBeforeWrite).when(spy).update(any(), any());
doAnswer(invokeBeforeWrite).when(spy).create(any(), any());
doAnswer(invokeBeforeWrite).when(spy).delete(any());
return spy;
}
Aggregations