Search in sources :

Example 71 with DiskRecoveryStore

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

the class Oplog method recoverValuesIfNeeded.

/**
   * This method is called by the async value recovery task to recover the values from the crf if
   * the keys were recovered from the krf.
   */
public void recoverValuesIfNeeded(Map<Long, DiskRecoveryStore> diskRecoveryStores) {
    // Early out if we start closing the parent.
    if (getParent().isClosing()) {
        return;
    }
    List<KRFEntry> sortedLiveEntries;
    HashMap<Long, DiskRegionInfo> targetRegions = new HashMap<Long, DiskRegionInfo>(this.regionMap);
    synchronized (diskRecoveryStores) {
        Iterator<DiskRecoveryStore> itr = diskRecoveryStores.values().iterator();
        while (itr.hasNext()) {
            DiskRecoveryStore store = itr.next();
            if (isLruValueRecoveryDisabled(store) || store.lruLimitExceeded()) {
                itr.remove();
            }
        }
        // Get the a sorted list of live entries from the target regions
        targetRegions.keySet().retainAll(diskRecoveryStores.keySet());
    }
    sortedLiveEntries = getSortedLiveEntries(targetRegions.values());
    if (sortedLiveEntries == null) {
        // There are no live entries in this oplog to recover.
        return;
    }
    final ByteArrayDataInput in = new ByteArrayDataInput();
    for (KRFEntry entry : sortedLiveEntries) {
        // Early out if we start closing the parent.
        if (getParent().isClosing()) {
            return;
        }
        DiskEntry diskEntry = entry.getDiskEntry();
        DiskRegionView diskRegionView = entry.getDiskRegionView();
        long diskRegionId = diskRegionView.getId();
        synchronized (diskRecoveryStores) {
            DiskRecoveryStore diskRecoveryStore = diskRecoveryStores.get(diskRegionId);
            if (diskRecoveryStore == null) {
                continue;
            }
            // Reset the disk region view because it may have changed
            // due to the region being created.
            diskRegionView = diskRecoveryStore.getDiskRegionView();
            if (diskRegionView == null) {
                continue;
            }
            if (diskRecoveryStore.lruLimitExceeded()) {
                diskRecoveryStores.remove(diskRegionId);
                continue;
            }
            if (diskRegionView.isEntriesMapIncompatible()) {
                // Refetch the disk entry because it may have changed due to copying
                // an incompatible region map
                diskEntry = (DiskEntry) diskRecoveryStore.getRegionMap().getEntryInVM(diskEntry.getKey());
                if (diskEntry == null) {
                    continue;
                }
            }
            synchronized (diskEntry) {
                // Make sure the entry hasn't been modified
                if (diskEntry.getDiskId() != null && diskEntry.getDiskId().getOplogId() == oplogId) {
                    try {
                        DiskEntry.Helper.recoverValue(diskEntry, getOplogId(), diskRecoveryStore, in);
                    } catch (RegionDestroyedException ignore) {
                        // This region has been destroyed, stop recovering from it.
                        diskRecoveryStores.remove(diskRegionId);
                    }
                }
            }
        }
    }
}
Also used : Long2ObjectOpenHashMap(it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap) Int2ObjectOpenHashMap(it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) RegionDestroyedException(org.apache.geode.cache.RegionDestroyedException) ByteArrayDataInput(org.apache.geode.internal.ByteArrayDataInput) DiskRegionView(org.apache.geode.internal.cache.persistence.DiskRegionView) DiskRecoveryStore(org.apache.geode.internal.cache.persistence.DiskRecoveryStore) AtomicLong(java.util.concurrent.atomic.AtomicLong)

Example 72 with DiskRecoveryStore

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

the class VersionedThinDiskLRURegionEntryOffHeapLongKey method diskInitialize.

// DO NOT modify this class. It was generated from LeafRegionEntry.cpp
private void diskInitialize(RegionEntryContext context, Object value) {
    DiskRecoveryStore drs = (DiskRecoveryStore) context;
    DiskStoreImpl ds = drs.getDiskStore();
    long maxOplogSize = ds.getMaxOplogSize();
    // get appropriate instance of DiskId implementation based on maxOplogSize
    this.id = DiskId.createDiskId(maxOplogSize, true, /* is persistence */
    ds.needsLinkedList());
    Helper.initialize(this, drs, value);
}
Also used : DiskRecoveryStore(org.apache.geode.internal.cache.persistence.DiskRecoveryStore)

Example 73 with DiskRecoveryStore

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

the class VersionedThinDiskLRURegionEntryOffHeapObjectKey method diskInitialize.

// DO NOT modify this class. It was generated from LeafRegionEntry.cpp
private void diskInitialize(RegionEntryContext context, Object value) {
    DiskRecoveryStore drs = (DiskRecoveryStore) context;
    DiskStoreImpl ds = drs.getDiskStore();
    long maxOplogSize = ds.getMaxOplogSize();
    // get appropriate instance of DiskId implementation based on maxOplogSize
    this.id = DiskId.createDiskId(maxOplogSize, true, /* is persistence */
    ds.needsLinkedList());
    Helper.initialize(this, drs, value);
}
Also used : DiskRecoveryStore(org.apache.geode.internal.cache.persistence.DiskRecoveryStore)

Example 74 with DiskRecoveryStore

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

the class VersionedThinDiskLRURegionEntryOffHeapStringKey1 method diskInitialize.

// DO NOT modify this class. It was generated from LeafRegionEntry.cpp
private void diskInitialize(RegionEntryContext context, Object value) {
    DiskRecoveryStore drs = (DiskRecoveryStore) context;
    DiskStoreImpl ds = drs.getDiskStore();
    long maxOplogSize = ds.getMaxOplogSize();
    // get appropriate instance of DiskId implementation based on maxOplogSize
    this.id = DiskId.createDiskId(maxOplogSize, true, /* is persistence */
    ds.needsLinkedList());
    Helper.initialize(this, drs, value);
}
Also used : DiskRecoveryStore(org.apache.geode.internal.cache.persistence.DiskRecoveryStore)

Example 75 with DiskRecoveryStore

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

the class VersionedThinDiskLRURegionEntryHeapIntKey method diskInitialize.

// DO NOT modify this class. It was generated from LeafRegionEntry.cpp
private void diskInitialize(RegionEntryContext context, Object value) {
    DiskRecoveryStore drs = (DiskRecoveryStore) context;
    DiskStoreImpl ds = drs.getDiskStore();
    long maxOplogSize = ds.getMaxOplogSize();
    // get appropriate instance of DiskId implementation based on maxOplogSize
    this.id = DiskId.createDiskId(maxOplogSize, true, /* is persistence */
    ds.needsLinkedList());
    Helper.initialize(this, drs, value);
}
Also used : DiskRecoveryStore(org.apache.geode.internal.cache.persistence.DiskRecoveryStore)

Aggregations

DiskRecoveryStore (org.apache.geode.internal.cache.persistence.DiskRecoveryStore)106 VersionTag (org.apache.geode.internal.cache.versions.VersionTag)5 StoredObject (org.apache.geode.internal.offheap.StoredObject)5 HashMap (java.util.HashMap)3 DiskRegionView (org.apache.geode.internal.cache.persistence.DiskRegionView)3 File (java.io.File)2 ByteArrayDataInput (org.apache.geode.internal.ByteArrayDataInput)2 OplogEntryIdSet (org.apache.geode.internal.cache.DiskStoreImpl.OplogEntryIdSet)2 Int2ObjectOpenHashMap (it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap)1 Long2ObjectOpenHashMap (it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap)1 LongOpenHashSet (it.unimi.dsi.fastutil.longs.LongOpenHashSet)1 BufferedInputStream (java.io.BufferedInputStream)1 DataInputStream (java.io.DataInputStream)1 FileInputStream (java.io.FileInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 InterruptedIOException (java.io.InterruptedIOException)1 HashSet (java.util.HashSet)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1