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;
}
}
Aggregations