Search in sources :

Example 1 with CqStateImpl

use of org.apache.geode.cache.query.internal.CqStateImpl in project geode by apache.

the class CqQueryDUnitTest method waitForCqState.

/**
   * Waits till the CQ state is same as the expected. Waits for max time, if the CQ state is not
   * same as expected throws exception.
   */
public void waitForCqState(VM vm, final String cqName, final int state) {
    vm.invoke(new CacheSerializableRunnable("Wait For cq State") {

        public void run2() throws CacheException {
            // Get CQ Service.
            QueryService cqService = null;
            try {
                cqService = getCache().getQueryService();
            } catch (Exception cqe) {
                cqe.printStackTrace();
                fail("Failed to getCQService.");
            }
            CqQuery cQuery = cqService.getCq(cqName);
            if (cQuery == null) {
                fail("Failed to get CqQuery for CQ : " + cqName);
            }
            // Get CQ State.
            final CqStateImpl cqState = (CqStateImpl) cQuery.getState();
            // Wait max time, till the CQ state is as expected.
            WaitCriterion ev = new WaitCriterion() {

                public boolean done() {
                    return cqState.getState() == state;
                }

                public String description() {
                    return "cqState never became " + state;
                }
            };
            Wait.waitForCriterion(ev, MAX_TIME, 200, true);
        }
    });
}
Also used : WaitCriterion(org.apache.geode.test.dunit.WaitCriterion) 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) CqQuery(org.apache.geode.cache.query.CqQuery) CqStateImpl(org.apache.geode.cache.query.internal.CqStateImpl) CqExistsException(org.apache.geode.cache.query.CqExistsException) RegionNotFoundException(org.apache.geode.cache.query.RegionNotFoundException) CqClosedException(org.apache.geode.cache.query.CqClosedException) IOException(java.io.IOException) CacheException(org.apache.geode.cache.CacheException)

Example 2 with CqStateImpl

use of org.apache.geode.cache.query.internal.CqStateImpl in project geode by apache.

the class FilterProfile method processRegisterCq.

/**
   * adds a new CQ to this profile during a delta operation or deserialization
   * 
   * @param serverCqName the query objects' name
   * @param ServerCQ the new query object
   * @param addToCqMap whether to add the query to this.cqs
   */
void processRegisterCq(String serverCqName, ServerCQ ServerCQ, boolean addToCqMap) {
    ServerCQ cq = (ServerCQ) ServerCQ;
    try {
        CqService cqService = GemFireCacheImpl.getInstance().getCqService();
        cqService.start();
        cq.setCqService(cqService);
        CqStateImpl cqState = (CqStateImpl) cq.getState();
        cq.setName(generateCqName(serverCqName));
        cq.registerCq(null, null, cqState.getState());
    } catch (Exception ex) {
        // Change it to Info level.
        if (logger.isDebugEnabled()) {
            logger.debug("Error while initializing the CQs with FilterProfile for CQ {}, Error : {}", serverCqName, ex.getMessage(), ex);
        }
    }
    if (logger.isDebugEnabled()) {
        logger.debug("Adding CQ to remote members FilterProfile using name: {}", serverCqName);
    }
    if (addToCqMap) {
        this.cqs.put(serverCqName, cq);
    }
    // region is not set on the FilterProfile created for the peer nodes.
    if (cq.getCqBaseRegion() != null) {
        FilterProfile pf = cq.getCqBaseRegion().getFilterProfile();
        if (pf != null) {
            pf.incCqCount();
        }
    }
}
Also used : ServerCQ(org.apache.geode.cache.query.internal.cq.ServerCQ) CqService(org.apache.geode.cache.query.internal.cq.CqService) CqStateImpl(org.apache.geode.cache.query.internal.CqStateImpl) CancelException(org.apache.geode.CancelException) IOException(java.io.IOException)

Example 3 with CqStateImpl

use of org.apache.geode.cache.query.internal.CqStateImpl in project geode by apache.

the class FilterProfile method processSetCqState.

public void processSetCqState(String serverCqName, ServerCQ ServerCQ) {
    ServerCQ cq = (ServerCQ) this.cqs.get(serverCqName);
    if (cq != null) {
        CqStateImpl cqState = (CqStateImpl) ServerCQ.getState();
        cq.setCqState(cqState.getState());
    }
}
Also used : ServerCQ(org.apache.geode.cache.query.internal.cq.ServerCQ) CqStateImpl(org.apache.geode.cache.query.internal.CqStateImpl)

Aggregations

CqStateImpl (org.apache.geode.cache.query.internal.CqStateImpl)3 IOException (java.io.IOException)2 ServerCQ (org.apache.geode.cache.query.internal.cq.ServerCQ)2 CancelException (org.apache.geode.CancelException)1 CacheException (org.apache.geode.cache.CacheException)1 CqClosedException (org.apache.geode.cache.query.CqClosedException)1 CqExistsException (org.apache.geode.cache.query.CqExistsException)1 CqQuery (org.apache.geode.cache.query.CqQuery)1 QueryService (org.apache.geode.cache.query.QueryService)1 RegionNotFoundException (org.apache.geode.cache.query.RegionNotFoundException)1 DefaultQueryService (org.apache.geode.cache.query.internal.DefaultQueryService)1 CqService (org.apache.geode.cache.query.internal.cq.CqService)1 CacheSerializableRunnable (org.apache.geode.cache30.CacheSerializableRunnable)1 WaitCriterion (org.apache.geode.test.dunit.WaitCriterion)1