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