Search in sources :

Example 1 with ClientUpdateMessageImpl

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);
    }
}
Also used : ClientUpdateMessageImpl(org.apache.geode.internal.cache.tier.sockets.ClientUpdateMessageImpl) Iterator(java.util.Iterator) CacheServerImpl(org.apache.geode.internal.cache.CacheServerImpl) Map(java.util.Map) HashMap(java.util.HashMap) IOException(java.io.IOException) CacheException(org.apache.geode.cache.CacheException)

Example 2 with ClientUpdateMessageImpl

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;
}
Also used : ClientUpdateMessageImpl(org.apache.geode.internal.cache.tier.sockets.ClientUpdateMessageImpl) Region(org.apache.geode.cache.Region)

Example 3 with ClientUpdateMessageImpl

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);
    }
}
Also used : ClientProxyMembershipID(org.apache.geode.internal.cache.tier.sockets.ClientProxyMembershipID) ClientUpdateMessageImpl(org.apache.geode.internal.cache.tier.sockets.ClientUpdateMessageImpl) CqNameToOp(org.apache.geode.internal.cache.tier.sockets.ClientUpdateMessageImpl.CqNameToOp)

Example 4 with ClientUpdateMessageImpl

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();
    }
}
Also used : ClientUpdateMessageImpl(org.apache.geode.internal.cache.tier.sockets.ClientUpdateMessageImpl) AtomicLong(java.util.concurrent.atomic.AtomicLong) HAEventWrapper(org.apache.geode.internal.cache.tier.sockets.HAEventWrapper)

Example 5 with ClientUpdateMessageImpl

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);
    }
}
Also used : ClientUpdateMessageImpl(org.apache.geode.internal.cache.tier.sockets.ClientUpdateMessageImpl) HAEventWrapper(org.apache.geode.internal.cache.tier.sockets.HAEventWrapper)

Aggregations

ClientUpdateMessageImpl (org.apache.geode.internal.cache.tier.sockets.ClientUpdateMessageImpl)9 HAEventWrapper (org.apache.geode.internal.cache.tier.sockets.HAEventWrapper)4 Region (org.apache.geode.cache.Region)3 IOException (java.io.IOException)2 Iterator (java.util.Iterator)2 CacheException (org.apache.geode.cache.CacheException)2 CacheServerImpl (org.apache.geode.internal.cache.CacheServerImpl)2 EventID (org.apache.geode.internal.cache.EventID)2 HAContainerWrapper (org.apache.geode.internal.cache.ha.HAContainerWrapper)2 ClientProxyMembershipID (org.apache.geode.internal.cache.tier.sockets.ClientProxyMembershipID)2 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Set (java.util.Set)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 AttributesFactory (org.apache.geode.cache.AttributesFactory)1 PartitionAttributesFactory (org.apache.geode.cache.PartitionAttributesFactory)1 QueryException (org.apache.geode.cache.query.QueryException)1 BucketRegion (org.apache.geode.internal.cache.BucketRegion)1