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