Search in sources :

Example 1 with LuceneIndexForPartitionedRegion

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

the class LuceneTestUtilities method verifyInternalRegions.

public static void verifyInternalRegions(LuceneService luceneService, Cache cache, Consumer<LocalRegion> verify) {
    // Get index
    LuceneIndexForPartitionedRegion index = (LuceneIndexForPartitionedRegion) luceneService.getIndex(INDEX_NAME, REGION_NAME);
    LocalRegion fileRegion = (LocalRegion) cache.getRegion(index.createFileRegionName());
    verify.accept(fileRegion);
}
Also used : LuceneIndexForPartitionedRegion(org.apache.geode.cache.lucene.internal.LuceneIndexForPartitionedRegion) LocalRegion(org.apache.geode.internal.cache.LocalRegion)

Example 2 with LuceneIndexForPartitionedRegion

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

Example 3 with LuceneIndexForPartitionedRegion

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

the class LuceneIndexMaintenanceIntegrationTest method statsAreUpdatedAfterACommit.

@Test
public void statsAreUpdatedAfterACommit() throws Exception {
    luceneService.createIndexFactory().setFields("title", "description").create(INDEX_NAME, REGION_NAME);
    Region region = createRegion(REGION_NAME, RegionShortcut.PARTITION);
    region.put("object-1", new TestObject("title 1", "hello world"));
    region.put("object-2", new TestObject("title 2", "this will not match"));
    region.put("object-3", new TestObject("title 3", "hello world"));
    region.put("object-4", new TestObject("hello world", "hello world"));
    LuceneIndexForPartitionedRegion index = (LuceneIndexForPartitionedRegion) luceneService.getIndex(INDEX_NAME, REGION_NAME);
    luceneService.waitUntilFlushed(INDEX_NAME, REGION_NAME, WAIT_FOR_FLUSH_TIME, TimeUnit.MILLISECONDS);
    FileSystemStats fileSystemStats = index.getFileSystemStats();
    LuceneIndexStats indexStats = index.getIndexStats();
    await(() -> assertEquals(4, indexStats.getDocuments()));
    await(() -> assertTrue(fileSystemStats.getBytes() > 0));
}
Also used : LuceneIndexStats(org.apache.geode.cache.lucene.internal.LuceneIndexStats) LuceneIndexForPartitionedRegion(org.apache.geode.cache.lucene.internal.LuceneIndexForPartitionedRegion) FileSystemStats(org.apache.geode.cache.lucene.internal.filesystem.FileSystemStats) LuceneIndexForPartitionedRegion(org.apache.geode.cache.lucene.internal.LuceneIndexForPartitionedRegion) Region(org.apache.geode.cache.Region) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Aggregations

LuceneIndexForPartitionedRegion (org.apache.geode.cache.lucene.internal.LuceneIndexForPartitionedRegion)3 IOException (java.io.IOException)1 Consumer (java.util.function.Consumer)1 Region (org.apache.geode.cache.Region)1 IndexRepositoryFactory (org.apache.geode.cache.lucene.internal.IndexRepositoryFactory)1 LuceneIndexImpl (org.apache.geode.cache.lucene.internal.LuceneIndexImpl)1 LuceneIndexStats (org.apache.geode.cache.lucene.internal.LuceneIndexStats)1 PartitionedRepositoryManager (org.apache.geode.cache.lucene.internal.PartitionedRepositoryManager)1 FileSystemStats (org.apache.geode.cache.lucene.internal.filesystem.FileSystemStats)1 IndexRepository (org.apache.geode.cache.lucene.internal.repository.IndexRepository)1 LuceneSerializer (org.apache.geode.cache.lucene.internal.repository.serializer.LuceneSerializer)1 LocalRegion (org.apache.geode.internal.cache.LocalRegion)1 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)1 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)1 Test (org.junit.Test)1 Matchers.any (org.mockito.Matchers.any)1 Mockito (org.mockito.Mockito)1 Answer (org.mockito.stubbing.Answer)1