use of org.infinispan.query.core.stats.QueryStatistics in project infinispan by infinispan.
the class QueryCoreTest method testStats.
@Test
public void testStats() {
String q = String.format("FROM %s", Person.class.getName());
// Cache without stats enabled
QueryFactory queryFactory = Search.getQueryFactory(cache);
Query<Person> query = queryFactory.create(q);
query.execute().list();
SearchStatistics searchStatistics = Search.getSearchStatistics(cache);
QueryStatistics queryStatistics = searchStatistics.getQueryStatistics();
IndexStatistics indexStatistics = searchStatistics.getIndexStatistics();
assertTrue(await(indexStatistics.computeIndexInfos()).isEmpty());
assertTrue(await(Search.getClusteredSearchStatistics(cache)).getIndexStatistics().indexInfos().isEmpty());
assertEquals(0, queryStatistics.getNonIndexedQueryCount());
// Cache with stats enabled
queryFactory = Search.getQueryFactory(cacheWithStats);
query = queryFactory.create(String.format("FROM %s", Person.class.getName()));
query.execute().list();
searchStatistics = Search.getSearchStatistics(cacheWithStats);
queryStatistics = searchStatistics.getQueryStatistics();
indexStatistics = searchStatistics.getIndexStatistics();
assertTrue(await(indexStatistics.computeIndexInfos()).isEmpty());
assertTrue(await(Search.getClusteredSearchStatistics(cacheWithStats).thenCompose(s -> s.getIndexStatistics().computeIndexInfos())).isEmpty());
assertEquals(1, queryStatistics.getNonIndexedQueryCount());
assertTrue(queryStatistics.getNonIndexedQueryAvgTime() > 0);
assertTrue(queryStatistics.getNonIndexedQueryMaxTime() > 0);
assertTrue(queryStatistics.getNonIndexedQueryTotalTime() > 0);
assertEquals(q, queryStatistics.getSlowestNonIndexedQuery());
}
use of org.infinispan.query.core.stats.QueryStatistics in project infinispan by infinispan.
the class StatsTest method testClean.
private void testClean() {
queryStatistics0.clear();
queryStatistics1.clear();
queryStatistics2.clear();
SearchStatistics clustered = await(Search.getClusteredSearchStatistics(cache0));
QueryStatistics localQueryStatistics = clustered.getQueryStatistics();
assertEquals(localQueryStatistics.getNonIndexedQueryCount(), 0);
assertEquals(localQueryStatistics.getHybridQueryCount(), 0);
assertEquals(localQueryStatistics.getDistributedIndexedQueryCount(), 0);
assertEquals(localQueryStatistics.getLocalIndexedQueryCount(), 0);
}
Aggregations