Repository: ignite Updated Branches: refs/heads/ignite-971 276aa57ac -> 07b476aaa
ignite-971 Fix offheap to swap eviction. Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/07b476aa Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/07b476aa Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/07b476aa Branch: refs/heads/ignite-971 Commit: 07b476aaa9bf0aaca0c51cb09ac15914261f2f5b Parents: 276aa57 Author: sboikov <[email protected]> Authored: Fri Sep 11 11:22:07 2015 +0300 Committer: sboikov <[email protected]> Committed: Fri Sep 11 11:25:41 2015 +0300 ---------------------------------------------------------------------- .../processors/cache/GridCacheMapEntry.java | 6 ++---- .../processors/cache/GridCacheSwapManager.java | 20 ++++++++++++++++++-- .../query/h2/opt/GridH2AbstractKeyValueRow.java | 18 ++++++++++-------- 3 files changed, 30 insertions(+), 14 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/07b476aa/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java index 8305b66..5a7cc42 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java @@ -433,7 +433,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme } /** {@inheritDoc} */ - @Override public boolean offheapSwapEvict(byte[] vb, GridCacheVersion evictVer, GridCacheVersion obsoleteVer) + @Override public boolean offheapSwapEvict(byte[] entry, GridCacheVersion evictVer, GridCacheVersion obsoleteVer) throws IgniteCheckedException, GridCacheEntryRemovedException { assert cctx.swap().swapEnabled() && cctx.swap().offHeapEnabled() : this; @@ -450,14 +450,12 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme if (mvcc != null && !mvcc.isEmpty(obsoleteVer)) return false; - if (cctx.swap().removeOffheap(key, partition(), evictVer)) { + if (cctx.swap().offheapSwapEvict(key, entry, partition(), evictVer)) { assert !hasValueUnlocked() : this; obsolete = markObsolete0(obsoleteVer, false); assert obsolete : this; - - cctx.swap().writeToSwap(partition(), key, vb); } else obsolete = false; http://git-wip-us.apache.org/repos/asf/ignite/blob/07b476aa/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java index c4a14f1..92fb065 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java @@ -1048,18 +1048,19 @@ public class GridCacheSwapManager extends GridCacheManagerAdapter { /** * @param key Key to remove. + * @param entry Serialized swap entry. * @param part Partition. * @param ver Expected version. * @return {@code True} if removed. * @throws IgniteCheckedException If failed. */ - boolean removeOffheap(final KeyCacheObject key, int part, final GridCacheVersion ver) + boolean offheapSwapEvict(final KeyCacheObject key, byte[] entry, int part, final GridCacheVersion ver) throws IgniteCheckedException { assert offheapEnabled; checkIteratorQueue(); - return offheap.removex(spaceName, part, key, key.valueBytes(cctx.cacheObjectContext()), + boolean rmv = offheap.removex(spaceName, part, key, key.valueBytes(cctx.cacheObjectContext()), new IgniteBiPredicate<Long, Integer>() { @Override public boolean apply(Long ptr, Integer len) { GridCacheVersion ver0 = GridCacheOffheapSwapEntry.version(ptr); @@ -1068,6 +1069,21 @@ public class GridCacheSwapManager extends GridCacheManagerAdapter { } } ); + + if (rmv) { + Collection<GridCacheSwapListener> lsnrs = offheapLsnrs.get(part); + + if (lsnrs != null) { + GridCacheSwapEntry e = swapEntry(GridCacheSwapEntryImpl.unmarshal(entry)); + + for (GridCacheSwapListener lsnr : lsnrs) + lsnr.onEntryUnswapped(part, key, e); + } + + cctx.swap().writeToSwap(part, key, entry); + } + + return rmv; } /** http://git-wip-us.apache.org/repos/asf/ignite/blob/07b476aa/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2AbstractKeyValueRow.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2AbstractKeyValueRow.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2AbstractKeyValueRow.java index 5704626..07c49a5 100644 --- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2AbstractKeyValueRow.java +++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2AbstractKeyValueRow.java @@ -207,16 +207,18 @@ public abstract class GridH2AbstractKeyValueRow extends GridH2Row { try { Object valObj = desc.readFromSwap(k); - // Even if we've found valObj in swap, it is may be some new value, - // while the needed value was already unswapped, so we have to recheck it. - if (valObj != null && (v = syncValue(0)) == null && (v = getOffheapValue(VAL_COL)) == null) { - Value upd = desc.wrap(valObj, desc.valueType()); + if (valObj != null) { + // Even if we've found valObj in swap, it is may be some new value, + // while the needed value was already unswapped, so we have to recheck it. + if ((v = WeakValue.unwrap(syncValue(0))) == null && (v = getOffheapValue(VAL_COL)) == null) { + Value upd = desc.wrap(valObj, desc.valueType()); - v = updateWeakValue(upd); + v = updateWeakValue(upd); - return v == null ? upd : v; + return v == null ? upd : v; + } } - else if (v != null) { + else { // If nothing found in swap then we should be already unswapped. v = syncValue(attempt); } @@ -242,7 +244,7 @@ public abstract class GridH2AbstractKeyValueRow extends GridH2Row { if (v == null) { v = getOffheapValue(KEY_COL); - assert v != null : v; + assert v != null; setValue(KEY_COL, v);
