use of org.apache.geode.internal.cache.tier.sockets.ClientUpdateMessageImpl in project geode by apache.
the class CQListGIIDUnitTest method VerifyCUMCQList.
public static void VerifyCUMCQList(Integer numOfKeys, Integer numOfClients) {
try {
Iterator iter = cache.getCacheServers().iterator();
if (iter.hasNext()) {
CacheServerImpl server = (CacheServerImpl) iter.next();
Map haContainer = server.getAcceptor().getCacheClientNotifier().getHaContainer();
Object[] keys = haContainer.keySet().toArray();
logger.fine("### numOfKeys :" + numOfKeys.intValue() + " keys.length : " + keys.length + " haContainer size : " + haContainer.size());
assertEquals(numOfKeys.intValue(), keys.length);
for (int i = 0; i < numOfKeys.intValue(); i++) {
logger.fine("i=: " + i);
ClientUpdateMessageImpl cum = (ClientUpdateMessageImpl) haContainer.get(keys[i]);
assertNotNull(cum);
assertNotNull(cum.getClientCqs());
assertEquals("This test may fail if the image provider gets an ack from client before providing image", numOfClients.intValue(), cum.getClientCqs().size());
}
}
} catch (Exception e) {
Assert.fail("failed in VerifyCUMCQList()" + e, e);
}
}
use of org.apache.geode.internal.cache.tier.sockets.ClientUpdateMessageImpl in project geode by apache.
the class HAContainerRegion method getEntry.
public Object getEntry(Object key) {
Region.Entry entry = ((Region) map).getEntry(key);
if (entry != null) {
ClientUpdateMessageImpl msg = (ClientUpdateMessageImpl) entry.getValue();
msg.setEventIdentifier(((HAEventWrapper) key).getEventId());
if (msg.hasCqs()) {
msg.setClientCqs(((HAEventWrapper) key).getClientCqs());
}
}
return entry;
}
use of org.apache.geode.internal.cache.tier.sockets.ClientUpdateMessageImpl in project geode by apache.
the class HARegionQueue method addClientCQsAndInterestList.
public static void addClientCQsAndInterestList(ClientUpdateMessageImpl msg, HAEventWrapper haEventWrapper, Map haContainer, String regionName) {
ClientProxyMembershipID proxyID = ((HAContainerWrapper) haContainer).getProxyID(regionName);
if (haEventWrapper.getClientCqs() != null) {
CqNameToOp clientCQ = haEventWrapper.getClientCqs().get(proxyID);
if (clientCQ != null) {
msg.addClientCqs(proxyID, clientCQ);
}
}
// if (haEventWrapper.getPutInProgress()) {
// ((HAEventWrapper)entry.getKey()).setPutInProgress(true);
// }
// This is a remote HAEventWrapper.
// Add new Interested client lists.
ClientUpdateMessageImpl clientMsg = (ClientUpdateMessageImpl) haEventWrapper.getClientUpdateMessage();
if (clientMsg.isClientInterestedInUpdates(proxyID)) {
msg.addClientInterestList(proxyID, true);
} else if (clientMsg.isClientInterestedInInvalidates(proxyID)) {
msg.addClientInterestList(proxyID, false);
}
}
use of org.apache.geode.internal.cache.tier.sockets.ClientUpdateMessageImpl in project geode by apache.
the class HARegionQueue method closeClientCq.
public void closeClientCq(ClientProxyMembershipID clientId, InternalCqQuery cqToClose) {
acquireReadLock();
try {
// Get all available Ids for the HA Region Queue
Object[] availableIds = this.availableIDsArray();
int currSize = availableIds.length;
Object event = null;
for (int i = 0; i < currSize; i++) {
Long counter = (Long) availableIds[i];
event = this.region.get(counter);
HAEventWrapper wrapper = null;
if (event instanceof HAEventWrapper) {
wrapper = (HAEventWrapper) event;
event = this.haContainer.get(event);
}
// cannot be null
if (event == null) {
Assert.assertTrue(this.destroyInProgress, "Got event null when queue was not being destroyed");
}
if (event instanceof ClientUpdateMessageImpl) {
ClientUpdateMessageImpl updateEvent = (ClientUpdateMessageImpl) event;
updateEvent.removeClientCq(clientId, cqToClose);
// If no more interest and no more cqs remove from available ids and backing region
if (!updateEvent.hasCqs(clientId) && !updateEvent.isClientInterested(clientId)) {
if (wrapper != null) {
try {
if (this.destroyFromAvailableIDsAndRegion(counter)) {
stats.incEventsRemoved();
}
} catch (InterruptedException ignore) {
Thread.currentThread().interrupt();
}
}
}
}
}
} finally {
releaseReadLock();
}
}
use of org.apache.geode.internal.cache.tier.sockets.ClientUpdateMessageImpl in project geode by apache.
the class HARegionQueue method putEventInHARegion.
/**
* If the event is an instance of HAEventWrapper, put it into the haContainer and then into the ha
* region. Otherwise, simply put it into the ha region.
*
* @since GemFire 5.7
*/
protected void putEventInHARegion(Conflatable event, Long position) {
if (event instanceof HAEventWrapper) {
HAEventWrapper haEventWrapper = (HAEventWrapper) event;
if (this.isQueueInitialized()) {
if (haEventWrapper.getIsRefFromHAContainer()) {
putEntryConditionallyIntoHAContainer(haEventWrapper);
} else {
// This means that the haEvenWrapper reference we have is not
// authentic, i.e. it doesn't refer to the HAEventWrapper instance
// in the haContainer, but to the one outside it.
boolean entryFound;
// synchronized (this.haContainer) {
HAEventWrapper original = null;
do {
ClientUpdateMessageImpl old = (ClientUpdateMessageImpl) ((HAContainerWrapper) this.haContainer).putIfAbsent(haEventWrapper, haEventWrapper.getClientUpdateMessage());
if (old != null) {
original = (HAEventWrapper) ((HAContainerWrapper) this.haContainer).getKey(haEventWrapper);
if (original == null) {
continue;
}
synchronized (original) {
// assert the entry is still present
if (((HAContainerWrapper) this.haContainer).getKey(original) != null) {
original.incAndGetReferenceCount();
addClientCQsAndInterestList(old, haEventWrapper, this.haContainer, this.regionName);
haEventWrapper = original;
} else {
original = null;
}
}
} else {
synchronized (haEventWrapper) {
haEventWrapper.incAndGetReferenceCount();
haEventWrapper.setHAContainer(this.haContainer);
if (!haEventWrapper.getPutInProgress()) {
// This means that this is a GII'ed event. Hence we must
// explicitly set 'clientUpdateMessage' to null.
haEventWrapper.setClientUpdateMessage(null);
}
haEventWrapper.setIsRefFromHAContainer(true);
}
break;
}
} while (original == null);
/*
* entry = (Map.Entry)((HAContainerWrapper)this.haContainer) .getEntry(haEventWrapper); if
* (entry == null) { entryFound = false;
* putEntryConditionallyIntoHAContainer(haEventWrapper); } else { entryFound = true; // Do
* not assign entry.getKey() to haEventWrapper right now.
* ((HAEventWrapper)entry.getKey()).incAndGetReferenceCount(); } }//haContainer
* synchronized ends if (entryFound) { addClientCQsAndInterestList(entry, haEventWrapper,
* haContainer, regionName); haEventWrapper = (HAEventWrapper)entry.getKey(); } else { //
* entry not found if (!haEventWrapper.getPutInProgress()) { // This means that this is a
* GII'ed event. Hence we must // explicitly set 'clientUpdateMessage' to null.
* haEventWrapper.setClientUpdateMessage(null); }
* haEventWrapper.setIsRefFromHAContainer(true); }
*/
}
}
// This has now been taken care of in AbstractRegionMap.initialImagePut()
// else{
// if(!haEventWrapper.getIsRefFromHAContainer()){
// haEventWrapper =(HAEventWrapper)((HAContainerWrapper)haContainer).getKey(haEventWrapper);
// }
// }
// Put the reference to the HAEventWrapper instance into the
// HA queue.
this.region.put(position, haEventWrapper);
// logger.info(LocalizedStrings.DEBUG, "added message at position " + position);
} else {
// (event instanceof ClientMarkerMessageImpl OR ConflatableObject OR
// ClientInstantiatorMessage)
this.region.put(position, event);
// logger.info(LocalizedStrings.DEBUG, "added non-msg at position " + position);
}
}
Aggregations