Search in sources :

Example 1 with ClientMarkerMessageImpl

use of org.apache.geode.internal.cache.tier.sockets.ClientMarkerMessageImpl in project geode by apache.

the class HARegionQueue method putGIIDataInRegion.

/**
   * Repopulates the HARegion after the GII is over so as to reset the counters and populate the
   * DACE objects for the thread identifiers . This method should be invoked as the last method in
   * the constructor . Thus while creating BlockingQueue this method should be invoked lastly in the
   * derived class constructor , after the HARegionQueue contructor is complete. Otherwise, the
   * ReentrantLock will be null.
   */
void putGIIDataInRegion() throws CacheException, InterruptedException {
    Set entrySet = this.region.entrySet(false);
    // be populated
    if (!entrySet.isEmpty()) {
        this.puttingGIIDataInQueue = true;
        final boolean isDebugEnabled = logger.isDebugEnabled();
        try {
            Region.Entry entry = null;
            Map orderedMap = new TreeMap();
            Iterator iterator = entrySet.iterator();
            Object key = null;
            while (iterator.hasNext()) {
                entry = (Region.Entry) iterator.next();
                key = entry.getKey();
                if (isDebugEnabled) {
                    logger.debug("processing queue key {} and value {}", key, entry.getValue());
                }
                if (key instanceof Long) {
                    if (!(entry.getValue() instanceof ClientMarkerMessageImpl)) {
                        orderedMap.put(key, entry.getValue());
                    }
                }
                this.region.localDestroy(key);
            }
            long max = 0;
            long counterInRegion = 0;
            entrySet = orderedMap.entrySet();
            if (!entrySet.isEmpty()) {
                Map.Entry mapEntry = null;
                iterator = entrySet.iterator();
                while (iterator.hasNext()) {
                    mapEntry = (Map.Entry) iterator.next();
                    Conflatable val = (Conflatable) mapEntry.getValue();
                    if (val != null && val.getEventId() != null) {
                        counterInRegion = ((Long) mapEntry.getKey()).intValue();
                        // TODO: remove this assertion
                        Assert.assertTrue(counterInRegion > max);
                        max = counterInRegion;
                        // putInQueue(val);
                        // logger.info(LocalizedStrings.DEBUG, this + " putting GII entry #" + counterInRegion
                        // + " into queue: " + val);
                        this.put(val);
                    } else if (isDebugEnabled) {
                        logger.debug("bug 44959 encountered: HARegion.putGIIDataInRegion found null eventId in {}", val);
                    }
                }
            }
            this.tailKey.set(max);
        } finally {
            this.puttingGIIDataInQueue = false;
            if (isDebugEnabled) {
                logger.debug("{} done putting GII data into queue", this);
            }
        }
    }
    // TODO:Asif: Avoid invocation of this method
    startHAServices(this.region.getCache());
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) TreeMap(java.util.TreeMap) Iterator(java.util.Iterator) AtomicLong(java.util.concurrent.atomic.AtomicLong) HARegion(org.apache.geode.internal.cache.HARegion) Region(org.apache.geode.cache.Region) ClientMarkerMessageImpl(org.apache.geode.internal.cache.tier.sockets.ClientMarkerMessageImpl) Conflatable(org.apache.geode.internal.cache.Conflatable) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) LinkedHashMap(java.util.LinkedHashMap) TreeMap(java.util.TreeMap)

Aggregations

HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1 LinkedHashMap (java.util.LinkedHashMap)1 LinkedHashSet (java.util.LinkedHashSet)1 Map (java.util.Map)1 Set (java.util.Set)1 TreeMap (java.util.TreeMap)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 Region (org.apache.geode.cache.Region)1 Conflatable (org.apache.geode.internal.cache.Conflatable)1 HARegion (org.apache.geode.internal.cache.HARegion)1 ClientMarkerMessageImpl (org.apache.geode.internal.cache.tier.sockets.ClientMarkerMessageImpl)1