use of org.apache.ignite.internal.processors.performancestatistics.AbstractPerformanceStatisticsTest.ClientType.THIN_CLIENT in project ignite by apache.
the class PerformanceStatisticsQueryTest method runQueryAndCheck.
/**
* Runs query and checks statistics.
*/
private void runQueryAndCheck(GridCacheQueryType expType, Query<?> qry, String expText, boolean hasLogicalReads, boolean hasPhysicalReads) throws Exception {
long startTime = U.currentTimeMillis();
cleanPerformanceStatisticsDir();
startCollectStatistics();
Collection<UUID> expNodeIds = new ArrayList<>();
if (clientType == SERVER) {
srv.cache(DEFAULT_CACHE_NAME).query(qry).getAll();
expNodeIds.add(srv.localNode().id());
} else if (clientType == CLIENT) {
client.cache(DEFAULT_CACHE_NAME).query(qry).getAll();
expNodeIds.add(client.localNode().id());
} else if (clientType == THIN_CLIENT) {
thinClient.cache(DEFAULT_CACHE_NAME).query(qry).getAll();
expNodeIds.addAll(F.nodeIds(client.cluster().forServers().nodes()));
}
Set<UUID> readsNodes = new HashSet<>();
if (hasLogicalReads)
srv.cluster().forServers().nodes().forEach(node -> readsNodes.add(node.id()));
AtomicInteger queryCnt = new AtomicInteger();
AtomicInteger readsCnt = new AtomicInteger();
HashSet<Long> qryIds = new HashSet<>();
stopCollectStatisticsAndRead(new TestHandler() {
@Override
public void query(UUID nodeId, GridCacheQueryType type, String text, long id, long queryStartTime, long duration, boolean success) {
queryCnt.incrementAndGet();
qryIds.add(id);
assertTrue(expNodeIds.contains(nodeId));
assertEquals(expType, type);
assertEquals(expText, text);
assertTrue(queryStartTime >= startTime);
assertTrue(duration >= 0);
assertTrue(success);
}
@Override
public void queryReads(UUID nodeId, GridCacheQueryType type, UUID queryNodeId, long id, long logicalReads, long physicalReads) {
readsCnt.incrementAndGet();
qryIds.add(id);
readsNodes.remove(nodeId);
assertTrue(expNodeIds.contains(queryNodeId));
assertEquals(expType, type);
assertTrue(logicalReads > 0);
assertTrue(hasPhysicalReads ? physicalReads > 0 : physicalReads == 0);
}
});
assertEquals(1, queryCnt.get());
assertTrue("Query reads expected on nodes: " + readsNodes, readsNodes.isEmpty());
assertEquals(1, qryIds.size());
}
Aggregations