Search in sources :

Example 6 with CqQueryTestListener

use of org.apache.geode.cache.query.cq.dunit.CqQueryTestListener in project geode by apache.

the class HADispatcherDUnitTest method createCQ.

private void createCQ() throws CqException, CqExistsException, RegionNotFoundException {
    QueryService cqService = null;
    try {
        cqService = cache.getQueryService();
    } catch (Exception cqe) {
        cqe.printStackTrace();
        fail("Failed to getCQService.");
    }
    // Create CQ Attributes.
    CqAttributesFactory cqf = new CqAttributesFactory();
    CqListener[] cqListeners = { new CqQueryTestListener(getLogWriter()) };
    cqf.initCqListeners(cqListeners);
    CqAttributes cqa = cqf.create();
    String cqName = "CQForHARegionQueueTest";
    String queryStr = "Select * from " + Region.SEPARATOR + REGION_NAME;
    // Create CQ.
    CqQuery cq1 = cqService.newCq(cqName, queryStr, cqa);
    cq1.execute();
}
Also used : CqQueryTestListener(org.apache.geode.cache.query.cq.dunit.CqQueryTestListener) IOException(java.io.IOException)

Example 7 with CqQueryTestListener

use of org.apache.geode.cache.query.cq.dunit.CqQueryTestListener in project geode by apache.

the class CQListGIIDUnitTest method waitForEvent.

public static void waitForEvent(int event, String cqName, String key) {
    // Get CQ Service.
    QueryService cqService = null;
    try {
        cqService = cache.getQueryService();
    } catch (Exception cqe) {
        Assert.fail("Failed to getCQService.", cqe);
    }
    CqQuery cQuery = cqService.getCq(cqName);
    if (cQuery == null) {
        Assert.fail("Failed to get CqQuery for CQ : " + cqName, new Exception("Failed to get CqQuery for CQ : " + cqName));
    }
    CqAttributes cqAttr = cQuery.getCqAttributes();
    CqListener[] cqListener = cqAttr.getCqListeners();
    CqQueryTestListener listener = (CqQueryTestListener) cqListener[0];
    switch(event) {
        case CREATE:
            listener.waitForCreated(key);
            break;
        case UPDATE:
            listener.waitForUpdated(key);
            break;
        case DESTROY:
            listener.waitForDestroyed(key);
            break;
        case INVALIDATE:
            listener.waitForInvalidated(key);
            break;
        case CLOSE:
            listener.waitForClose();
            break;
        case REGION_CLEAR:
            listener.waitForRegionClear();
            break;
        case REGION_INVALIDATE:
            listener.waitForRegionInvalidate();
            break;
    }
}
Also used : CqQueryTestListener(org.apache.geode.cache.query.cq.dunit.CqQueryTestListener) QueryService(org.apache.geode.cache.query.QueryService) CqAttributes(org.apache.geode.cache.query.CqAttributes) CqListener(org.apache.geode.cache.query.CqListener) CqQuery(org.apache.geode.cache.query.CqQuery) IOException(java.io.IOException) CacheException(org.apache.geode.cache.CacheException)

Example 8 with CqQueryTestListener

use of org.apache.geode.cache.query.cq.dunit.CqQueryTestListener in project geode by apache.

the class ClientCQPostAuthorizationDUnitTest method createCQ.

private void createCQ(final int num) throws CqException, CqExistsException {
    for (int i = 0; i < num; i++) {
        QueryService cqService = getProxyCaches(i).getQueryService();
        String cqName = "CQ_" + i;
        String queryStr = cqNameToQueryStrings.get(cqName) + getProxyCaches(i).getRegion(REGION_NAME).getFullPath();
        // Create CQ Attributes.
        CqAttributesFactory cqf = new CqAttributesFactory();
        CqListener[] cqListeners = { new CqQueryTestListener(getLogWriter()) };
        ((CqQueryTestListener) cqListeners[0]).cqName = cqName;
        cqf.initCqListeners(cqListeners);
        CqAttributes cqa = cqf.create();
        // Create CQ.
        CqQuery cq1 = cqService.newCq(cqName, queryStr, cqa);
        assertTrue("newCq() state mismatch", cq1.getState().isStopped());
    }
}
Also used : CqQueryTestListener(org.apache.geode.cache.query.cq.dunit.CqQueryTestListener) QueryService(org.apache.geode.cache.query.QueryService) CqAttributes(org.apache.geode.cache.query.CqAttributes) CqListener(org.apache.geode.cache.query.CqListener) CqAttributesFactory(org.apache.geode.cache.query.CqAttributesFactory) InternalCqQuery(org.apache.geode.cache.query.internal.cq.InternalCqQuery) CqQuery(org.apache.geode.cache.query.CqQuery)

Example 9 with CqQueryTestListener

use of org.apache.geode.cache.query.cq.dunit.CqQueryTestListener in project geode by apache.

the class ClientCQPostAuthorizationDUnitTest method waitForLastKey.

private void waitForLastKey(final int cqIndex) {
    String cqName = "CQ_" + cqIndex;
    QueryService qService = getProxyCaches(cqIndex).getQueryService();
    ClientCQImpl cqQuery = (ClientCQImpl) qService.getCq(cqName);
    ((CqQueryTestListener) cqQuery.getCqListeners()[0]).waitForCreated("LAST_KEY");
}
Also used : ClientCQImpl(org.apache.geode.cache.query.internal.cq.ClientCQImpl) CqQueryTestListener(org.apache.geode.cache.query.cq.dunit.CqQueryTestListener) QueryService(org.apache.geode.cache.query.QueryService)

Example 10 with CqQueryTestListener

use of org.apache.geode.cache.query.cq.dunit.CqQueryTestListener in project geode by apache.

the class ClientCQPostAuthorizationDUnitTest method waitForLastKeyUpdate.

private void waitForLastKeyUpdate(final int cqIndex) {
    String cqName = "CQ_" + cqIndex;
    QueryService qService = getProxyCaches(cqIndex).getQueryService();
    ClientCQImpl cqQuery = (ClientCQImpl) qService.getCq(cqName);
    ((CqQueryTestListener) cqQuery.getCqListeners()[0]).waitForUpdated("LAST_KEY");
}
Also used : ClientCQImpl(org.apache.geode.cache.query.internal.cq.ClientCQImpl) CqQueryTestListener(org.apache.geode.cache.query.cq.dunit.CqQueryTestListener) QueryService(org.apache.geode.cache.query.QueryService)

Aggregations

CqQueryTestListener (org.apache.geode.cache.query.cq.dunit.CqQueryTestListener)11 QueryService (org.apache.geode.cache.query.QueryService)10 CqAttributes (org.apache.geode.cache.query.CqAttributes)7 CqListener (org.apache.geode.cache.query.CqListener)7 CqQuery (org.apache.geode.cache.query.CqQuery)7 CqAttributesFactory (org.apache.geode.cache.query.CqAttributesFactory)6 CacheException (org.apache.geode.cache.CacheException)5 IOException (java.io.IOException)3 Region (org.apache.geode.cache.Region)3 SelectResults (org.apache.geode.cache.query.SelectResults)3 Struct (org.apache.geode.cache.query.Struct)3 TestObject (org.apache.geode.cache.query.dunit.PdxQueryCQTestBase.TestObject)3 ClientCQImpl (org.apache.geode.cache.query.internal.cq.ClientCQImpl)3 CacheSerializableRunnable (org.apache.geode.cache30.CacheSerializableRunnable)3 Host (org.apache.geode.test.dunit.Host)3 SerializableRunnable (org.apache.geode.test.dunit.SerializableRunnable)3 VM (org.apache.geode.test.dunit.VM)3 ClientSubscriptionTest (org.apache.geode.test.junit.categories.ClientSubscriptionTest)3 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)3 SerializationTest (org.apache.geode.test.junit.categories.SerializationTest)3