Search in sources :

Example 1 with LuceneIndexImpl

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);
}
Also used : LuceneIndexInfo(org.apache.geode.cache.lucene.internal.cli.LuceneIndexInfo) LuceneIndex(org.apache.geode.cache.lucene.LuceneIndex) LuceneIndexDetails(org.apache.geode.cache.lucene.internal.cli.LuceneIndexDetails) LuceneServiceImpl(org.apache.geode.cache.lucene.internal.LuceneServiceImpl) LuceneIndexCreationProfile(org.apache.geode.cache.lucene.internal.LuceneIndexCreationProfile) LuceneIndexImpl(org.apache.geode.cache.lucene.internal.LuceneIndexImpl) Cache(org.apache.geode.cache.Cache)

Example 2 with LuceneIndexImpl

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;
}
Also used : LuceneIndex(org.apache.geode.cache.lucene.LuceneIndex) LuceneIndexMetrics(org.apache.geode.cache.lucene.management.LuceneIndexMetrics) LuceneIndexImpl(org.apache.geode.cache.lucene.internal.LuceneIndexImpl)

Example 3 with LuceneIndexImpl

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);
}
Also used : LuceneIndex(org.apache.geode.cache.lucene.LuceneIndex) LuceneIndexDetails(org.apache.geode.cache.lucene.internal.cli.LuceneIndexDetails) LuceneServiceImpl(org.apache.geode.cache.lucene.internal.LuceneServiceImpl) LuceneIndexImpl(org.apache.geode.cache.lucene.internal.LuceneIndexImpl) LuceneIndexCreationProfile(org.apache.geode.cache.lucene.internal.LuceneIndexCreationProfile) HashSet(java.util.HashSet) Cache(org.apache.geode.cache.Cache)

Example 4 with LuceneIndexImpl

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;
}
Also used : KeywordAnalyzer(org.apache.lucene.analysis.core.KeywordAnalyzer) HashMap(java.util.HashMap) StandardAnalyzer(org.apache.lucene.analysis.standard.StandardAnalyzer) Analyzer(org.apache.lucene.analysis.Analyzer) KeywordAnalyzer(org.apache.lucene.analysis.core.KeywordAnalyzer) StandardAnalyzer(org.apache.lucene.analysis.standard.StandardAnalyzer) LuceneIndexImpl(org.apache.geode.cache.lucene.internal.LuceneIndexImpl)

Example 5 with LuceneIndexImpl

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;
}
Also used : Matchers.any(org.mockito.Matchers.any) Consumer(java.util.function.Consumer) Mockito(org.mockito.Mockito) Answer(org.mockito.stubbing.Answer) IndexRepositoryFactory(org.apache.geode.cache.lucene.internal.IndexRepositoryFactory) LuceneIndexForPartitionedRegion(org.apache.geode.cache.lucene.internal.LuceneIndexForPartitionedRegion) IOException(java.io.IOException) LuceneSerializer(org.apache.geode.cache.lucene.internal.repository.serializer.LuceneSerializer) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) LuceneIndexImpl(org.apache.geode.cache.lucene.internal.LuceneIndexImpl) PartitionedRepositoryManager(org.apache.geode.cache.lucene.internal.PartitionedRepositoryManager) IndexRepository(org.apache.geode.cache.lucene.internal.repository.IndexRepository) Answer(org.mockito.stubbing.Answer) IndexRepository(org.apache.geode.cache.lucene.internal.repository.IndexRepository) LuceneIndexForPartitionedRegion(org.apache.geode.cache.lucene.internal.LuceneIndexForPartitionedRegion)

Aggregations

LuceneIndexImpl (org.apache.geode.cache.lucene.internal.LuceneIndexImpl)14 Cache (org.apache.geode.cache.Cache)5 LuceneServiceImpl (org.apache.geode.cache.lucene.internal.LuceneServiceImpl)5 Region (org.apache.geode.cache.Region)4 LuceneIndex (org.apache.geode.cache.lucene.LuceneIndex)4 LuceneIndexDetails (org.apache.geode.cache.lucene.internal.cli.LuceneIndexDetails)4 LuceneService (org.apache.geode.cache.lucene.LuceneService)3 Test (org.junit.Test)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 CacheClosedException (org.apache.geode.cache.CacheClosedException)2 FunctionContext (org.apache.geode.cache.execute.FunctionContext)2 RegionFunctionContext (org.apache.geode.cache.execute.RegionFunctionContext)2 ResultSender (org.apache.geode.cache.execute.ResultSender)2 LuceneIndexCreationProfile (org.apache.geode.cache.lucene.internal.LuceneIndexCreationProfile)2 LuceneIndexForPartitionedRegion (org.apache.geode.cache.lucene.internal.LuceneIndexForPartitionedRegion)2 LuceneIndexInfo (org.apache.geode.cache.lucene.internal.cli.LuceneIndexInfo)2 IndexRepository (org.apache.geode.cache.lucene.internal.repository.IndexRepository)2 GemFireCacheImpl (org.apache.geode.internal.cache.GemFireCacheImpl)2