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