@Override public int calculateRegionEntryValueSize(RegionEntry re) { return calcMemSize(re._getValue()); // OFFHEAP _getValue ok }
/** * Create one of these in the local case so that we have a snapshot of the state * and can allow the bucket to move out from under us. */ public NonLocalRegionEntry(RegionEntry re, LocalRegion br, boolean allowTombstones) { this.key = re.getKey(); if (allowTombstones && re.isTombstone()) { // client get() operations need to see tombstone values this.value = Token.TOMBSTONE; } else { this.value = re.getValue(br); // OFFHEAP: copy into heap cd } Assert.assertTrue(this.value != Token.NOT_AVAILABLE, "getEntry did not fault value in from disk"); this.lastModified = re.getLastModified(); this.isRemoved = re.isRemoved(); VersionStamp stamp = re.getVersionStamp(); if (stamp != null) { this.versionTag = stamp.asVersionTag(); } }
public void run() { assertTrue(Token.TOMBSTONE == CCRegion.getRegionEntry(loadKey).getValueInVM(CCRegion)); } });
@Override public boolean isUpdateInProgress() { return updateInProgress || regionEntry.isUpdateInProgress() // The index update could have started just before the iterator was created. The entry still // needs to be re-evaluated in this case. || IndexManager.needsRecalculation(iteratorStartTime, regionEntry.getLastModified()); } }
/** * Returns the entry's RegionEntry if it "checks" out. The check is to * see if the region entry still exists. * @throws EntryNotFoundException if the RegionEntry has been removed. */ private RegionEntry getCheckedRegionEntry() throws EntryNotFoundException { RegionEntry result = this.re; if (re.isDestroyedOrRemoved()) { throw new EntryNotFoundException("Entry for key " + re.getKey() + " no longer exists"); } return result; }
public final Object readEntry(final ExclusiveSharedLockObject lockObj, final Object context, int iContext, boolean allowTombstones) { final RegionEntry re = (RegionEntry)lockObj; if ((re.isTombstone() && allowTombstones) || !re.isDestroyedOrRemoved()) { return new EntrySnapshot(re, (LocalRegion)context, partitionedRegion, allowTombstones); } return null; } };
/** * Create one of these in the local case so that we have a snapshot of the * state and can allow the bucket to move out from under us. */ protected NonLocalRegionEntry(RegionEntry re, LocalRegion br, boolean allowTombstones) { this.key = re.getKeyCopy(); // client get() operations need to see tombstone values if (allowTombstones && re.isTombstone()) { this.value = Token.TOMBSTONE; } else { this.value = re.getValue(br); // OFFHEAP: copy into heap cd } Assert.assertTrue(this.value != Token.NOT_AVAILABLE, "getEntry did not fault value in from disk"); this.lastModified = re.getLastModified(); this.isRemoved = re.isRemoved(); VersionStamp<?> stamp = re.getVersionStamp(); if (stamp != null) { this.versionTag = stamp.asVersionTag(); } }
@Override public void run2() throws CacheException { Cache cache = getCache(); Region region = cache.getRegion("prRegion"); Region.Entry entry = ((PartitionedRegion)region).getEntry("testKey", null, true /*Entry is destroyed*/); RegionEntry re = ((EntrySnapshot)entry).getRegionEntry(); getLogWriter().fine("RegionEntry for testKey: " + re.getKey() + " " + re.getValueInVM((LocalRegion) region)); assertTrue(re.getValueInVM((LocalRegion) region) instanceof Tombstone); VersionTag tag = re.getVersionStamp().asVersionTag(); assertEquals(3 /*Two puts and a Destroy*/, tag.getEntryVersion()); } });
protected void copyRecoveredEntry(RegionEntry oldRe, RegionEntry newRe, LocalRegion owner, long dummyVersionTs) { long lastModifiedTime = oldRe.getLastModified(); if (lastModifiedTime != 0) { newRe.setLastModified(lastModifiedTime); } if (newRe.getVersionStamp() != null) { // [sjigyasu] Fixes #50794. // If the recovered entry does not have a version stamp and the newRe is // versioned, create a dummy version stamp. if (oldRe.getVersionStamp() == null) { VersionTag vt = createDummyTag(dummyVersionTs); newRe.getVersionStamp().setVersions(vt); } else { newRe.getVersionStamp().setVersions( oldRe.getVersionStamp().asVersionTag()); } } if (newRe instanceof AbstractOplogDiskRegionEntry) { AbstractOplogDiskRegionEntry newDe = (AbstractOplogDiskRegionEntry)newRe; newDe.setDiskIdForRegion(owner, oldRe); _getOwner().getDiskRegion().replaceIncompatibleEntry((DiskEntry) oldRe, newDe); } _getMap().put(newRe.getKey(), newRe); }
@Override public Object getKey() { if (this.regionEntry != null) { return this.regionEntry.getKey(); } assert this.rowLocation != null; return this.rowLocation.getKey(); }
@Override public Object getTargetObjectInVM(RegionEntry entry) { if (indexOnValues) { Object o = entry.getValueInVM((LocalRegion) region); if (o instanceof CachedDeserializable) { return ((CachedDeserializable) o).getDeserializedValue( region, entry); } return o; } else if (indexOnRegionKeys) { return entry.getKey(); } return ((LocalRegion) region).new NonTXEntry(entry); }
@Override public boolean isUpdateInProgress() { return regionEntry.isUpdateInProgress(); } }
@Override public Object getTargetObject(RegionEntry entry) { if (indexOnValues) { Object o = entry.getValue((LocalRegion) region); if (o instanceof CachedDeserializable) { return ((CachedDeserializable) o).getDeserializedValue( region, entry); } return o; } else if (indexOnRegionKeys) { return entry.getKey(); } return ((LocalRegion) region).new NonTXEntry(entry); }
private boolean reHasDelta(LocalRegion owner, RegionEntry re) { @Retained @Released Object oVal = re.getValueOffHeapOrDiskWithoutFaultIn(owner); try { if (oVal != null && oVal instanceof ListOfDeltas) { return true; } return false; } finally { OffHeapHelper.release(oVal); } }
public final void removeEntry(Object key, RegionEntry re, boolean updateStat) { if (re.isTombstone() && _getMap().get(key) == re && !re.isMarkedForEviction()){ logger.fatal(LocalizedMessage.create(LocalizedStrings.AbstractRegionMap_ATTEMPT_TO_REMOVE_TOMBSTONE), new Exception("stack trace")); return; // can't remove tombstones except from the tombstone sweeper } if (_getMap().remove(key, re)) { re.removePhase2(); if (updateStat) { incEntryCount(-1); } } }
/** * If the value in the VM is still REMOVED_PHASE1 Token, then the operation * was not completed (due to cacheWriter exception, concurrentMap operation) etc. */ private boolean isOpComplete(RegionEntry re, EntryEventImpl event) { if (re.getValueAsToken() == Token.REMOVED_PHASE1) { return false; } return true; }
public final Object readEntry(final ExclusiveSharedLockObject lockObj, Object context, int iContext, boolean allowTombstones) { return ((RegionEntry)lockObj).getValue((LocalRegion)context); } };
protected HashMap<String, VersionTag> saveVersionTags(LocalRegion region) { HashMap<String, VersionTag> tagmap = new HashMap<String, VersionTag>(); Iterator entryItr = region.entrySet().iterator(); while (entryItr.hasNext()) { RegionEntry entry = ((NonTXEntry)entryItr.next()).getRegionEntry(); String key = (String)entry.getKey(); VersionTag tag = entry.getVersionStamp().asVersionTag(); tagmap.put(key, tag); } return tagmap; }
@Override public boolean doEvict(EntryEvent<Object, Object> event) { final EntryEventImpl ev = (EntryEventImpl)event; final RegionEntry re = ev.getRegionEntry(); LocalRegion region = ev.getRegion(); if (region.getLogWriterI18n().fineEnabled()) { region.getLogWriterI18n().fine( " The entry is " + re + " and the event is " + event + " re marked for eviction " + re.isMarkedForEviction()); } if (re != null) { if (re.hasAnyLock()) { return false; } if (re.isMarkedForEviction()) { return true; } } return false; }
@Override public boolean isDestroyed() { if (this.re.isDestroyedOrRemoved()) return true; return false; }