use of org.apache.geode.internal.cache.tier.sockets.CacheClientProxy 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);
}
}
use of org.apache.geode.internal.cache.tier.sockets.CacheClientProxy in project geode by apache.
the class ServerCQImpl method cleanup.
/**
* Clears the resource used by CQ.
*/
@Override
protected void cleanup() throws CqException {
// CqBaseRegion
try {
if (this.cqBaseRegion != null && !this.cqBaseRegion.isDestroyed()) {
this.cqBaseRegion.getFilterProfile().closeCq(this);
CacheClientProxy clientProxy = ccn.getClientProxy(clientProxyId);
clientProxy.decCqCount();
if (clientProxy.hasNoCq()) {
cqService.stats().decClientsWithCqs();
}
}
} catch (Exception ex) {
// May be cache is being shutdown
if (logger.isDebugEnabled()) {
logger.debug("Failed to remove CQ from the base region. CqName :{}", cqName);
}
}
}
use of org.apache.geode.internal.cache.tier.sockets.CacheClientProxy in project geode by apache.
the class Bug51400DUnitTest method verifyQueueSize.
public static void verifyQueueSize(Boolean isPrimary, Integer numOfEvents) throws Exception {
CacheClientProxyStats stats = ((CacheClientProxy) CacheClientNotifier.getInstance().getClientProxies().toArray()[0]).getStatistics();
if (isPrimary) {
// marker
numOfEvents = numOfEvents + 1;
}
long qSize = stats.getMessageQueueSize();
assertEquals("Expected queue size: " + numOfEvents + " but actual size: " + qSize + " at " + (isPrimary ? "primary." : "secondary."), numOfEvents.intValue(), qSize);
}
use of org.apache.geode.internal.cache.tier.sockets.CacheClientProxy in project geode by apache.
the class Simple2CacheServerDUnitTest method checkProxyIsPrimary.
private boolean checkProxyIsPrimary(VM vm) {
SerializableCallable checkProxyIsPrimary = new SerializableCallable() {
@Override
public Object call() throws Exception {
final CacheClientNotifier ccn = CacheClientNotifier.getInstance();
Awaitility.waitAtMost(20, TimeUnit.SECONDS).until(() -> {
return (ccn.getClientProxies().size() == 1);
});
Iterator iter_prox = ccn.getClientProxies().iterator();
CacheClientProxy proxy = (CacheClientProxy) iter_prox.next();
return proxy.isPrimary();
}
};
return (Boolean) vm.invoke(checkProxyIsPrimary);
}
Aggregations