Search in sources :

Example 1 with QueryStatistics

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());
}
Also used : IndexStatistics(org.infinispan.query.core.stats.IndexStatistics) SingleCacheManagerTest(org.infinispan.test.SingleCacheManagerTest) ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) QueryStatistics(org.infinispan.query.core.stats.QueryStatistics) IndexStatistics(org.infinispan.query.core.stats.IndexStatistics) FunctionalTestUtils.await(org.infinispan.functional.FunctionalTestUtils.await) Test(org.testng.annotations.Test) QueryFactory(org.infinispan.query.dsl.QueryFactory) Cache(org.infinispan.Cache) AssertJUnit.assertTrue(org.testng.AssertJUnit.assertTrue) SearchStatistics(org.infinispan.query.core.stats.SearchStatistics) List(java.util.List) EmbeddedCacheManager(org.infinispan.manager.EmbeddedCacheManager) Search(org.infinispan.query.core.Search) TestCacheManagerFactory(org.infinispan.test.fwk.TestCacheManagerFactory) Query(org.infinispan.query.dsl.Query) AssertJUnit.assertEquals(org.testng.AssertJUnit.assertEquals) QueryFactory(org.infinispan.query.dsl.QueryFactory) SearchStatistics(org.infinispan.query.core.stats.SearchStatistics) QueryStatistics(org.infinispan.query.core.stats.QueryStatistics) SingleCacheManagerTest(org.infinispan.test.SingleCacheManagerTest) Test(org.testng.annotations.Test)

Example 2 with QueryStatistics

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);
}
Also used : SearchStatistics(org.infinispan.query.core.stats.SearchStatistics) QueryStatistics(org.infinispan.query.core.stats.QueryStatistics)

Aggregations

QueryStatistics (org.infinispan.query.core.stats.QueryStatistics)2 SearchStatistics (org.infinispan.query.core.stats.SearchStatistics)2 List (java.util.List)1 Cache (org.infinispan.Cache)1 ConfigurationBuilder (org.infinispan.configuration.cache.ConfigurationBuilder)1 FunctionalTestUtils.await (org.infinispan.functional.FunctionalTestUtils.await)1 EmbeddedCacheManager (org.infinispan.manager.EmbeddedCacheManager)1 Search (org.infinispan.query.core.Search)1 IndexStatistics (org.infinispan.query.core.stats.IndexStatistics)1 Query (org.infinispan.query.dsl.Query)1 QueryFactory (org.infinispan.query.dsl.QueryFactory)1 SingleCacheManagerTest (org.infinispan.test.SingleCacheManagerTest)1 TestCacheManagerFactory (org.infinispan.test.fwk.TestCacheManagerFactory)1 AssertJUnit.assertEquals (org.testng.AssertJUnit.assertEquals)1 AssertJUnit.assertTrue (org.testng.AssertJUnit.assertTrue)1 Test (org.testng.annotations.Test)1