Search in sources :

Example 16 with DiskRegionView

use of org.apache.geode.internal.cache.persistence.DiskRegionView in project geode by apache.

the class DiskInitFile method cmnOnlineMemberId.

public void cmnOnlineMemberId(long drId, PersistentMemberID pmid) {
    DiskRegionView dr = getDiskRegionById(drId);
    if (dr != null) {
        dr.addOnlineMember(pmid);
        if (dr.rmOfflineMember(pmid) || dr.rmEqualMember(pmid)) {
            this.ifLiveRecordCount--;
        }
        this.ifLiveRecordCount++;
        this.ifTotalRecordCount++;
    } else {
        if (logger.isTraceEnabled(LogMarker.PERSIST_RECOVERY)) {
            logger.trace(LogMarker.PERSIST_RECOVERY, "bad disk region id!");
        } else {
            throw new IllegalStateException("bad disk region id");
        }
    }
}
Also used : DiskRegionView(org.apache.geode.internal.cache.persistence.DiskRegionView)

Example 17 with DiskRegionView

use of org.apache.geode.internal.cache.persistence.DiskRegionView in project geode by apache.

the class DiskInitFile method getRegionsToDump.

/**
   * Returns a map of region_name->(pr_buckets|replicated_region)
   * 
   * @param regName
   */
private Map<String, List<PlaceHolderDiskRegion>> getRegionsToDump(String regName) {
    if (regName == null) {
        Map<String, List<PlaceHolderDiskRegion>> regions = new HashMap<String, List<PlaceHolderDiskRegion>>();
        for (DiskRegionView drv : this.drMap.values()) {
            if (drv instanceof PlaceHolderDiskRegion) {
                PlaceHolderDiskRegion dr = (PlaceHolderDiskRegion) drv;
                if (dr.isBucket()) {
                    List<PlaceHolderDiskRegion> buckets = regions.get(dr.getPrName());
                    if (buckets == null) {
                        buckets = new ArrayList<PlaceHolderDiskRegion>();
                        regions.put(dr.getPrName(), buckets);
                    }
                    buckets.add(dr);
                } else {
                    regions.put(drv.getName(), Collections.singletonList(dr));
                }
            }
        }
        return regions;
    } else {
        DiskRegionView drv = getDiskRegionByName(regName);
        if (drv == null) {
            List<PlaceHolderDiskRegion> buckets = new ArrayList<PlaceHolderDiskRegion>();
            for (PlaceHolderDiskRegion dr : this.drMapByName.values()) {
                if (dr.isBucket()) {
                    if (dr.getName().equals(dr.getPrName())) {
                        buckets.add(dr);
                    }
                }
            }
            if (buckets.isEmpty()) {
                throw new IllegalArgumentException("The disk store does not contain a region named " + regName);
            } else {
                return Collections.singletonMap(regName, buckets);
            }
        } else if (drv instanceof PlaceHolderDiskRegion) {
            return Collections.singletonMap(regName, Collections.singletonList((PlaceHolderDiskRegion) drv));
        } else {
            return Collections.emptyMap();
        }
    }
}
Also used : Int2ObjectOpenHashMap(it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) DiskRegionView(org.apache.geode.internal.cache.persistence.DiskRegionView)

Example 18 with DiskRegionView

use of org.apache.geode.internal.cache.persistence.DiskRegionView in project geode by apache.

the class DiskInitFile method close.

void close() {
    lock.lock();
    try {
        if (this.closed)
            return;
        this.closed = true;
        stopListeningForDataSerializerChanges();
        try {
            this.ifRAF.close();
        } catch (IOException ignore) {
        }
        for (DiskRegionView k : this.getKnown()) {
            k.close();
        }
        if (this.liveRegions == 0 && !parent.isValidating()) {
            basicDestroy();
        }
    } finally {
        lock.unlock();
    }
}
Also used : IOException(java.io.IOException) DiskRegionView(org.apache.geode.internal.cache.persistence.DiskRegionView)

Example 19 with DiskRegionView

use of org.apache.geode.internal.cache.persistence.DiskRegionView in project geode by apache.

the class DiskInitFile method cmnOfflineMemberId.

public void cmnOfflineMemberId(long drId, PersistentMemberID pmid) {
    DiskRegionView dr = getDiskRegionById(drId);
    if (dr != null) {
        dr.addOfflineMember(pmid);
        if (dr.rmOnlineMember(pmid) || dr.rmEqualMember(pmid)) {
            this.ifLiveRecordCount--;
        }
        this.ifLiveRecordCount++;
        this.ifTotalRecordCount++;
    } else {
        if (logger.isTraceEnabled(LogMarker.PERSIST_RECOVERY)) {
            logger.trace(LogMarker.PERSIST_RECOVERY, "bad disk region id!");
        } else {
            throw new IllegalStateException("bad disk region id");
        }
    }
}
Also used : DiskRegionView(org.apache.geode.internal.cache.persistence.DiskRegionView)

Example 20 with DiskRegionView

use of org.apache.geode.internal.cache.persistence.DiskRegionView in project geode by apache.

the class DiskInitFile method cmnClearRegion.

public void cmnClearRegion(long drId, long clearOplogEntryId) {
    DiskRegionView drv = getDiskRegionById(drId);
    if (drv.getClearOplogEntryId() == DiskStoreImpl.INVALID_ID) {
        this.ifLiveRecordCount++;
    }
    // otherwise previous clear is cancelled so don't change liveRecordCount
    this.ifTotalRecordCount++;
    drv.setClearOplogEntryId(clearOplogEntryId);
    if (clearOplogEntryId > clearOplogEntryIdHWM) {
        clearOplogEntryIdHWM = clearOplogEntryId;
    }
}
Also used : DiskRegionView(org.apache.geode.internal.cache.persistence.DiskRegionView)

Aggregations

DiskRegionView (org.apache.geode.internal.cache.persistence.DiskRegionView)27 ArrayList (java.util.ArrayList)5 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)4 File (java.io.File)3 HashMap (java.util.HashMap)3 StatisticsFactory (org.apache.geode.StatisticsFactory)3 DiskRecoveryStore (org.apache.geode.internal.cache.persistence.DiskRecoveryStore)3 PdxType (org.apache.geode.pdx.internal.PdxType)3 Int2ObjectOpenHashMap (it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap)2 VersionTag (org.apache.geode.internal.cache.versions.VersionTag)2 StoredObject (org.apache.geode.internal.offheap.StoredObject)2 EnumInfo (org.apache.geode.pdx.internal.EnumInfo)2 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)2 Expectations (org.jmock.Expectations)2 Test (org.junit.Test)2 IntOpenHashSet (it.unimi.dsi.fastutil.ints.IntOpenHashSet)1 Long2ObjectOpenHashMap (it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap)1 LongOpenHashSet (it.unimi.dsi.fastutil.longs.LongOpenHashSet)1 IOException (java.io.IOException)1 HashSet (java.util.HashSet)1