use of org.apache.geode.i18n.StringId in project geode by apache.
the class LocalizedMessageJUnitTest method testEmptyParams.
@Test
public void testEmptyParams() {
final StringId stringId = new StringId(100, "This is a message for testEmptyParams");
final LocalizedMessage message = LocalizedMessage.create(stringId, new Object[] {});
final Object[] object = message.getParameters();
assertNotNull(object);
assertEquals(0, object.length);
}
use of org.apache.geode.i18n.StringId 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;
}
}
use of org.apache.geode.i18n.StringId in project geode by apache.
the class CqServiceImpl method closeCq.
@Override
public void closeCq(String cqName, ClientProxyMembershipID clientProxyId) throws CqException {
String serverCqName = cqName;
if (clientProxyId != null) {
serverCqName = this.constructServerCqName(cqName, clientProxyId);
removeFromCacheForServerToConstructedCQName(cqName, clientProxyId);
}
ServerCQImpl cQuery = null;
StringId errMsg = null;
Exception ex = null;
try {
HashMap<String, CqQueryImpl> cqMap = cqQueryMap;
if (!cqMap.containsKey(serverCqName)) {
/*
* gregp 052808: We should silently fail here instead of throwing error. This is to deal
* with races in recovery
*/
return;
}
cQuery = (ServerCQImpl) cqMap.get(serverCqName);
} catch (CacheLoaderException e1) {
errMsg = LocalizedStrings.CqService_CQ_NOT_FOUND_IN_THE_CQ_META_REGION_CQNAME_0;
ex = e1;
} catch (TimeoutException e2) {
errMsg = LocalizedStrings.CqService_TIMEOUT_WHILE_TRYING_TO_GET_CQ_FROM_META_REGION_CQNAME_0;
ex = e2;
} finally {
if (ex != null) {
String s = errMsg.toLocalizedString(cqName);
if (logger.isDebugEnabled()) {
logger.debug(s);
}
throw new CqException(s, ex);
}
}
try {
cQuery.close(false);
// CqBaseRegion
try {
LocalRegion baseRegion = cQuery.getCqBaseRegion();
if (baseRegion != null && !baseRegion.isDestroyed()) {
// Server specific clean up.
if (isServer()) {
FilterProfile fp = baseRegion.getFilterProfile();
if (fp != null) {
fp.closeCq(cQuery);
}
CacheClientProxy clientProxy = cQuery.getCacheClientNotifier().getClientProxy(clientProxyId);
clientProxy.decCqCount();
if (clientProxy.hasNoCq()) {
this.stats.decClientsWithCqs();
}
}
}
} catch (Exception e) {
// May be cache is being shutdown
if (logger.isDebugEnabled()) {
logger.debug("Failed to remove CQ from the base region. CqName : {}", cqName);
}
}
if (isServer()) {
removeFromBaseRegionToCqNameMap(cQuery.getRegionName(), serverCqName);
}
LocalRegion baseRegion = cQuery.getCqBaseRegion();
if (baseRegion.getFilterProfile().getCqCount() <= 0) {
if (logger.isDebugEnabled()) {
logger.debug("Should update the profile for this partitioned region {} for not requiring old value", baseRegion);
}
}
} catch (CqClosedException cce) {
throw new CqException(cce.getMessage());
} finally {
this.removeFromMatchingCqMap(cQuery);
}
}
Aggregations