Search in sources :

Example 11 with CqExistsException

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

the class CqServiceImpl method addToCqMap.

/**
   * Adds the given CQ and cqQuery object into the CQ map.
   */
void addToCqMap(CqQueryImpl cq) throws CqExistsException, CqException {
    // On server side cqName will be server side cqName.
    String sCqName = cq.getServerCqName();
    if (logger.isDebugEnabled()) {
        logger.debug("Adding to CQ Repository. CqName : {} ServerCqName : {}", cq.getName(), sCqName);
    }
    HashMap<String, CqQueryImpl> cqMap = cqQueryMap;
    if (cqMap.containsKey(sCqName)) {
        throw new CqExistsException(LocalizedStrings.CqService_A_CQ_WITH_THE_GIVEN_NAME_0_ALREADY_EXISTS.toLocalizedString(sCqName));
    }
    synchronized (cqQueryMapLock) {
        HashMap<String, CqQueryImpl> tmpCqQueryMap = new HashMap<>(cqQueryMap);
        try {
            tmpCqQueryMap.put(sCqName, cq);
        } catch (Exception ex) {
            StringId errMsg = LocalizedStrings.CqQueryImpl_FAILED_TO_STORE_CONTINUOUS_QUERY_IN_THE_REPOSITORY_CQNAME_0_1;
            Object[] errMsgArgs = new Object[] { sCqName, ex.getLocalizedMessage() };
            String s = errMsg.toLocalizedString(errMsgArgs);
            logger.error(s);
            throw new CqException(s, ex);
        }
        UserAttributes attributes = UserAttributes.userAttributes.get();
        if (attributes != null) {
            this.cqNameToUserAttributesMap.put(cq.getName(), attributes);
        }
        cqQueryMap = tmpCqQueryMap;
    }
}
Also used : StringId(org.apache.geode.i18n.StringId) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) CqException(org.apache.geode.cache.query.CqException) CqExistsException(org.apache.geode.cache.query.CqExistsException) 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) UserAttributes(org.apache.geode.cache.client.internal.UserAttributes)

Aggregations

CqExistsException (org.apache.geode.cache.query.CqExistsException)11 RegionNotFoundException (org.apache.geode.cache.query.RegionNotFoundException)8 CqException (org.apache.geode.cache.query.CqException)7 QueryService (org.apache.geode.cache.query.QueryService)7 CacheException (org.apache.geode.cache.CacheException)6 CacheSerializableRunnable (org.apache.geode.cache30.CacheSerializableRunnable)6 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)6 Test (org.junit.Test)6 CqAttributes (org.apache.geode.cache.query.CqAttributes)5 CqAttributesFactory (org.apache.geode.cache.query.CqAttributesFactory)5 Host (org.apache.geode.test.dunit.Host)5 VM (org.apache.geode.test.dunit.VM)5 CqClosedException (org.apache.geode.cache.query.CqClosedException)4 IOException (java.io.IOException)3 List (java.util.List)3 CqQuery (org.apache.geode.cache.query.CqQuery)3 HashMap (java.util.HashMap)2 Region (org.apache.geode.cache.Region)2 QueryException (org.apache.geode.cache.query.QueryException)2 QueryInvalidException (org.apache.geode.cache.query.QueryInvalidException)2