use of org.apache.geode.internal.cache.versions.RegionVersionVector in project geode by apache.
the class DiskStoreImpl method writeRVV.
public void writeRVV(DiskRegion dr, LocalRegion region, Boolean isRVVTrusted) {
acquireReadLock(dr);
try {
if (dr.isRegionClosed()) {
dr.getCancelCriterion().checkCancelInProgress(null);
throw new RegionDestroyedException(LocalizedStrings.DiskRegion_THE_DISKREGION_HAS_BEEN_CLOSED_OR_DESTROYED.toLocalizedString(), dr.getName());
}
RegionVersionVector inMemoryRVV = (region == null) ? null : region.getVersionVector();
// persist the new GC RVV information for this region to the CRF
PersistentOplogSet oplogSet = getPersistentOplogSet(dr);
// use current dr.rvvTrust
oplogSet.getChild().writeRVV(dr, inMemoryRVV, isRVVTrusted);
} finally {
releaseReadLock(dr);
}
}
use of org.apache.geode.internal.cache.versions.RegionVersionVector in project geode by apache.
the class DiskStoreImpl method writeRVVGC.
public void writeRVVGC(DiskRegion dr, LocalRegion region) {
acquireReadLock(dr);
try {
if (dr.isRegionClosed()) {
region.getCancelCriterion().checkCancelInProgress(null);
throw new RegionDestroyedException(LocalizedStrings.DiskRegion_THE_DISKREGION_HAS_BEEN_CLOSED_OR_DESTROYED.toLocalizedString(), dr.getName());
}
// Update on the on disk region version vector.
// TODO - RVV - For async regions, it's possible that
// the on disk RVV is actually less than the GC RVV we're trying record
// it might make sense to push the RVV through the async queue?
// What we're doing here is only recording the GC RVV if it is dominated
// by the RVV of what we have persisted.
RegionVersionVector inMemoryRVV = region.getVersionVector();
RegionVersionVector diskRVV = dr.getRegionVersionVector();
// Update the GC version for each member in our on disk version map
updateDiskGCRVV(diskRVV, inMemoryRVV, diskRVV.getOwnerId());
for (VersionSource member : (Collection<VersionSource>) inMemoryRVV.getMemberToGCVersion().keySet()) {
updateDiskGCRVV(diskRVV, inMemoryRVV, member);
}
// Remove any exceptions from the disk RVV that are are dominated
// by the GC RVV.
diskRVV.pruneOldExceptions();
PersistentOplogSet oplogSet = getPersistentOplogSet(dr);
// persist the new GC RVV information for this region to the DRF
oplogSet.getChild().writeGCRVV(dr);
} finally {
releaseReadLock(dr);
}
}
use of org.apache.geode.internal.cache.versions.RegionVersionVector in project geode by apache.
the class LocalRegion method cmnClearRegion.
// TODO: what does cmn refer to?
void cmnClearRegion(RegionEventImpl regionEvent, boolean cacheWrite, boolean useRVV) {
RegionVersionVector rvv = null;
if (useRVV && this.dataPolicy.withReplication() && this.concurrencyChecksEnabled) {
rvv = this.versionVector.getCloneForTransmission();
}
clearRegionLocally(regionEvent, cacheWrite, rvv);
}
use of org.apache.geode.internal.cache.versions.RegionVersionVector in project geode by apache.
the class Oplog method serializeRVVs.
private byte[] serializeRVVs(Map<Long, AbstractDiskRegion> drMap, boolean gcRVV) throws IOException {
HeapDataOutputStream out = new HeapDataOutputStream(Version.CURRENT);
// Filter out any regions that do not have versioning enabled
drMap = new HashMap<Long, AbstractDiskRegion>(drMap);
for (Iterator<Map.Entry<Long, AbstractDiskRegion>> itr = drMap.entrySet().iterator(); itr.hasNext(); ) {
Map.Entry<Long, AbstractDiskRegion> regionEntry = itr.next();
AbstractDiskRegion dr = regionEntry.getValue();
if (!dr.getFlags().contains(DiskRegionFlag.IS_WITH_VERSIONING)) {
itr.remove();
}
}
// Write the size first
InternalDataSerializer.writeUnsignedVL(drMap.size(), out);
// Now write regions RVV.
for (Map.Entry<Long, AbstractDiskRegion> regionEntry : drMap.entrySet()) {
// For each region, write the RVV for the region.
Long diskRegionID = regionEntry.getKey();
AbstractDiskRegion dr = regionEntry.getValue();
RegionVersionVector rvv = dr.getRegionVersionVector();
if (logger.isTraceEnabled(LogMarker.PERSIST_WRITES)) {
logger.trace(LogMarker.PERSIST_WRITES, "serializeRVVs: isGCRVV={} drId={} rvv={} oplog#{}", gcRVV, diskRegionID, rvv.fullToString(), getOplogId());
}
// Write the disk region id
InternalDataSerializer.writeUnsignedVL(diskRegionID, out);
if (gcRVV) {
// For the GC RVV, we will just write the GC versions
Map<VersionSource, Long> memberToVersion = rvv.getMemberToGCVersion();
InternalDataSerializer.writeUnsignedVL(memberToVersion.size(), out);
for (Entry<VersionSource, Long> memberEntry : memberToVersion.entrySet()) {
// For each member, write the canonicalized member id,
// and the version number for that member
VersionSource member = memberEntry.getKey();
Long gcVersion = memberEntry.getValue();
int id = getParent().getDiskInitFile().getOrCreateCanonicalId(member);
InternalDataSerializer.writeUnsignedVL(id, out);
InternalDataSerializer.writeUnsignedVL(gcVersion, out);
}
} else {
DataSerializer.writeBoolean(dr.getRVVTrusted(), out);
// Otherwise, we will write the version and exception list for each
// member
Map<VersionSource, RegionVersionHolder> memberToVersion = rvv.getMemberToVersion();
InternalDataSerializer.writeUnsignedVL(memberToVersion.size(), out);
for (Map.Entry<VersionSource, RegionVersionHolder> memberEntry : memberToVersion.entrySet()) {
// For each member, right the canonicalized member id,
// and the version number with exceptions for that member
VersionSource member = memberEntry.getKey();
RegionVersionHolder versionHolder = memberEntry.getValue();
int id = getParent().getDiskInitFile().getOrCreateCanonicalId(member);
InternalDataSerializer.writeUnsignedVL(id, out);
synchronized (versionHolder) {
InternalDataSerializer.invokeToData(versionHolder, out);
}
}
}
}
return out.toByteArray();
}
use of org.apache.geode.internal.cache.versions.RegionVersionVector in project geode by apache.
the class LocalRegion method repairRVV.
/**
* Fix up our RVV by iterating over the entries in the region and making sure they are applied to
* the RVV.
*
* If we failed to do a GII, we may have applied the RVV from a remote member. That RVV may not
* have seen some of the events in our local RVV. Those entries were supposed to be replaced with
* the results of the GII. However, if we failed the GII, those entries may still be in the cache,
* but are no longer reflected in the local RVV. This method iterates over those keys and makes
* sure their versions are applied to the local RVV.
*
* TODO - this method should probably rebuild the RVV from scratch, instead of starting with the
* existing RVV. By starting with the existing RVV, we may claim to have entries that we actually
* don't have. Unfortunately, we can't really rebuild the RVV from scratch because we will end up
* with huge exception lists.
*
* However, if we are in the state of recovering from disk with an untrusted RVV, we must be newer
* than any other surviving members. So they shouldn't have any entries in their cache that match
* entries that we failed to receive through the GII but are reflected in our current RVV. So it
* should be safe to start with the current RVV.
*
*/
void repairRVV() {
RegionVersionVector rvv = this.getVersionVector();
if (rvv == null) {
// No need to do anything.
return;
}
Iterator<RegionEntry> it = getBestIterator(false);
VersionSource<?> myId = getVersionMember();
// Iterate over the all of the entries
while (it.hasNext()) {
RegionEntry mapEntry = it.next();
VersionStamp<?> stamp = mapEntry.getVersionStamp();
VersionSource<?> id = stamp.getMemberID();
if (id == null) {
id = myId;
}
// Make sure the version is applied to the regions RVV
rvv.recordVersion(id, stamp.getRegionVersion());
}
}
Aggregations