Search in sources :

Example 1 with LuceneIndexCreationProfile

use of org.apache.geode.cache.lucene.internal.LuceneIndexCreationProfile 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 LuceneIndexCreationProfile

use of org.apache.geode.cache.lucene.internal.LuceneIndexCreationProfile 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 3 with LuceneIndexCreationProfile

use of org.apache.geode.cache.lucene.internal.LuceneIndexCreationProfile in project geode by apache.

the class LuceneIndexCommandsDUnitTest method createIndexWithoutRegionShouldReturnCorrectResults.

@Test
public void createIndexWithoutRegionShouldReturnCorrectResults() throws Exception {
    final VM vm1 = Host.getHost(0).getVM(1);
    vm1.invoke(() -> {
        getCache();
    });
    CommandStringBuilder csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_CREATE_INDEX);
    csb.addOption(LuceneCliStrings.LUCENE__INDEX_NAME, INDEX_NAME);
    csb.addOption(LuceneCliStrings.LUCENE__REGION_PATH, REGION_NAME);
    csb.addOption(LuceneCliStrings.LUCENE_CREATE_INDEX__FIELD, "field1,field2,field3");
    String resultAsString = executeCommandAndLogResult(csb);
    vm1.invoke(() -> {
        LuceneServiceImpl luceneService = (LuceneServiceImpl) LuceneServiceProvider.get(getCache());
        final ArrayList<LuceneIndexCreationProfile> profiles = new ArrayList<>(luceneService.getAllDefinedIndexes());
        assertEquals(1, profiles.size());
        assertEquals(INDEX_NAME, profiles.get(0).getIndexName());
    });
}
Also used : CommandStringBuilder(org.apache.geode.management.internal.cli.util.CommandStringBuilder) VM(org.apache.geode.test.dunit.VM) ArrayList(java.util.ArrayList) LuceneServiceImpl(org.apache.geode.cache.lucene.internal.LuceneServiceImpl) LuceneIndexCreationProfile(org.apache.geode.cache.lucene.internal.LuceneIndexCreationProfile) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 4 with LuceneIndexCreationProfile

use of org.apache.geode.cache.lucene.internal.LuceneIndexCreationProfile in project geode by apache.

the class LuceneIndexCreationIntegrationTest method shouldReturnAllDefinedIndexes.

@Test
public void shouldReturnAllDefinedIndexes() {
    LuceneServiceImpl luceneServiceImpl = (LuceneServiceImpl) luceneService;
    luceneServiceImpl.createIndexFactory().setFields("field1", "field2", "field3").create(INDEX_NAME, REGION_NAME);
    luceneServiceImpl.createIndexFactory().setFields("field4", "field5", "field6").create("index2", "region2");
    final Collection<LuceneIndexCreationProfile> indexList = luceneServiceImpl.getAllDefinedIndexes();
    assertEquals(Arrays.asList(INDEX_NAME, "index2"), indexList.stream().map(LuceneIndexCreationProfile::getIndexName).sorted().collect(Collectors.toList()));
    createRegion();
    assertEquals(Collections.singletonList("index2"), indexList.stream().map(LuceneIndexCreationProfile::getIndexName).collect(Collectors.toList()));
}
Also used : LuceneServiceImpl(org.apache.geode.cache.lucene.internal.LuceneServiceImpl) LuceneIndexCreationProfile(org.apache.geode.cache.lucene.internal.LuceneIndexCreationProfile) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Aggregations

LuceneIndexCreationProfile (org.apache.geode.cache.lucene.internal.LuceneIndexCreationProfile)4 LuceneServiceImpl (org.apache.geode.cache.lucene.internal.LuceneServiceImpl)4 Cache (org.apache.geode.cache.Cache)2 LuceneIndex (org.apache.geode.cache.lucene.LuceneIndex)2 LuceneIndexImpl (org.apache.geode.cache.lucene.internal.LuceneIndexImpl)2 LuceneIndexDetails (org.apache.geode.cache.lucene.internal.cli.LuceneIndexDetails)2 Test (org.junit.Test)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 LuceneIndexInfo (org.apache.geode.cache.lucene.internal.cli.LuceneIndexInfo)1 CommandStringBuilder (org.apache.geode.management.internal.cli.util.CommandStringBuilder)1 VM (org.apache.geode.test.dunit.VM)1 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)1 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)1