Search in sources :

Example 1 with FileSystemStats

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();
}
Also used : PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) FileSystemStats(org.apache.geode.cache.lucene.internal.filesystem.FileSystemStats) StandardAnalyzer(org.apache.lucene.analysis.standard.StandardAnalyzer) PartitionedRegionDataStore(org.apache.geode.internal.cache.PartitionedRegionDataStore)

Example 2 with FileSystemStats

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");
}
Also used : LuceneIndexStats(org.apache.geode.cache.lucene.internal.LuceneIndexStats) HeterogeneousLuceneSerializer(org.apache.geode.cache.lucene.internal.repository.serializer.HeterogeneousLuceneSerializer) FileSystemStats(org.apache.geode.cache.lucene.internal.filesystem.FileSystemStats) BucketRegion(org.apache.geode.internal.cache.BucketRegion) IndexWriter(org.apache.lucene.index.IndexWriter) BucketRegion(org.apache.geode.internal.cache.BucketRegion) Region(org.apache.geode.cache.Region) BucketAdvisor(org.apache.geode.internal.cache.BucketAdvisor) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) RegionDirectory(org.apache.geode.cache.lucene.internal.directory.RegionDirectory) IndexWriterConfig(org.apache.lucene.index.IndexWriterConfig) Before(org.junit.Before)

Example 3 with FileSystemStats

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

FileSystemStats (org.apache.geode.cache.lucene.internal.filesystem.FileSystemStats)3 Region (org.apache.geode.cache.Region)2 LuceneIndexStats (org.apache.geode.cache.lucene.internal.LuceneIndexStats)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 LuceneIndexForPartitionedRegion (org.apache.geode.cache.lucene.internal.LuceneIndexForPartitionedRegion)1 RegionDirectory (org.apache.geode.cache.lucene.internal.directory.RegionDirectory)1 HeterogeneousLuceneSerializer (org.apache.geode.cache.lucene.internal.repository.serializer.HeterogeneousLuceneSerializer)1 BucketAdvisor (org.apache.geode.internal.cache.BucketAdvisor)1 BucketRegion (org.apache.geode.internal.cache.BucketRegion)1 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)1 PartitionedRegionDataStore (org.apache.geode.internal.cache.PartitionedRegionDataStore)1 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)1 StandardAnalyzer (org.apache.lucene.analysis.standard.StandardAnalyzer)1 IndexWriter (org.apache.lucene.index.IndexWriter)1 IndexWriterConfig (org.apache.lucene.index.IndexWriterConfig)1 Before (org.junit.Before)1 Test (org.junit.Test)1