use of org.apache.geode.internal.util.concurrent.CustomEntryConcurrentHashMap in project geode by apache.
the class AbstractRegionMap method copyRecoveredEntries.
public void copyRecoveredEntries(RegionMap rm) {
// We need to sort the tombstones before scheduling them,
// so that they will be in the correct order.
OrderedTombstoneMap<RegionEntry> tombstones = new OrderedTombstoneMap<RegionEntry>();
if (rm != null) {
CustomEntryConcurrentHashMap<Object, Object> other = ((AbstractRegionMap) rm)._getMap();
Iterator<Map.Entry<Object, Object>> it = other.entrySetWithReusableEntries().iterator();
while (it.hasNext()) {
Map.Entry<Object, Object> me = it.next();
// This removes the RegionEntry from "rm" but it does not decrement its
it.remove();
// refcount to an offheap value.
RegionEntry oldRe = (RegionEntry) me.getValue();
Object key = me.getKey();
@Retained @Released Object value = oldRe._getValueRetain((RegionEntryContext) ((AbstractRegionMap) rm)._getOwnerObject(), true);
try {
if (value == Token.NOT_AVAILABLE) {
// fix for bug 43993
value = null;
}
if (value == Token.TOMBSTONE && !_getOwner().getConcurrencyChecksEnabled()) {
continue;
}
RegionEntry newRe = getEntryFactory().createEntry((RegionEntryContext) _getOwnerObject(), key, value);
// TODO: passing value to createEntry causes a problem with the disk stats.
// The disk stats have already been set to track oldRe.
// So when we call createEntry we probably want to give it REMOVED_PHASE1
// and then set the value in copyRecoveredEntry it a way that does not
// change the disk stats. This also depends on DiskEntry.Helper.initialize not changing
// the stats for REMOVED_PHASE1
copyRecoveredEntry(oldRe, newRe);
// newRe is now in this._getMap().
if (newRe.isTombstone()) {
VersionTag tag = newRe.getVersionStamp().asVersionTag();
tombstones.put(tag, newRe);
} else {
_getOwner().updateSizeOnCreate(key, _getOwner().calculateRegionEntryValueSize(newRe));
}
incEntryCount(1);
lruEntryUpdate(newRe);
} finally {
OffHeapHelper.release(value);
if (oldRe instanceof OffHeapRegionEntry) {
((OffHeapRegionEntry) oldRe).release();
}
}
lruUpdateCallback();
}
} else {
for (Iterator<RegionEntry> iter = regionEntries().iterator(); iter.hasNext(); ) {
RegionEntry re = iter.next();
if (re.isTombstone()) {
if (re.getVersionStamp() == null) {
// bug #50992 - recovery from versioned to
// non-versioned
iter.remove();
continue;
} else {
tombstones.put(re.getVersionStamp().asVersionTag(), re);
}
} else {
_getOwner().updateSizeOnCreate(re.getKey(), _getOwner().calculateRegionEntryValueSize(re));
}
}
incEntryCount(size());
// Since lru was not being done during recovery call it now.
lruUpdateCallback();
}
// Schedule all of the tombstones, now that we have sorted them
Map.Entry<VersionTag, RegionEntry> entry;
while ((entry = tombstones.take()) != null) {
// refresh the tombstone so it doesn't time out too soon
_getOwner().scheduleTombstone(entry.getValue(), entry.getKey());
}
}
use of org.apache.geode.internal.util.concurrent.CustomEntryConcurrentHashMap in project geode by apache.
the class ConcurrentHashMapJUnitTest method testPutIfAbsent2_NullPointerException.
/**
* putIfAbsent(x, null) throws NPE
*/
@Test
public void testPutIfAbsent2_NullPointerException() {
try {
CustomEntryConcurrentHashMap c = new CustomEntryConcurrentHashMap(5);
c.putIfAbsent("whatever", null);
shouldThrow();
} catch (NullPointerException e) {
}
}
use of org.apache.geode.internal.util.concurrent.CustomEntryConcurrentHashMap in project geode by apache.
the class ConcurrentHashMapJUnitTest method testValues.
/**
* values collection contains all values
*/
@Test
public void testValues() {
CustomEntryConcurrentHashMap map = map5();
Collection s = map.values();
assertEquals(5, s.size());
assertTrue(s.contains("A"));
assertTrue(s.contains("B"));
assertTrue(s.contains("C"));
assertTrue(s.contains("D"));
assertTrue(s.contains("E"));
}
use of org.apache.geode.internal.util.concurrent.CustomEntryConcurrentHashMap in project geode by apache.
the class ConcurrentHashMapJUnitTest method testRemove1_NullPointerException.
/**
* remove(null) throws NPE
*/
@Test
public void testRemove1_NullPointerException() {
try {
CustomEntryConcurrentHashMap c = new CustomEntryConcurrentHashMap(5);
c.put("sadsdf", "asdads");
c.remove(null);
shouldThrow();
} catch (NullPointerException e) {
}
}
use of org.apache.geode.internal.util.concurrent.CustomEntryConcurrentHashMap in project geode by apache.
the class ConcurrentHashMapJUnitTest method testReplace_NullPointerException.
/**
* replace(null, x) throws NPE
*/
@Test
public void testReplace_NullPointerException() {
try {
CustomEntryConcurrentHashMap c = new CustomEntryConcurrentHashMap(5);
c.replace(null, "whatever");
shouldThrow();
} catch (NullPointerException e) {
}
}
Aggregations