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);
}
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);
}
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());
});
}
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()));
}
Aggregations