Search in sources :

Example 41 with CqException

use of org.apache.geode.cache.query.CqException in project geode by apache.

the class CqStatsUsingPoolDUnitTest method validateCQStats.

private void validateCQStats(VM vm, final String cqName, final int creates, final int updates, final int deletes, final int totalEvents, final int cqListenerInvocations) {
    vm.invoke(new CacheSerializableRunnable("Validate CQs") {

        @Override
        public void run2() throws CacheException {
            LogWriterUtils.getLogWriter().info("### Validating CQ Stats. ### " + cqName);
            // Get CQ Service.
            QueryService qService = null;
            try {
                qService = getCache().getQueryService();
            } catch (Exception cqe) {
                cqe.printStackTrace();
                fail("Failed to get query service.");
            }
            CqService cqService = null;
            try {
                cqService = ((DefaultQueryService) qService).getCqService();
            } catch (CqException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
                fail("Failed to get CqService, CQ : " + cqName);
            }
            Collection<? extends InternalCqQuery> cqs = cqService.getAllCqs();
            if (cqs.size() == 0) {
                fail("Failed to get CqQuery for CQ : " + cqName);
            }
            CqQueryImpl cQuery = (CqQueryImpl) cqs.iterator().next();
            CqStatistics cqStats = cQuery.getStatistics();
            CqQueryVsdStats cqVsdStats = ((CqQueryImpl) cQuery).getVsdStats();
            if (cqStats == null || cqVsdStats == null) {
                fail("Failed to get CqQuery Stats for CQ : " + cqName);
            }
            getCache().getLogger().info("#### CQ stats for " + cQuery.getName() + ": " + " Events Total: " + cqStats.numEvents() + " Events Created: " + cqStats.numInserts() + " Events Updated: " + cqStats.numUpdates() + " Events Deleted: " + cqStats.numDeletes() + " CQ Listener invocations: " + cqVsdStats.getNumCqListenerInvocations() + " Initial results time (nano sec): " + cqVsdStats.getCqInitialResultsTime());
            // Check for totalEvents count.
            if (totalEvents != CqQueryUsingPoolDUnitTest.noTest) {
                // Result size validation.
                assertEquals("Total Event Count mismatch", totalEvents, cqStats.numEvents());
            }
            // Check for create count.
            if (creates != CqQueryUsingPoolDUnitTest.noTest) {
                assertEquals("Create Event mismatch", creates, cqStats.numInserts());
            }
            // Check for update count.
            if (updates != CqQueryUsingPoolDUnitTest.noTest) {
                assertEquals("Update Event mismatch", updates, cqStats.numUpdates());
            }
            // Check for delete count.
            if (deletes != CqQueryUsingPoolDUnitTest.noTest) {
                assertEquals("Delete Event mismatch", deletes, cqStats.numDeletes());
            }
            // Check for CQ listener invocations.
            if (cqListenerInvocations != CqQueryUsingPoolDUnitTest.noTest) {
                assertEquals("CQ Listener invocations mismatch", cqListenerInvocations, cqVsdStats.getNumCqListenerInvocations());
            }
        //// Check for initial results time.
        // if (initialResultsTime != CqQueryUsingPoolDUnitTest.noTest &&
        //// cqVsdStats.getCqInitialResultsTime() <= 0) {
        // assertIndexDetailsEquals("Initial results time mismatch", initialResultsTime,
        //// cqVsdStats.getCqInitialResultsTime());
        // }
        }
    });
}
Also used : CacheException(org.apache.geode.cache.CacheException) CqException(org.apache.geode.cache.query.CqException) CqService(org.apache.geode.cache.query.internal.cq.CqService) CqException(org.apache.geode.cache.query.CqException) CacheException(org.apache.geode.cache.CacheException) CqStatistics(org.apache.geode.cache.query.CqStatistics) CqQueryVsdStats(org.apache.geode.cache.query.internal.CqQueryVsdStats) CacheSerializableRunnable(org.apache.geode.cache30.CacheSerializableRunnable) DefaultQueryService(org.apache.geode.cache.query.internal.DefaultQueryService) QueryService(org.apache.geode.cache.query.QueryService) Collection(java.util.Collection) InternalCqQuery(org.apache.geode.cache.query.internal.cq.InternalCqQuery) CqQueryImpl(org.apache.geode.cache.query.internal.cq.CqQueryImpl) DefaultQueryService(org.apache.geode.cache.query.internal.DefaultQueryService)

Example 42 with CqException

use of org.apache.geode.cache.query.CqException in project geode by apache.

the class CqServiceImpl method processEntryEvent.

private void processEntryEvent(CacheEvent event, Profile localProfile, Profile[] profiles, FilterRoutingInfo frInfo) throws CqException {
    final boolean isDebugEnabled = logger.isDebugEnabled();
    HashSet<Object> cqUnfilteredEventsSet_newValue = new HashSet<>();
    HashSet<Object> cqUnfilteredEventsSet_oldValue = new HashSet<>();
    boolean b_cqResults_newValue;
    boolean b_cqResults_oldValue;
    boolean queryOldValue;
    EntryEvent entryEvent = (EntryEvent) event;
    Object eventKey = entryEvent.getKey();
    boolean isDupEvent = ((EntryEventImpl) event).isPossibleDuplicate();
    // The CQ query needs to be applied when the op is update, destroy
    // invalidate and in case when op is create and its an duplicate
    // event, the reason for this is when peer sends a duplicate event
    // it marks it as create and sends it, so that the receiving node
    // applies it (see DR.virtualPut()).
    boolean opRequiringQueryOnOldValue = (event.getOperation().isUpdate() || event.getOperation().isDestroy() || event.getOperation().isInvalidate() || (event.getOperation().isCreate() && isDupEvent));
    HashMap<String, Integer> matchedCqs = new HashMap<>();
    long executionStartTime;
    for (int i = -1; i < profiles.length; i++) {
        CacheProfile cf;
        if (i < 0) {
            cf = (CacheProfile) localProfile;
            if (cf == null)
                continue;
        } else {
            cf = (CacheProfile) profiles[i];
        }
        FilterProfile pf = cf.filterProfile;
        if (pf == null || pf.getCqMap().isEmpty()) {
            continue;
        }
        Map cqs = pf.getCqMap();
        if (isDebugEnabled) {
            logger.debug("Profile for {} processing {} CQs", cf.peerMemberId, cqs.size());
        }
        if (cqs.isEmpty()) {
            continue;
        }
        // Get new value. If its not retrieved.
        if (cqUnfilteredEventsSet_newValue.isEmpty() && (event.getOperation().isCreate() || event.getOperation().isUpdate())) {
            Object newValue = entryEvent.getNewValue();
            if (newValue != null) {
                // We have a new value to run the query on
                cqUnfilteredEventsSet_newValue.add(newValue);
            }
        }
        HashMap<Long, Integer> cqInfo = new HashMap<>();
        Iterator cqIter = cqs.entrySet().iterator();
        while (cqIter.hasNext()) {
            Map.Entry cqEntry = (Map.Entry) cqIter.next();
            ServerCQImpl cQuery = (ServerCQImpl) cqEntry.getValue();
            b_cqResults_newValue = false;
            b_cqResults_oldValue = false;
            queryOldValue = false;
            if (cQuery == null) {
                continue;
            }
            String cqName = cQuery.getServerCqName();
            Long filterID = cQuery.getFilterID();
            if (isDebugEnabled) {
                logger.debug("Processing CQ : {} Key: {}", cqName, eventKey);
            }
            Integer cqEvent = null;
            if (matchedCqs.containsKey(cqName)) {
                cqEvent = matchedCqs.get(cqName);
                if (isDebugEnabled) {
                    logger.debug("query {} has already been processed and returned {}", cqName, cqEvent);
                }
                if (cqEvent == null) {
                    continue;
                }
                // Update the Cache Results for this CQ.
                if (cqEvent.intValue() == MessageType.LOCAL_CREATE || cqEvent.intValue() == MessageType.LOCAL_UPDATE) {
                    cQuery.addToCqResultKeys(eventKey);
                } else if (cqEvent.intValue() == MessageType.LOCAL_DESTROY) {
                    cQuery.markAsDestroyedInCqResultKeys(eventKey);
                }
            } else {
                boolean error = false;
                {
                    try {
                        synchronized (cQuery) {
                            // Apply query on new value.
                            if (!cqUnfilteredEventsSet_newValue.isEmpty()) {
                                executionStartTime = this.stats.startCqQueryExecution();
                                b_cqResults_newValue = evaluateQuery(cQuery, new Object[] { cqUnfilteredEventsSet_newValue });
                                this.stats.endCqQueryExecution(executionStartTime);
                            }
                        }
                        // Apply query on oldValue.
                        if (opRequiringQueryOnOldValue) {
                            // with PR region.
                            if (cQuery.cqResultKeysInitialized) {
                                b_cqResults_oldValue = cQuery.isPartOfCqResult(eventKey);
                                // Also apply if the query was not executed during cq execute
                                if ((cQuery.isPR || !CqServiceImpl.EXECUTE_QUERY_DURING_INIT) && b_cqResults_oldValue == false) {
                                    queryOldValue = true;
                                }
                                if (isDebugEnabled && !cQuery.isPR && !b_cqResults_oldValue) {
                                    logger.debug("Event Key not found in the CQ Result Queue. EventKey : {} CQ Name : {}", eventKey, cqName);
                                }
                            } else {
                                queryOldValue = true;
                            }
                            if (queryOldValue) {
                                if (cqUnfilteredEventsSet_oldValue.isEmpty()) {
                                    Object oldValue = entryEvent.getOldValue();
                                    if (oldValue != null) {
                                        cqUnfilteredEventsSet_oldValue.add(oldValue);
                                    }
                                }
                                synchronized (cQuery) {
                                    // Apply query on old value.
                                    if (!cqUnfilteredEventsSet_oldValue.isEmpty()) {
                                        executionStartTime = this.stats.startCqQueryExecution();
                                        b_cqResults_oldValue = evaluateQuery(cQuery, new Object[] { cqUnfilteredEventsSet_oldValue });
                                        this.stats.endCqQueryExecution(executionStartTime);
                                    } else {
                                        if (isDebugEnabled) {
                                            logger.debug("old value for event with key {} is null - query execution not performed", eventKey);
                                        }
                                    }
                                }
                            }
                        // Query oldValue
                        }
                    } catch (Exception ex) {
                        // Any exception in running the query should be caught here and
                        // buried because this code is running in-line with the message
                        // processing code and we don't want to kill that thread
                        error = true;
                        // CHANGE LOG MESSAGE:
                        logger.info(LocalizedMessage.create(LocalizedStrings.CqService_ERROR_WHILE_PROCESSING_CQ_ON_THE_EVENT_KEY_0_CQNAME_1_ERROR_2, new Object[] { ((EntryEvent) event).getKey(), cQuery.getName(), ex.getLocalizedMessage() }));
                    }
                    if (error) {
                        cqEvent = MESSAGE_TYPE_EXCEPTION;
                    } else {
                        if (b_cqResults_newValue) {
                            if (b_cqResults_oldValue) {
                                cqEvent = MESSAGE_TYPE_LOCAL_UPDATE;
                            } else {
                                cqEvent = MESSAGE_TYPE_LOCAL_CREATE;
                            }
                            // If its create and caching is enabled, cache the key
                            // for this CQ.
                            cQuery.addToCqResultKeys(eventKey);
                        } else if (b_cqResults_oldValue) {
                            // Base invalidate operation is treated as destroy.
                            // When the invalidate comes through, the entry will no longer
                            // satisfy the query and will need to be deleted.
                            cqEvent = MESSAGE_TYPE_LOCAL_DESTROY;
                            // If caching is enabled, mark this event's key as removed
                            // from the CQ cache.
                            cQuery.markAsDestroyedInCqResultKeys(eventKey);
                        }
                    }
                }
                // Get the matching CQs if any.
                // synchronized (this.matchingCqMap){
                String query = cQuery.getQueryString();
                Set matchingCqs = (Set) matchingCqMap.get(query);
                if (matchingCqs != null) {
                    Iterator iter = matchingCqs.iterator();
                    while (iter.hasNext()) {
                        String matchingCqName = (String) iter.next();
                        if (!matchingCqName.equals(cqName)) {
                            matchedCqs.put(matchingCqName, cqEvent);
                            if (isDebugEnabled) {
                                logger.debug("Adding CQ into Matching CQ Map: {} Event is: {}", matchingCqName, cqEvent);
                            }
                        }
                    }
                }
            }
            if (cqEvent != null && cQuery.isRunning()) {
                if (isDebugEnabled) {
                    logger.debug("Added event to CQ with client-side name: {} key: {} operation : {}", cQuery.cqName, eventKey, cqEvent);
                }
                cqInfo.put(filterID, cqEvent);
                CqQueryVsdStats stats = cQuery.getVsdStats();
                if (stats != null) {
                    stats.updateStats(cqEvent);
                }
            }
        }
        if (cqInfo.size() > 0) {
            if (pf.isLocalProfile()) {
                if (isDebugEnabled) {
                    logger.debug("Setting local CQ matches to {}", cqInfo);
                }
                frInfo.setLocalCqInfo(cqInfo);
            } else {
                if (isDebugEnabled) {
                    logger.debug("Setting CQ matches for {} to {}", cf.getDistributedMember(), cqInfo);
                }
                frInfo.setCqRoutingInfo(cf.getDistributedMember(), cqInfo);
            }
        }
    }
// iteration over Profiles.
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) EntryEventImpl(org.apache.geode.internal.cache.EntryEventImpl) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) TimeoutException(org.apache.geode.cache.TimeoutException) CqExistsException(org.apache.geode.cache.query.CqExistsException) CqException(org.apache.geode.cache.query.CqException) QueryInvalidException(org.apache.geode.cache.query.QueryInvalidException) InvalidDeltaException(org.apache.geode.InvalidDeltaException) RegionNotFoundException(org.apache.geode.cache.query.RegionNotFoundException) CacheLoaderException(org.apache.geode.cache.CacheLoaderException) CqClosedException(org.apache.geode.cache.query.CqClosedException) QueryException(org.apache.geode.cache.query.QueryException) CqQueryVsdStats(org.apache.geode.cache.query.internal.CqQueryVsdStats) CacheProfile(org.apache.geode.internal.cache.CacheDistributionAdvisor.CacheProfile) FilterProfile(org.apache.geode.internal.cache.FilterProfile) EntryEvent(org.apache.geode.cache.EntryEvent) Iterator(java.util.Iterator) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) HashSet(java.util.HashSet)

Example 43 with CqException

use of org.apache.geode.cache.query.CqException in project geode by apache.

the class ClientCQImpl method close.

@Override
public void close(boolean sendRequestToServer) throws CqClosedException, CqException {
    final boolean isDebugEnabled = logger.isDebugEnabled();
    if (isDebugEnabled) {
        logger.debug("Started closing CQ CqName: {} SendRequestToServer: {}", cqName, sendRequestToServer);
    }
    // Synchronize with stop and execute CQ commands
    synchronized (this.cqState) {
        // Check if the cq is already closed.
        if (this.isClosed()) {
            // throw new CqClosedException("CQ is already closed, CqName : " + this.cqName);
            if (isDebugEnabled) {
                logger.debug("CQ is already closed, CqName: {}", this.cqName);
            }
            return;
        }
        int stateBeforeClosing = this.cqState.getState();
        this.cqState.setState(CqStateImpl.CLOSING);
        boolean isClosed = false;
        // Client Close. Proxy is null in case of server.
        // Check if this has been sent to server, if so send
        // Close request to server.
        Exception exception = null;
        if (this.cqProxy != null && sendRequestToServer) {
            try {
                if (this.proxyCache != null) {
                    if (this.proxyCache.isClosed()) {
                        throw new CacheClosedException("Cache is closed for this user.");
                    }
                    UserAttributes.userAttributes.set(this.proxyCache.getUserAttributes());
                }
                cqProxy.close(this);
                isClosed = true;
            } catch (CancelException e) {
                throw e;
            } catch (Exception ex) {
                if (shutdownInProgress()) {
                    return;
                }
                exception = ex;
            } finally {
                UserAttributes.userAttributes.set(null);
            }
        }
        // Cleanup the resource used by cq.
        this.removeFromCqMap();
        if (cqProxy == null || !sendRequestToServer || isClosed) {
            // Stat update.
            if (stateBeforeClosing == CqStateImpl.RUNNING) {
                cqService.stats().decCqsActive();
            } else if (stateBeforeClosing == CqStateImpl.STOPPED) {
                cqService.stats().decCqsStopped();
            }
            // Set the state to close, and update stats
            this.cqState.setState(CqStateImpl.CLOSED);
            cqService.stats().incCqsClosed();
            cqService.stats().decCqsOnClient();
            if (this.stats != null)
                this.stats.close();
        } else {
            if (shutdownInProgress()) {
                return;
            }
            // Hasn't able to send close request to any server.
            if (exception != null) {
                throw new CqException(LocalizedStrings.CqQueryImpl_FAILED_TO_CLOSE_THE_CQ_CQNAME_0_ERROR_FROM_LAST_ENDPOINT_1.toLocalizedString(this.cqName, exception.getLocalizedMessage()), exception.getCause());
            } else {
                throw new CqException(LocalizedStrings.CqQueryImpl_FAILED_TO_CLOSE_THE_CQ_CQNAME_0_THE_SERVER_ENDPOINTS_ON_WHICH_THIS_CQ_WAS_REGISTERED_WERE_NOT_FOUND.toLocalizedString(this.cqName));
            }
        }
    }
    // Invoke close on Listeners if any.
    if (this.cqAttributes != null) {
        CqListener[] cqListeners = this.getCqAttributes().getCqListeners();
        if (cqListeners != null) {
            if (isDebugEnabled) {
                logger.debug("Invoking CqListeners close() api for the CQ, CqName: {} Number of CqListeners: {}", cqName, cqListeners.length);
            }
            for (int lCnt = 0; lCnt < cqListeners.length; lCnt++) {
                try {
                    cqListeners[lCnt].close();
                // Handle client side exceptions.
                } catch (Exception ex) {
                    logger.warn(LocalizedMessage.create(LocalizedStrings.CqQueryImpl_EXCEPTION_OCCOURED_IN_THE_CQLISTENER_OF_THE_CQ_CQNAME_0_ERROR_1, new Object[] { cqName, ex.getLocalizedMessage() }));
                    if (isDebugEnabled) {
                        logger.debug(ex.getMessage(), ex);
                    }
                } catch (VirtualMachineError err) {
                    SystemFailure.initiateFailure(err);
                    // now, so don't let this thread continue.
                    throw err;
                } catch (Throwable t) {
                    // Whenever you catch Error or Throwable, you must also
                    // catch VirtualMachineError (see above). However, there is
                    // _still_ a possibility that you are dealing with a cascading
                    // error condition, so you also need to check to see if the JVM
                    // is still usable:
                    SystemFailure.checkFailure();
                    logger.warn(LocalizedMessage.create(LocalizedStrings.CqQueryImpl_RUNTIMEEXCEPTION_OCCOURED_IN_THE_CQLISTENER_OF_THE_CQ_CQNAME_0_ERROR_1, new Object[] { cqName, t.getLocalizedMessage() }));
                    if (isDebugEnabled) {
                        logger.debug(t.getMessage(), t);
                    }
                }
            }
        }
    }
    if (isDebugEnabled) {
        logger.debug("Successfully closed the CQ. {}", cqName);
    }
}
Also used : CqException(org.apache.geode.cache.query.CqException) CqListener(org.apache.geode.cache.query.CqListener) CacheClosedException(org.apache.geode.cache.CacheClosedException) CancelException(org.apache.geode.CancelException) RegionNotFoundException(org.apache.geode.cache.query.RegionNotFoundException) CqException(org.apache.geode.cache.query.CqException) CacheClosedException(org.apache.geode.cache.CacheClosedException) CancelException(org.apache.geode.CancelException) GemFireSecurityException(org.apache.geode.security.GemFireSecurityException) CqClosedException(org.apache.geode.cache.query.CqClosedException)

Example 44 with CqException

use of org.apache.geode.cache.query.CqException in project geode by apache.

the class ClientCQImpl method stop.

/**
   * Stop or pause executing the query.
   */
@Override
public void stop() throws CqClosedException, CqException {
    boolean isStopped = false;
    synchronized (this.cqState) {
        if (this.isClosed()) {
            throw new CqClosedException(LocalizedStrings.CqQueryImpl_CQ_IS_CLOSED_CQNAME_0.toLocalizedString(this.cqName));
        }
        if (!(this.isRunning())) {
            throw new IllegalStateException(LocalizedStrings.CqQueryImpl_CQ_IS_NOT_IN_RUNNING_STATE_STOP_CQ_DOES_NOT_APPLY_CQNAME_0.toLocalizedString(this.cqName));
        }
        Exception exception = null;
        try {
            if (this.proxyCache != null) {
                if (this.proxyCache.isClosed()) {
                    throw new CacheClosedException("Cache is closed for this user.");
                }
                UserAttributes.userAttributes.set(this.proxyCache.getUserAttributes());
            }
            cqProxy.stop(this);
            isStopped = true;
        } catch (Exception e) {
            exception = e;
        } finally {
            UserAttributes.userAttributes.set(null);
        }
        if (cqProxy == null || isStopped) {
            // Change state and stats on the client side
            this.cqState.setState(CqStateImpl.STOPPED);
            this.cqService.stats().incCqsStopped();
            this.cqService.stats().decCqsActive();
            if (logger.isDebugEnabled()) {
                logger.debug("Successfully stopped the CQ. {}", cqName);
            }
        } else {
            // Hasn't able to send stop request to any server.
            if (exception != null) {
                throw new CqException(LocalizedStrings.CqQueryImpl_FAILED_TO_STOP_THE_CQ_CQNAME_0_ERROR_FROM_LAST_SERVER_1.toLocalizedString(this.cqName, exception.getLocalizedMessage()), exception.getCause());
            } else {
                throw new CqException(LocalizedStrings.CqQueryImpl_FAILED_TO_STOP_THE_CQ_CQNAME_0_THE_SERVER_ENDPOINTS_ON_WHICH_THIS_CQ_WAS_REGISTERED_WERE_NOT_FOUND.toLocalizedString(this.cqName));
            }
        }
    }
}
Also used : CqException(org.apache.geode.cache.query.CqException) CqClosedException(org.apache.geode.cache.query.CqClosedException) CacheClosedException(org.apache.geode.cache.CacheClosedException) RegionNotFoundException(org.apache.geode.cache.query.RegionNotFoundException) CqException(org.apache.geode.cache.query.CqException) CacheClosedException(org.apache.geode.cache.CacheClosedException) CancelException(org.apache.geode.CancelException) GemFireSecurityException(org.apache.geode.security.GemFireSecurityException) CqClosedException(org.apache.geode.cache.query.CqClosedException)

Example 45 with CqException

use of org.apache.geode.cache.query.CqException in project geode by apache.

the class ClientCQPostAuthorizationDUnitTest method executeCQ.

private void executeCQ(final int num, final boolean[] initialResults, final int expectedResultsSize, final String[] expectedErr, final boolean[] postAuthzAllowed) throws RegionNotFoundException, CqException {
    for (int i = 0; i < num; i++) {
        try {
            if (expectedErr[i] != null) {
                getLogWriter().info("<ExpectedException action=add>" + expectedErr[i] + "</ExpectedException>");
            }
            CqQuery cq1 = null;
            String cqName = "CQ_" + i;
            // String queryStr = cqNameToQueryStrings.get(cqName) +
            // getProxyCaches(i).getRegion(REGION_NAME).getFullPath();
            QueryService cqService = getProxyCaches(i).getQueryService();
            // Get CqQuery object.
            cq1 = cqService.getCq(cqName);
            if (cq1 == null) {
                getLogWriter().info("Failed to get CqQuery object for CQ name: " + cqName);
                fail("Failed to get CQ " + cqName);
            } else {
                getLogWriter().info("Obtained CQ, CQ name: " + cq1.getName());
                assertTrue("newCq() state mismatch", cq1.getState().isStopped());
            }
            if (initialResults[i]) {
                SelectResults cqResults = null;
                try {
                    cqResults = cq1.executeWithInitialResults();
                } catch (CqException ce) {
                    if (ce.getCause() instanceof NotAuthorizedException && !postAuthzAllowed[i]) {
                        getLogWriter().info("Got expected exception for CQ " + cqName);
                    } else {
                        getLogWriter().info("CqService is: " + cqService);
                        throw new AssertionError("Failed to execute CQ " + cqName, ce);
                    }
                }
                getLogWriter().info("initial result size = " + cqResults.size());
                assertTrue("executeWithInitialResults() state mismatch", cq1.getState().isRunning());
                if (expectedResultsSize >= 0) {
                    assertEquals("unexpected results size", expectedResultsSize, cqResults.size());
                }
            } else {
                try {
                    cq1.execute();
                } catch (CqException ce) {
                    if (ce.getCause() instanceof NotAuthorizedException && !postAuthzAllowed[i]) {
                        getLogWriter().info("Got expected exception for CQ " + cqName);
                    } else {
                        throw ce;
                    }
                }
                assertTrue("execute() state mismatch", cq1.getState().isRunning() == postAuthzAllowed[i]);
            }
        } finally {
            if (expectedErr[i] != null) {
                getLogWriter().info("<ExpectedException action=remove>" + expectedErr[i] + "</ExpectedException>");
            }
        }
    }
}
Also used : SelectResults(org.apache.geode.cache.query.SelectResults) QueryService(org.apache.geode.cache.query.QueryService) CqException(org.apache.geode.cache.query.CqException) InternalCqQuery(org.apache.geode.cache.query.internal.cq.InternalCqQuery) CqQuery(org.apache.geode.cache.query.CqQuery)

Aggregations

CqException (org.apache.geode.cache.query.CqException)46 CacheException (org.apache.geode.cache.CacheException)20 RegionNotFoundException (org.apache.geode.cache.query.RegionNotFoundException)20 CacheSerializableRunnable (org.apache.geode.cache30.CacheSerializableRunnable)20 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)16 Test (org.junit.Test)16 CqExistsException (org.apache.geode.cache.query.CqExistsException)15 QueryService (org.apache.geode.cache.query.QueryService)14 CqClosedException (org.apache.geode.cache.query.CqClosedException)12 ClientSubscriptionTest (org.apache.geode.test.junit.categories.ClientSubscriptionTest)9 FlakyTest (org.apache.geode.test.junit.categories.FlakyTest)9 IOException (java.io.IOException)8 List (java.util.List)8 CqQuery (org.apache.geode.cache.query.CqQuery)8 DefaultQueryService (org.apache.geode.cache.query.internal.DefaultQueryService)8 CqService (org.apache.geode.cache.query.internal.cq.CqService)8 Set (java.util.Set)7 CqAttributesFactory (org.apache.geode.cache.query.CqAttributesFactory)7 QueryException (org.apache.geode.cache.query.QueryException)7 InternalCqQuery (org.apache.geode.cache.query.internal.cq.InternalCqQuery)7