Search in sources :

Example 1 with CqServiceVsdStats

use of org.apache.geode.cache.query.internal.cq.CqServiceVsdStats 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());
            }
        }
    });
}
Also used : CacheSerializableRunnable(org.apache.geode.cache30.CacheSerializableRunnable) CacheException(org.apache.geode.cache.CacheException) DefaultQueryService(org.apache.geode.cache.query.internal.DefaultQueryService) QueryService(org.apache.geode.cache.query.QueryService) CqServiceVsdStats(org.apache.geode.cache.query.internal.cq.CqServiceVsdStats) CqException(org.apache.geode.cache.query.CqException) CqException(org.apache.geode.cache.query.CqException) CacheException(org.apache.geode.cache.CacheException) CqServiceStatistics(org.apache.geode.cache.query.CqServiceStatistics) CqServiceImpl(org.apache.geode.cache.query.internal.cq.CqServiceImpl)

Example 2 with CqServiceVsdStats

use of org.apache.geode.cache.query.internal.cq.CqServiceVsdStats 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());
            }
        }
    });
}
Also used : CacheSerializableRunnable(org.apache.geode.cache30.CacheSerializableRunnable) CacheException(org.apache.geode.cache.CacheException) DefaultQueryService(org.apache.geode.cache.query.internal.DefaultQueryService) QueryService(org.apache.geode.cache.query.QueryService) CqServiceVsdStats(org.apache.geode.cache.query.internal.cq.CqServiceVsdStats) CqException(org.apache.geode.cache.query.CqException) CqException(org.apache.geode.cache.query.CqException) CacheException(org.apache.geode.cache.CacheException) CqServiceStatistics(org.apache.geode.cache.query.CqServiceStatistics) CqServiceImpl(org.apache.geode.cache.query.internal.cq.CqServiceImpl)

Aggregations

CacheException (org.apache.geode.cache.CacheException)2 CqException (org.apache.geode.cache.query.CqException)2 CqServiceStatistics (org.apache.geode.cache.query.CqServiceStatistics)2 QueryService (org.apache.geode.cache.query.QueryService)2 DefaultQueryService (org.apache.geode.cache.query.internal.DefaultQueryService)2 CqServiceImpl (org.apache.geode.cache.query.internal.cq.CqServiceImpl)2 CqServiceVsdStats (org.apache.geode.cache.query.internal.cq.CqServiceVsdStats)2 CacheSerializableRunnable (org.apache.geode.cache30.CacheSerializableRunnable)2