Search in sources :

Example 21 with LuceneService

use of org.apache.geode.cache.lucene.LuceneService in project geode by apache.

the class LuceneIndexCommandsDUnitTest method putEntries.

private void putEntries(final VM vm1, Map<String, TestObject> entries, int countOfDocuments) {
    Cache cache = getCache();
    vm1.invoke(() -> {
        LuceneService luceneService = LuceneServiceProvider.get(getCache());
        Region region = getCache().getRegion(REGION_NAME);
        region.putAll(entries);
        luceneService.waitUntilFlushed(INDEX_NAME, REGION_NAME, 60000, TimeUnit.MILLISECONDS);
        LuceneIndexImpl index = (LuceneIndexImpl) luceneService.getIndex(INDEX_NAME, REGION_NAME);
        Awaitility.await().atMost(65, TimeUnit.SECONDS).until(() -> assertEquals(countOfDocuments, index.getIndexStats().getDocuments()));
    });
}
Also used : Region(org.apache.geode.cache.Region) LuceneIndexImpl(org.apache.geode.cache.lucene.internal.LuceneIndexImpl) Cache(org.apache.geode.cache.Cache) LuceneService(org.apache.geode.cache.lucene.LuceneService)

Example 22 with LuceneService

use of org.apache.geode.cache.lucene.LuceneService in project geode by apache.

the class LuceneServiceImplIntegrationTest method getCacheShouldReturnTheCorrectCache.

@Test
public void getCacheShouldReturnTheCorrectCache() {
    cache = getCache();
    new LuceneServiceImpl().init(cache);
    LuceneService service = LuceneServiceProvider.get(cache);
    assertTrue(service.getCache().equals(cache));
}
Also used : LuceneService(org.apache.geode.cache.lucene.LuceneService) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 23 with LuceneService

use of org.apache.geode.cache.lucene.LuceneService in project geode by apache.

the class LuceneIndexXmlParserIntegrationJUnitTest method createIndex.

/**
   * Test that the Index creation objects get appropriately translated into a real index.
   * 
   * @throws FileNotFoundException
   */
@Test
public void createIndex() throws FileNotFoundException {
    CacheFactory cf = new CacheFactory();
    cf.set(MCAST_PORT, "0");
    cf.set(CACHE_XML_FILE, getXmlFileForTest());
    Cache cache = cf.create();
    LuceneService service = LuceneServiceProvider.get(cache);
    assertEquals(3, service.getAllIndexes().size());
    LuceneIndex index1 = service.getIndex("index1", "/region");
    LuceneIndex index2 = service.getIndex("index2", "/region");
    LuceneIndex index3 = service.getIndex("index3", "/region");
    assertArrayEquals(index1.getFieldNames(), new String[] { "a", "b", "c", "d" });
    assertArrayEquals(index2.getFieldNames(), new String[] { "f", "g" });
    assertArrayEquals(index3.getFieldNames(), new String[] { "h", "i", "j" });
}
Also used : LuceneIndex(org.apache.geode.cache.lucene.LuceneIndex) CacheFactory(org.apache.geode.cache.CacheFactory) Cache(org.apache.geode.cache.Cache) LuceneService(org.apache.geode.cache.lucene.LuceneService) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Aggregations

LuceneService (org.apache.geode.cache.lucene.LuceneService)23 LuceneIndex (org.apache.geode.cache.lucene.LuceneIndex)10 Test (org.junit.Test)10 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)6 Analyzer (org.apache.lucene.analysis.Analyzer)6 StandardAnalyzer (org.apache.lucene.analysis.standard.StandardAnalyzer)6 Cache (org.apache.geode.cache.Cache)5 KeywordAnalyzer (org.apache.lucene.analysis.core.KeywordAnalyzer)5 CommandStringBuilder (org.apache.geode.management.internal.cli.util.CommandStringBuilder)4 VM (org.apache.geode.test.dunit.VM)4 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)4 LuceneIndexImpl (org.apache.geode.cache.lucene.internal.LuceneIndexImpl)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 CacheFactory (org.apache.geode.cache.CacheFactory)2 Region (org.apache.geode.cache.Region)2 RegionFunctionContext (org.apache.geode.cache.execute.RegionFunctionContext)2 LuceneServiceImpl (org.apache.geode.cache.lucene.internal.LuceneServiceImpl)2 CliFunctionResult (org.apache.geode.management.internal.cli.functions.CliFunctionResult)2 MemberVM (org.apache.geode.test.dunit.rules.MemberVM)2