use of org.apache.geode.cache.query.CqServiceStatistics in project geode by apache.
the class CqStatsUsingPoolDUnitTest method validateCQServiceStats.
private void validateCQServiceStats(VM vm, final int created, final int activated, final int stopped, final int closed, final int cqsOnClient, final int cqsOnRegion, final int clientsWithCqs) {
vm.invoke(new CacheSerializableRunnable("Validate CQ Service Stats") {
@Override
public void run2() throws CacheException {
LogWriterUtils.getLogWriter().info("### Validating CQ Service Stats. ### ");
// Get CQ Service.
QueryService qService = null;
try {
qService = getCache().getQueryService();
} catch (Exception cqe) {
cqe.printStackTrace();
fail("Failed to getCQService.");
}
CqServiceStatistics cqServiceStats = null;
cqServiceStats = qService.getCqStatistics();
CqServiceVsdStats cqServiceVsdStats = null;
try {
cqServiceVsdStats = ((CqServiceImpl) ((DefaultQueryService) qService).getCqService()).stats();
} catch (CqException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if (cqServiceStats == null) {
fail("Failed to get CQ Service Stats");
}
getCache().getLogger().info("#### CQ Service stats: " + " CQs created: " + cqServiceStats.numCqsCreated() + " CQs active: " + cqServiceStats.numCqsActive() + " CQs stopped: " + cqServiceStats.numCqsStopped() + " CQs closed: " + cqServiceStats.numCqsClosed() + " CQs on Client: " + cqServiceStats.numCqsOnClient() + " CQs on region /root/regionA : " + cqServiceVsdStats.numCqsOnRegion(GemFireCacheImpl.getInstance(), "/root/regionA") + " Clients with CQs: " + cqServiceVsdStats.getNumClientsWithCqs());
// Check for created count.
if (created != CqQueryUsingPoolDUnitTest.noTest) {
assertEquals("Number of CQs created mismatch", created, cqServiceStats.numCqsCreated());
}
// Check for activated count.
if (activated != CqQueryUsingPoolDUnitTest.noTest) {
assertEquals("Number of CQs activated mismatch", activated, cqServiceStats.numCqsActive());
}
// Check for stopped count.
if (stopped != CqQueryUsingPoolDUnitTest.noTest) {
assertEquals("Number of CQs stopped mismatch", stopped, cqServiceStats.numCqsStopped());
}
// Check for closed count.
if (closed != CqQueryUsingPoolDUnitTest.noTest) {
assertEquals("Number of CQs closed mismatch", closed, cqServiceStats.numCqsClosed());
}
// Check for CQs on client count.
if (cqsOnClient != CqQueryUsingPoolDUnitTest.noTest) {
assertEquals("Number of CQs on client mismatch", cqsOnClient, cqServiceStats.numCqsOnClient());
}
// Check for CQs on region.
if (cqsOnRegion != CqQueryUsingPoolDUnitTest.noTest) {
assertEquals("Number of CQs on region /root/regionA mismatch", cqsOnRegion, cqServiceVsdStats.numCqsOnRegion(GemFireCacheImpl.getInstance(), "/root/regionA"));
}
// Check for clients with CQs count.
if (clientsWithCqs != CqQueryUsingPoolDUnitTest.noTest) {
assertEquals("Clints with CQs mismatch", clientsWithCqs, cqServiceVsdStats.getNumClientsWithCqs());
}
}
});
}
use of org.apache.geode.cache.query.CqServiceStatistics in project geode by apache.
the class CqStatsDUnitTest method validateCQServiceStats.
private void validateCQServiceStats(VM vm, final int created, final int activated, final int stopped, final int closed, final int cqsOnClient, final int cqsOnRegion, final int clientsWithCqs) {
vm.invoke(new CacheSerializableRunnable("Validate CQ Service Stats") {
@Override
public void run2() throws CacheException {
LogWriterUtils.getLogWriter().info("### Validating CQ Service Stats. ### ");
// Get CQ Service.
QueryService qService = null;
try {
qService = getCache().getQueryService();
} catch (Exception cqe) {
cqe.printStackTrace();
fail("Failed to getCQService.");
}
CqServiceStatistics cqServiceStats = null;
cqServiceStats = qService.getCqStatistics();
CqServiceVsdStats cqServiceVsdStats = null;
try {
cqServiceVsdStats = ((CqServiceImpl) ((DefaultQueryService) qService).getCqService()).stats();
} catch (CqException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if (cqServiceStats == null) {
fail("Failed to get CQ Service Stats");
}
getCache().getLogger().info("#### CQ Service stats: " + " CQs created: " + cqServiceStats.numCqsCreated() + " CQs active: " + cqServiceStats.numCqsActive() + " CQs stopped: " + cqServiceStats.numCqsStopped() + " CQs closed: " + cqServiceStats.numCqsClosed() + " CQs on Client: " + cqServiceStats.numCqsOnClient() + " CQs on region /root/regionA : " + cqServiceVsdStats.numCqsOnRegion(GemFireCacheImpl.getInstance(), "/root/regionA") + " Clients with CQs: " + cqServiceVsdStats.getNumClientsWithCqs());
// Check for created count.
if (created != CqQueryDUnitTest.noTest) {
assertEquals("Number of CQs created mismatch", created, cqServiceStats.numCqsCreated());
}
// Check for activated count.
if (activated != CqQueryDUnitTest.noTest) {
assertEquals("Number of CQs activated mismatch", activated, cqServiceStats.numCqsActive());
}
// Check for stopped count.
if (stopped != CqQueryDUnitTest.noTest) {
assertEquals("Number of CQs stopped mismatch", stopped, cqServiceStats.numCqsStopped());
}
// Check for closed count.
if (closed != CqQueryDUnitTest.noTest) {
assertEquals("Number of CQs closed mismatch", closed, cqServiceStats.numCqsClosed());
}
// Check for CQs on client count.
if (cqsOnClient != CqQueryDUnitTest.noTest) {
assertEquals("Number of CQs on client mismatch", cqsOnClient, cqServiceStats.numCqsOnClient());
}
// Check for CQs on region.
if (cqsOnRegion != CqQueryDUnitTest.noTest) {
assertEquals("Number of CQs on region /root/regionA mismatch", cqsOnRegion, cqServiceVsdStats.numCqsOnRegion(GemFireCacheImpl.getInstance(), "/root/regionA"));
}
// Check for clients with CQs count.
if (clientsWithCqs != CqQueryDUnitTest.noTest) {
assertEquals("Clints with CQs mismatch", clientsWithCqs, cqServiceVsdStats.getNumClientsWithCqs());
}
}
});
}
Aggregations