Search in sources :

Example 1 with SearchStatistics

use of org.infinispan.query.core.stats.SearchStatistics 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 SearchStatistics

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

the class StatsTest method testNonIndexedQueryStats.

private void testNonIndexedQueryStats() {
    executeQuery(nonIndexedQuery, cache0);
    assertEquals(queryStatistics0.getNonIndexedQueryCount(), 1);
    assertEquals(queryStatistics1.getNonIndexedQueryCount(), 0);
    assertEquals(queryStatistics2.getNonIndexedQueryCount(), 0);
    SearchStatistics clustered1 = await(Search.getClusteredSearchStatistics(cache1));
    assertEquals(clustered1.getQueryStatistics().getNonIndexedQueryCount(), 1);
    executeQuery(nonIndexedQuery, cache1);
    assertEquals(queryStatistics0.getNonIndexedQueryCount(), 1);
    assertEquals(queryStatistics1.getNonIndexedQueryCount(), 1);
    assertEquals(queryStatistics2.getNonIndexedQueryCount(), 0);
    SearchStatistics clustered2 = await(Search.getClusteredSearchStatistics(cache2));
    assertEquals(clustered2.getQueryStatistics().getNonIndexedQueryCount(), 2);
    executeQuery(nonIndexedQuery, cache2);
    assertEquals(queryStatistics0.getNonIndexedQueryCount(), 1);
    assertEquals(queryStatistics1.getNonIndexedQueryCount(), 1);
    assertEquals(queryStatistics2.getNonIndexedQueryCount(), 1);
    SearchStatistics clustered0 = await(Search.getClusteredSearchStatistics(cache0));
    assertEquals(clustered0.getQueryStatistics().getNonIndexedQueryCount(), 3);
}
Also used : SearchStatistics(org.infinispan.query.core.stats.SearchStatistics)

Example 3 with SearchStatistics

use of org.infinispan.query.core.stats.SearchStatistics 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 4 with SearchStatistics

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

the class StatsTest method testHybridQueryStats.

private void testHybridQueryStats() {
    executeQuery(hybridQuery, cache0);
    assertEquals(queryStatistics0.getHybridQueryCount(), 1);
    assertEquals(queryStatistics0.getLocalIndexedQueryCount(), 4);
    assertEquals(queryStatistics0.getDistributedIndexedQueryCount(), 2);
    assertEquals(queryStatistics1.getHybridQueryCount(), 0);
    assertEquals(queryStatistics1.getLocalIndexedQueryCount(), 4);
    assertEquals(queryStatistics1.getDistributedIndexedQueryCount(), 1);
    assertEquals(queryStatistics2.getHybridQueryCount(), 0);
    assertEquals(queryStatistics2.getLocalIndexedQueryCount(), 4);
    assertEquals(queryStatistics2.getDistributedIndexedQueryCount(), 1);
    SearchStatistics clustered = await(Search.getClusteredSearchStatistics(cache1));
    assertEquals(clustered.getQueryStatistics().getHybridQueryCount(), 1);
    assertEquals(clustered.getQueryStatistics().getLocalIndexedQueryCount(), 12);
    assertEquals(clustered.getQueryStatistics().getDistributedIndexedQueryCount(), 4);
    executeQuery(hybridQuery, cache1);
    assertEquals(queryStatistics0.getHybridQueryCount(), 1);
    assertEquals(queryStatistics0.getLocalIndexedQueryCount(), 5);
    assertEquals(queryStatistics0.getDistributedIndexedQueryCount(), 2);
    assertEquals(queryStatistics1.getHybridQueryCount(), 1);
    assertEquals(queryStatistics1.getLocalIndexedQueryCount(), 5);
    assertEquals(queryStatistics1.getDistributedIndexedQueryCount(), 2);
    assertEquals(queryStatistics2.getHybridQueryCount(), 0);
    assertEquals(queryStatistics2.getLocalIndexedQueryCount(), 5);
    assertEquals(queryStatistics2.getDistributedIndexedQueryCount(), 1);
    clustered = await(Search.getClusteredSearchStatistics(cache1));
    assertEquals(clustered.getQueryStatistics().getHybridQueryCount(), 2);
    assertEquals(clustered.getQueryStatistics().getLocalIndexedQueryCount(), 15);
    assertEquals(clustered.getQueryStatistics().getDistributedIndexedQueryCount(), 5);
    executeQuery(hybridQuery, cache2);
    assertEquals(queryStatistics0.getHybridQueryCount(), 1);
    assertEquals(queryStatistics0.getLocalIndexedQueryCount(), 6);
    assertEquals(queryStatistics0.getDistributedIndexedQueryCount(), 2);
    assertEquals(queryStatistics1.getHybridQueryCount(), 1);
    assertEquals(queryStatistics1.getLocalIndexedQueryCount(), 6);
    assertEquals(queryStatistics1.getDistributedIndexedQueryCount(), 2);
    assertEquals(queryStatistics2.getHybridQueryCount(), 1);
    assertEquals(queryStatistics2.getLocalIndexedQueryCount(), 6);
    assertEquals(queryStatistics2.getDistributedIndexedQueryCount(), 2);
    clustered = await(Search.getClusteredSearchStatistics(cache1));
    assertEquals(clustered.getQueryStatistics().getHybridQueryCount(), 3);
    assertEquals(clustered.getQueryStatistics().getLocalIndexedQueryCount(), 18);
    assertEquals(clustered.getQueryStatistics().getDistributedIndexedQueryCount(), 6);
}
Also used : SearchStatistics(org.infinispan.query.core.stats.SearchStatistics)

Example 5 with SearchStatistics

use of org.infinispan.query.core.stats.SearchStatistics 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)

Aggregations

SearchStatistics (org.infinispan.query.core.stats.SearchStatistics)12 IndexInfo (org.infinispan.query.core.stats.IndexInfo)4 Test (org.testng.annotations.Test)3 HashSet (java.util.HashSet)2 Configuration (org.infinispan.configuration.cache.Configuration)2 ConfigurationBuilder (org.infinispan.configuration.cache.ConfigurationBuilder)2 EmbeddedCacheManager (org.infinispan.manager.EmbeddedCacheManager)2 IndexStatistics (org.infinispan.query.core.stats.IndexStatistics)2 QueryStatistics (org.infinispan.query.core.stats.QueryStatistics)2 QueryFactory (org.infinispan.query.dsl.QueryFactory)2 MultipleCacheManagersTest (org.infinispan.test.MultipleCacheManagersTest)2 List (java.util.List)1 Set (java.util.Set)1 MBeanServer (javax.management.MBeanServer)1 ObjectName (javax.management.ObjectName)1 Cache (org.infinispan.Cache)1 CacheException (org.infinispan.commons.CacheException)1 ConfigurationWriter (org.infinispan.commons.configuration.io.ConfigurationWriter)1 StringBuilderWriter (org.infinispan.commons.io.StringBuilderWriter)1 GlobalConfiguration (org.infinispan.configuration.global.GlobalConfiguration)1