Search in sources :

Example 1 with IndexInfo

use of org.infinispan.query.core.stats.IndexInfo in project infinispan by infinispan.

the class StatsTest method testEmptyIndexStats.

@Test
public void testEmptyIndexStats() {
    Set<String> expectedEntities = new HashSet<>(Arrays.asList(Person.class.getName(), Transaction.class.getName()));
    Set<String> totalEntities = new HashSet<>();
    for (int i = 0; i < cacheManagers.size(); i++) {
        SearchStatistics searchStatistics = Search.getSearchStatistics(cache(i));
        Map<String, IndexInfo> indexInfos = await(searchStatistics.getIndexStatistics().computeIndexInfos());
        totalEntities.addAll(indexInfos.keySet());
        for (IndexInfo indexInfo : indexInfos.values()) {
            assertEquals(indexInfo.count(), 0L);
            assertThat(indexInfo.size()).isLessThan(MAX_EMPTY_INDEX_SIZE);
        }
    }
    assertEquals(totalEntities, expectedEntities);
    SearchStatistics clusteredStats = await(Search.getClusteredSearchStatistics(cache0));
    Map<String, IndexInfo> classIndexInfoMap = await(clusteredStats.getIndexStatistics().computeIndexInfos());
    assertEquals(classIndexInfoMap.keySet(), expectedEntities);
    Long reduceCount = classIndexInfoMap.values().stream().map(IndexInfo::count).reduce(0L, Long::sum);
    assertEquals(reduceCount.intValue(), 0L);
    Long reduceSize = classIndexInfoMap.values().stream().map(IndexInfo::size).reduce(0L, Long::sum);
    // 2 indexes
    assertThat(reduceSize.longValue()).isLessThan(MAX_EMPTY_INDEX_SIZE * 2);
}
Also used : SearchStatistics(org.infinispan.query.core.stats.SearchStatistics) IndexInfo(org.infinispan.query.core.stats.IndexInfo) HashSet(java.util.HashSet) Test(org.testng.annotations.Test) MultipleCacheManagersTest(org.infinispan.test.MultipleCacheManagersTest)

Example 2 with IndexInfo

use of org.infinispan.query.core.stats.IndexInfo in project infinispan by infinispan.

the class StatsTest method testNonEmptyIndexStats.

@Test
public void testNonEmptyIndexStats() {
    addData();
    Set<String> expectedEntities = new HashSet<>(Arrays.asList(Person.class.getName(), Transaction.class.getName()));
    int expectDocuments = cacheManagers.size() * cache0.getCacheConfiguration().clustering().hash().numOwners();
    flushAll();
    Set<String> totalEntities = new HashSet<>();
    int totalCount = 0;
    long totalSize = 0L;
    for (int i = 0; i < cacheManagers.size(); i++) {
        SearchStatistics searchStatistics = Search.getSearchStatistics(cache(i));
        Map<String, IndexInfo> indexInfos = await(searchStatistics.getIndexStatistics().computeIndexInfos());
        totalEntities.addAll(indexInfos.keySet());
        for (IndexInfo indexInfo : indexInfos.values()) {
            totalCount += indexInfo.count();
            totalSize += indexInfo.size();
        }
    }
    assertEquals(totalEntities, expectedEntities);
    assertEquals(totalCount, expectDocuments);
    assertEquals(totalSize, totalIndexSize());
    SearchStatistics clusteredStats = await(Search.getClusteredSearchStatistics(cache0));
    Map<String, IndexInfo> classIndexInfoMap = await(clusteredStats.getIndexStatistics().computeIndexInfos());
    assertEquals(classIndexInfoMap.keySet(), expectedEntities);
    Long reduceCount = classIndexInfoMap.values().stream().map(IndexInfo::count).reduce(0L, Long::sum);
    int clusteredExpectDocuments = cacheManagers.size() * cache0.getCacheConfiguration().clustering().hash().numOwners();
    assertEquals(reduceCount.intValue(), clusteredExpectDocuments);
    Long reduceSize = classIndexInfoMap.values().stream().map(IndexInfo::size).reduce(0L, Long::sum);
    assertEquals(reduceSize.longValue(), totalIndexSize());
}
Also used : SearchStatistics(org.infinispan.query.core.stats.SearchStatistics) IndexInfo(org.infinispan.query.core.stats.IndexInfo) HashSet(java.util.HashSet) Test(org.testng.annotations.Test) MultipleCacheManagersTest(org.infinispan.test.MultipleCacheManagersTest)

Example 3 with IndexInfo

use of org.infinispan.query.core.stats.IndexInfo in project infinispan by infinispan.

the class LocalMassIndexingTest method assertIndexState.

private void assertIndexState(BiConsumer<IndexInfo, Integer> cacheIndexInfo) {
    IntStream.range(0, NUM_NODES).forEach(i -> {
        Cache<?, ?> cache = cache(i);
        SearchStatistics searchStatistics = Search.getSearchStatistics(cache);
        Map<String, IndexInfo> indexInfo = join(searchStatistics.getIndexStatistics().computeIndexInfos());
        cacheIndexInfo.accept(indexInfo.get(Car.class.getName()), i);
    });
}
Also used : SearchStatistics(org.infinispan.query.core.stats.SearchStatistics) IndexInfo(org.infinispan.query.core.stats.IndexInfo)

Example 4 with IndexInfo

use of org.infinispan.query.core.stats.IndexInfo in project infinispan by infinispan.

the class DistributedMassIndexingTest method assertIndexedEntities.

private void assertIndexedEntities(int expected, Class<?> entityClass, Cache<?, Car> cache) {
    IndexStatisticsSnapshot indexStatistics = await(Search.getClusteredSearchStatistics(cache)).getIndexStatistics();
    IndexInfo indexInfo = indexStatistics.indexInfos().get(entityClass.getName());
    int count = (int) indexInfo.count();
    // each entry is indexed in all owners for redundancy
    final ClusteringConfiguration clusteringConfiguration = cache.getCacheConfiguration().clustering();
    long indexedCount;
    if (clusteringConfiguration.cacheMode().isReplicated()) {
        indexedCount = count / caches().size();
    } else {
        indexedCount = count / clusteringConfiguration.hash().numOwners();
    }
    assertEquals(indexedCount, expected);
}
Also used : IndexStatisticsSnapshot(org.infinispan.query.core.stats.IndexStatisticsSnapshot) IndexInfo(org.infinispan.query.core.stats.IndexInfo) ClusteringConfiguration(org.infinispan.configuration.cache.ClusteringConfiguration)

Example 5 with IndexInfo

use of org.infinispan.query.core.stats.IndexInfo in project infinispan by infinispan.

the class LocalIndexSyncStateTransferTest method getIndexCountPerEntity.

private Map<String, Long> getIndexCountPerEntity(Cache<Integer, Object> cache) {
    IndexStatistics indexStatistics = Search.getSearchStatistics(cache).getIndexStatistics();
    Map<String, IndexInfo> stringIndexInfoMap = await(indexStatistics.computeIndexInfos().toCompletableFuture());
    return stringIndexInfoMap.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue().count()));
}
Also used : IndexStatistics(org.infinispan.query.core.stats.IndexStatistics) AnotherGrassEater(org.infinispan.query.test.AnotherGrassEater) ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) MultipleCacheManagersTest(org.infinispan.test.MultipleCacheManagersTest) IndexStatistics(org.infinispan.query.core.stats.IndexStatistics) FunctionalTestUtils.await(org.infinispan.functional.FunctionalTestUtils.await) Person(org.infinispan.query.test.Person) HashMap(java.util.HashMap) Test(org.testng.annotations.Test) Cache(org.infinispan.Cache) Supplier(java.util.function.Supplier) Collectors(java.util.stream.Collectors) List(java.util.List) CacheMode(org.infinispan.configuration.cache.CacheMode) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) QueryTestSCI(org.infinispan.query.test.QueryTestSCI) Map(java.util.Map) LOCAL_HEAP(org.infinispan.configuration.cache.IndexStorage.LOCAL_HEAP) IndexInfo(org.infinispan.query.core.stats.IndexInfo) Search(org.infinispan.query.Search) IndexInfo(org.infinispan.query.core.stats.IndexInfo) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

IndexInfo (org.infinispan.query.core.stats.IndexInfo)8 SearchStatistics (org.infinispan.query.core.stats.SearchStatistics)4 MultipleCacheManagersTest (org.infinispan.test.MultipleCacheManagersTest)3 Test (org.testng.annotations.Test)3 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 Map (java.util.Map)2 List (java.util.List)1 CompletionStage (java.util.concurrent.CompletionStage)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Supplier (java.util.function.Supplier)1 Collectors (java.util.stream.Collectors)1 LuceneIndexManager (org.hibernate.search.backend.lucene.index.LuceneIndexManager)1 SearchPredicateFactory (org.hibernate.search.engine.search.predicate.dsl.SearchPredicateFactory)1 Cache (org.infinispan.Cache)1 CacheMode (org.infinispan.configuration.cache.CacheMode)1 ClusteringConfiguration (org.infinispan.configuration.cache.ClusteringConfiguration)1 ConfigurationBuilder (org.infinispan.configuration.cache.ConfigurationBuilder)1 LOCAL_HEAP (org.infinispan.configuration.cache.IndexStorage.LOCAL_HEAP)1 FunctionalTestUtils.await (org.infinispan.functional.FunctionalTestUtils.await)1