use of org.apache.geode.cache.lucene.internal.filesystem.FileSystemStats in project geode by apache.
the class PartitionedRepositoryManagerJUnitTest method createIndexAndRepoManager.
protected void createIndexAndRepoManager() {
fileAndChunkRegion = Mockito.mock(PartitionedRegion.class);
fileDataStore = Mockito.mock(PartitionedRegionDataStore.class);
when(fileAndChunkRegion.getDataStore()).thenReturn(fileDataStore);
when(fileAndChunkRegion.getTotalNumberOfBuckets()).thenReturn(113);
when(fileAndChunkRegion.getFullPath()).thenReturn("FileRegion");
indexStats = Mockito.mock(LuceneIndexStats.class);
fileSystemStats = Mockito.mock(FileSystemStats.class);
indexForPR = Mockito.mock(LuceneIndexForPartitionedRegion.class);
when(((LuceneIndexForPartitionedRegion) indexForPR).getFileAndChunkRegion()).thenReturn(fileAndChunkRegion);
when(((LuceneIndexForPartitionedRegion) indexForPR).getFileSystemStats()).thenReturn(fileSystemStats);
when(indexForPR.getIndexStats()).thenReturn(indexStats);
when(indexForPR.getAnalyzer()).thenReturn(new StandardAnalyzer());
when(indexForPR.getCache()).thenReturn(cache);
when(indexForPR.getRegionPath()).thenReturn("/testRegion");
repoManager = new PartitionedRepositoryManager(indexForPR, serializer);
repoManager.setUserRegionForRepositoryManager();
repoManager.allowRepositoryComputation();
}
use of org.apache.geode.cache.lucene.internal.filesystem.FileSystemStats in project geode by apache.
the class IndexRepositoryImplJUnitTest method setUp.
@Before
public void setUp() throws IOException {
ConcurrentHashMap fileAndChunkRegion = new ConcurrentHashMap();
fileSystemStats = mock(FileSystemStats.class);
RegionDirectory dir = new RegionDirectory(fileAndChunkRegion, fileSystemStats);
IndexWriterConfig config = new IndexWriterConfig(analyzer);
writer = new IndexWriter(dir, config);
String[] indexedFields = new String[] { "s", "i", "l", "d", "f", "s2", "missing" };
mapper = new HeterogeneousLuceneSerializer(indexedFields);
region = Mockito.mock(Region.class);
userRegion = Mockito.mock(BucketRegion.class);
BucketAdvisor bucketAdvisor = Mockito.mock(BucketAdvisor.class);
Mockito.when(bucketAdvisor.isPrimary()).thenReturn(true);
Mockito.when(((BucketRegion) userRegion).getBucketAdvisor()).thenReturn(bucketAdvisor);
Mockito.when(((BucketRegion) userRegion).getBucketAdvisor().isPrimary()).thenReturn(true);
stats = Mockito.mock(LuceneIndexStats.class);
Mockito.when(userRegion.isDestroyed()).thenReturn(false);
repo = new IndexRepositoryImpl(region, writer, mapper, stats, userRegion, mock(DistributedLockService.class), "lockName");
}
use of org.apache.geode.cache.lucene.internal.filesystem.FileSystemStats 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