You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2016/04/21 15:53:02 UTC
[3/3] ignite git commit: ignite-db-x-10884
ignite-db-x-10884
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/49543e16
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/49543e16
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/49543e16
Branch: refs/heads/ignite-db-x-10884
Commit: 49543e1675129408c845746c4e68c2c0c5447335
Parents: f0757ac
Author: sboikov <sb...@gridgain.com>
Authored: Thu Apr 21 11:48:26 2016 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Thu Apr 21 16:52:46 2016 +0300
----------------------------------------------------------------------
.../ignite/internal/GridKernalContext.java | 8 -
.../ignite/internal/GridKernalContextImpl.java | 12 -
.../apache/ignite/internal/IgniteKernal.java | 4 -
.../cache/CacheEntryPredicateAdapter.java | 7 +-
.../cache/CacheEvictableEntryImpl.java | 10 +-
.../processors/cache/CacheMetricsImpl.java | 18 +-
.../processors/cache/GridCacheAdapter.java | 174 ++----
.../cache/GridCacheClearAllRunnable.java | 2 +-
.../processors/cache/GridCacheContext.java | 69 +--
.../processors/cache/GridCacheEntryEx.java | 32 +-
.../cache/GridCacheEvictionManager.java | 3 +-
.../processors/cache/GridCacheMapEntry.java | 542 +++++--------------
.../processors/cache/GridCacheProcessor.java | 5 +-
.../processors/cache/GridCacheProxyImpl.java | 36 --
.../processors/cache/GridCacheSwapManager.java | 2 -
.../cache/IgniteCacheOffheapManager.java | 132 +++--
.../processors/cache/IgniteCacheProxy.java | 17 +-
.../processors/cache/IgniteInternalCache.java | 27 -
.../binary/CacheObjectBinaryProcessorImpl.java | 14 -
.../GridDistributedCacheAdapter.java | 3 +-
.../distributed/dht/GridDhtCacheAdapter.java | 30 +-
.../distributed/dht/GridDhtCacheEntry.java | 11 +-
.../dht/GridDhtOffHeapCacheEntry.java | 63 ---
.../dht/GridDhtTransactionalCacheAdapter.java | 4 -
.../distributed/dht/GridDhtTxLocalAdapter.java | 26 +-
.../distributed/dht/GridDhtTxPrepareFuture.java | 4 -
.../distributed/dht/GridNoStorageCacheMap.java | 4 +-
.../dht/GridPartitionedGetFuture.java | 8 +-
.../dht/GridPartitionedSingleGetFuture.java | 6 -
.../dht/atomic/GridDhtAtomicCache.java | 25 +-
.../atomic/GridDhtAtomicOffHeapCacheEntry.java | 63 ---
.../dht/colocated/GridDhtColocatedCache.java | 11 +-
.../GridDhtColocatedOffHeapCacheEntry.java | 63 ---
.../colocated/GridDhtDetachedCacheEntry.java | 11 +-
.../dht/preloader/GridDhtPartitionSupplier.java | 2 -
.../distributed/near/GridNearCacheAdapter.java | 29 -
.../distributed/near/GridNearCacheEntry.java | 7 +-
.../distributed/near/GridNearGetFuture.java | 12 -
.../near/GridNearOffHeapCacheEntry.java | 60 --
.../distributed/near/GridNearTxRemote.java | 4 +-
.../cache/local/GridLocalCacheEntry.java | 18 -
.../local/atomic/GridLocalAtomicCache.java | 26 +-
.../cache/query/GridCacheQueryManager.java | 129 +----
.../cache/transactions/IgniteTxAdapter.java | 4 -
.../transactions/IgniteTxLocalAdapter.java | 40 +-
.../cacheobject/IgniteCacheObjectProcessor.java | 9 -
.../IgniteCacheObjectProcessorImpl.java | 26 -
.../processors/query/GridQueryIndexing.java | 11 +-
.../processors/query/GridQueryProcessor.java | 14 +-
.../ignite/internal/visor/cache/VisorCache.java | 9 -
.../ignite/startup/BasicWarmupClosure.java | 3 +-
.../cache/CacheNearReaderUpdateTest.java | 1 -
.../cache/CacheOffheapMapEntrySelfTest.java | 19 -
.../CacheSerializableTransactionsTest.java | 1 -
.../processors/cache/GridCacheTestEntryEx.java | 13 +-
.../IgniteTxStoreExceptionAbstractSelfTest.java | 4 +-
.../dht/GridCacheDhtEntrySelfTest.java | 4 +-
.../dht/GridCacheTxNodeFailureSelfTest.java | 2 +-
...eAtomicInvalidPartitionHandlingSelfTest.java | 4 +-
.../near/GridCacheNearMultiNodeSelfTest.java | 2 +-
.../near/GridCacheNearOneNodeSelfTest.java | 2 +-
.../DataStreamProcessorSelfTest.java | 2 +-
.../processors/query/h2/IgniteH2Indexing.java | 12 +-
63 files changed, 370 insertions(+), 1545 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/49543e16/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContext.java b/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContext.java
index c0b50a2..2ed3345 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContext.java
@@ -48,7 +48,6 @@ import org.apache.ignite.internal.processors.igfs.IgfsHelper;
import org.apache.ignite.internal.processors.igfs.IgfsProcessorAdapter;
import org.apache.ignite.internal.processors.job.GridJobProcessor;
import org.apache.ignite.internal.processors.jobmetrics.GridJobMetricsProcessor;
-import org.apache.ignite.internal.processors.offheap.GridOffHeapProcessor;
import org.apache.ignite.internal.processors.platform.PlatformProcessor;
import org.apache.ignite.internal.processors.plugin.IgnitePluginProcessor;
import org.apache.ignite.internal.processors.port.GridPortProcessor;
@@ -157,13 +156,6 @@ public interface GridKernalContext extends Iterable<GridComponent> {
public GridJobProcessor job();
/**
- * Gets offheap processor.
- *
- * @return Off-heap processor.
- */
- public GridOffHeapProcessor offheap();
-
- /**
* Gets timeout processor.
*
* @return Timeout processor.
http://git-wip-us.apache.org/repos/asf/ignite/blob/49543e16/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java
index 22fd96c..0987e5d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java
@@ -65,7 +65,6 @@ import org.apache.ignite.internal.processors.igfs.IgfsProcessorAdapter;
import org.apache.ignite.internal.processors.job.GridJobProcessor;
import org.apache.ignite.internal.processors.jobmetrics.GridJobMetricsProcessor;
import org.apache.ignite.internal.processors.nodevalidation.DiscoveryNodeValidationProcessor;
-import org.apache.ignite.internal.processors.offheap.GridOffHeapProcessor;
import org.apache.ignite.internal.processors.platform.PlatformProcessor;
import org.apache.ignite.internal.processors.plugin.IgnitePluginProcessor;
import org.apache.ignite.internal.processors.port.GridPortProcessor;
@@ -208,10 +207,6 @@ public class GridKernalContextImpl implements GridKernalContext, Externalizable
/** */
@GridToStringInclude
- private GridOffHeapProcessor offheapProc;
-
- /** */
- @GridToStringInclude
private IgniteScheduleProcessorAdapter scheduleProc;
/** */
@@ -494,8 +489,6 @@ public class GridKernalContextImpl implements GridKernalContext, Externalizable
dataLdrProc = (DataStreamProcessor)comp;
else if (comp instanceof IgfsProcessorAdapter)
igfsProc = (IgfsProcessorAdapter)comp;
- else if (comp instanceof GridOffHeapProcessor)
- offheapProc = (GridOffHeapProcessor)comp;
else if (comp instanceof GridContinuousProcessor)
contProc = (GridContinuousProcessor)comp;
else if (comp instanceof HadoopProcessorAdapter)
@@ -623,11 +616,6 @@ public class GridKernalContextImpl implements GridKernalContext, Externalizable
}
/** {@inheritDoc} */
- @Override public GridOffHeapProcessor offheap() {
- return offheapProc;
- }
-
- /** {@inheritDoc} */
@Override public IgniteScheduleProcessorAdapter schedule() {
return scheduleProc;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/49543e16/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
index 4056b89..2c2f30e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
@@ -117,7 +117,6 @@ import org.apache.ignite.internal.processors.job.GridJobProcessor;
import org.apache.ignite.internal.processors.jobmetrics.GridJobMetricsProcessor;
import org.apache.ignite.internal.processors.nodevalidation.DiscoveryNodeValidationProcessor;
import org.apache.ignite.internal.processors.nodevalidation.OsDiscoveryNodeValidationProcessor;
-import org.apache.ignite.internal.processors.offheap.GridOffHeapProcessor;
import org.apache.ignite.internal.processors.platform.PlatformNoopProcessor;
import org.apache.ignite.internal.processors.platform.PlatformProcessor;
import org.apache.ignite.internal.processors.plugin.IgnitePluginProcessor;
@@ -801,9 +800,6 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
startProcessor(new IgnitePluginProcessor(ctx, cfg, plugins));
- // Off-heap processor has no dependencies.
- startProcessor(new GridOffHeapProcessor(ctx));
-
// Closure processor should be started before all others
// (except for resource processor), as many components can depend on it.
startProcessor(new GridClosureProcessor(ctx));
http://git-wip-us.apache.org/repos/asf/ignite/blob/49543e16/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicateAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicateAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicateAdapter.java
index 10e4787..2768813 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicateAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryPredicateAdapter.java
@@ -87,11 +87,6 @@ public abstract class CacheEntryPredicateAdapter implements CacheEntryPredicate
* @return Value.
*/
@Nullable protected CacheObject peekVisibleValue(GridCacheEntryEx entry) {
- try {
- return locked ? entry.rawGetOrUnmarshal(true) : entry.peekVisibleValue();
- }
- catch (IgniteCheckedException e) {
- throw new IgniteException(e);
- }
+ return locked ? entry.rawGet() : entry.peekVisibleValue();
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/49543e16/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEvictableEntryImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEvictableEntryImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEvictableEntryImpl.java
index 7cea4f6..8857732 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEvictableEntryImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEvictableEntryImpl.java
@@ -103,14 +103,10 @@ public class CacheEvictableEntryImpl<K, V> implements EvictableEntry<K, V> {
byte[] valBytes = null;
- if (cctx.useOffheapEntry())
- valBytes = cctx.offheap().get(cctx.swap().spaceName(), cached.partition(), key, keyBytes);
- else {
- CacheObject cacheObj = cached.valueBytes();
+ CacheObject cacheObj = cached.valueBytes();
- if (cacheObj != null)
- valBytes = cacheObj.valueBytes(cctx.cacheObjectContext());
- }
+ if (cacheObj != null)
+ valBytes = cacheObj.valueBytes(cctx.cacheObjectContext());
return valBytes == null ? keyBytes.length : keyBytes.length + valBytes.length;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/49543e16/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsImpl.java
index fd30ea3..8dd11d6 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsImpl.java
@@ -215,7 +215,7 @@ public class CacheMetricsImpl implements CacheMetrics {
/** {@inheritDoc} */
@Override public long getOffHeapPrimaryEntriesCount() {
try {
- return cctx.swap().offheapEntriesCount(true, false, cctx.affinity().affinityTopologyVersion());
+ return cctx.offheap().entriesCount(true, false, cctx.affinity().affinityTopologyVersion());
}
catch (IgniteCheckedException e) {
return 0;
@@ -225,7 +225,7 @@ public class CacheMetricsImpl implements CacheMetrics {
/** {@inheritDoc} */
@Override public long getOffHeapBackupEntriesCount() {
try {
- return cctx.swap().offheapEntriesCount(false, true, cctx.affinity().affinityTopologyVersion());
+ return cctx.offheap().entriesCount(false, true, cctx.affinity().affinityTopologyVersion());
}
catch (IgniteCheckedException e) {
return 0;
@@ -271,22 +271,12 @@ public class CacheMetricsImpl implements CacheMetrics {
/** {@inheritDoc} */
@Override public long getSwapEntriesCount() {
- try {
- return cctx.cache().swapKeys();
- }
- catch (IgniteCheckedException e) {
- return 0;
- }
+ return 0;
}
/** {@inheritDoc} */
@Override public long getSwapSize() {
- try {
- return cctx.cache().swapSize();
- }
- catch (IgniteCheckedException e) {
- return 0;
- }
+ return 0;
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/49543e16/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
index bbbb096..4eb1f9b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
@@ -81,6 +81,7 @@ import org.apache.ignite.internal.cluster.ClusterTopologyServerNotFoundException
import org.apache.ignite.internal.cluster.IgniteClusterEx;
import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
import org.apache.ignite.internal.processors.cache.affinity.GridCacheAffinityImpl;
+import org.apache.ignite.internal.processors.cache.database.CacheDataRow;
import org.apache.ignite.internal.processors.cache.distributed.IgniteExternalizableExpiryPolicy;
import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheAdapter;
import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtInvalidPartitionException;
@@ -106,6 +107,7 @@ import org.apache.ignite.internal.util.future.GridCompoundFuture;
import org.apache.ignite.internal.util.future.GridEmbeddedFuture;
import org.apache.ignite.internal.util.future.GridFinishedFuture;
import org.apache.ignite.internal.util.future.GridFutureAdapter;
+import org.apache.ignite.internal.util.lang.GridCloseableIterator;
import org.apache.ignite.internal.util.lang.GridClosureException;
import org.apache.ignite.internal.util.lang.GridTriple;
import org.apache.ignite.internal.util.tostring.GridToStringExclude;
@@ -692,13 +694,10 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
if (modes.primary || modes.backup) {
AffinityTopologyVersion topVer = ctx.affinity().affinityTopologyVersion();
- GridCacheSwapManager swapMgr = ctx.isNear() ? ctx.near().dht().context().swap() : ctx.swap();
-
- if (modes.swap)
- its.add(swapMgr.<K, V>swapIterator(modes.primary, modes.backup, topVer));
+ IgniteCacheOffheapManager offheapMgr = ctx.isNear() ? ctx.near().dht().context().offheap() : ctx.offheap();
if (modes.offheap)
- its.add(swapMgr.<K, V>offheapIterator(modes.primary, modes.backup, topVer));
+ its.add(offheapMgr.<K, V>entriesIterator(modes.primary, modes.backup, topVer));
}
final Iterator<Cache.Entry<K, V>> it = F.flatIterators(its);
@@ -797,9 +796,9 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
}
if (modes.offheap || modes.swap) {
- GridCacheSwapManager swapMgr = ctx.isNear() ? ctx.near().dht().context().swap() : ctx.swap();
+ IgniteCacheOffheapManager offheapMgr = ctx.isNear() ? ctx.near().dht().context().offheap() : ctx.offheap();
- cacheVal = swapMgr.readValue(cacheKey, modes.offheap, modes.swap);
+ cacheVal = offheapMgr.readValue(cacheKey, part);
}
}
else
@@ -845,9 +844,9 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
}
if (offheap || swap) {
- GridCacheSwapManager swapMgr = ctx.isNear() ? ctx.near().dht().context().swap() : ctx.swap();
+ IgniteCacheOffheapManager offheapMgr = ctx.isNear() ? ctx.near().dht().context().offheap() : ctx.offheap();
- return swapMgr.readValue(key, offheap, swap);
+ return offheapMgr.readValue(key, ctx.affinity().partition(key));
}
return null;
@@ -1861,13 +1860,11 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
final boolean storeEnabled = !skipVals && readThrough && ctx.readThrough();
- final boolean needEntry = storeEnabled || ctx.offheap0().enabled();
-
Map<KeyCacheObject, GridCacheVersion> misses = null;
for (KeyCacheObject key : keys) {
while (true) {
- GridCacheEntryEx entry = needEntry ? entryEx(key) : peekEx(key);
+ GridCacheEntryEx entry = entryEx(key);
if (entry == null) {
if (!skipVals && ctx.config().isStatisticsEnabled())
@@ -1878,8 +1875,6 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
try {
T2<CacheObject, GridCacheVersion> res = entry.innerGetVersioned(null,
- ctx.offheap0().enabled(),
- /*unmarshal*/true,
/*update-metrics*/!skipVals,
/*event*/!skipVals,
subjId,
@@ -2892,12 +2887,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
@Override public void removeAll() throws IgniteCheckedException {
assert ctx.isLocal();
- for (Iterator<KeyCacheObject> it = ctx.swap().offHeapKeyIterator(true, true, AffinityTopologyVersion.NONE);
- it.hasNext(); )
- remove((K)it.next());
-
- for (Iterator<KeyCacheObject> it = ctx.swap().swapKeyIterator(true, true, AffinityTopologyVersion.NONE);
- it.hasNext(); )
+ for (Iterator<KeyCacheObject> it = ctx.offheap().keysIterator(); it.hasNext(); )
remove((K)it.next());
removeAll(keySet());
@@ -3784,24 +3774,22 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
*/
@Deprecated
@Nullable public Cache.Entry<K, V> randomEntry() {
- GridCacheMapEntry entry;
+ GridCloseableIterator<CacheDataRow> it;
- if (ctx.offheapTiered()) {
- Iterator<Cache.Entry<K, V>> it;
+ try {
+ it = ctx.offheap().iterator();
+ }
+ catch (IgniteCheckedException e) {
+ throw CU.convertToCacheException(e);
+ }
- try {
- it = ctx.swap().offheapIterator(true, true, ctx.affinity().affinityTopologyVersion());
- }
- catch (IgniteCheckedException e) {
- throw CU.convertToCacheException(e);
- }
+ if (it.hasNext()) {
+ CacheDataRow row = it.next();
- return it.hasNext() ? it.next() : null;
+ return new CacheEntryImpl<>((K)row.key(), (V)row.value(), row.version());
}
- else
- entry = map.randomEntry();
- return entry == null || entry.obsolete() ? null : entry.<K, V>wrapLazyValue();
+ return null;
}
/** {@inheritDoc} */
@@ -3903,7 +3891,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
if (modes.primary || modes.backup) {
AffinityTopologyVersion topVer = ctx.affinity().affinityTopologyVersion();
- IgniteCacheOffheapManager offheap = ctx.isNear() ? ctx.near().dht().context().offheap0() : ctx.offheap0();
+ IgniteCacheOffheapManager offheap = ctx.isNear() ? ctx.near().dht().context().offheap() : ctx.offheap();
if (modes.offheap)
size += offheap.entriesCount(modes.primary, modes.backup, topVer);
@@ -3991,9 +3979,6 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
final CacheOperationContext opCtx = ctx.operationContextPerCall();
- if (!ctx0.isOffHeapEnabled() && ctx0.kernalContext().discovery().size() == 1)
- return localIteratorHonorExpirePolicy(opCtx);
-
CacheQueryFuture<Map.Entry<K, V>> fut = ctx0.queries().createScanQuery(null, null, ctx.keepBinary())
.keepAll(false)
.execute();
@@ -4019,114 +4004,23 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
});
}
- /**
- * @param key Key.
- * @param deserializeBinary Deserialize binary flag.
- * @return Value.
- * @throws IgniteCheckedException If failed.
- */
- @SuppressWarnings("IfMayBeConditional")
- @Nullable public V promote(K key, boolean deserializeBinary) throws IgniteCheckedException {
- A.notNull(key, "key");
-
- if (keyCheck)
- validateCacheKey(key);
-
- KeyCacheObject cacheKey = ctx.toCacheKeyObject(key);
-
- GridCacheSwapEntry unswapped = ctx.swap().readAndRemove(cacheKey);
-
- if (unswapped == null)
- return null;
-
- GridCacheEntryEx entry = entryEx(cacheKey);
-
- try {
- if (!entry.initialValue(cacheKey, unswapped))
- return null;
- }
- catch (GridCacheEntryRemovedException ignored) {
- if (log.isDebugEnabled())
- log.debug("Entry has been concurrently removed.");
-
- return null;
- }
-
- CacheObject val = unswapped.value();
-
- Object val0 = val != null ? val.value(ctx.cacheObjectContext(), true) : null;
-
- return (V)ctx.unwrapBinaryIfNeeded(val0, !deserializeBinary);
- }
-
/** {@inheritDoc} */
- @Override public void promoteAll(@Nullable Collection<? extends K> keys) throws IgniteCheckedException {
- if (F.isEmpty(keys))
- return;
-
- if (keyCheck)
- validateCacheKeys(keys);
-
- Collection<KeyCacheObject> unswap = new ArrayList<>(keys.size());
-
- for (K key : keys) {
- KeyCacheObject cacheKey = ctx.toCacheKeyObject(key);
-
- // Do not look up in swap for existing entries.
- GridCacheEntryEx entry = peekEx(cacheKey);
-
- try {
- if (entry == null || entry.obsolete() || entry.isNewLocked()) {
- if (entry != null)
- cacheKey = entry.key();
+ @Override public long offHeapEntriesCount() {
+ try {
+ IgniteCacheOffheapManager mgr = ctx.offheap();
- unswap.add(cacheKey);
- }
- }
- catch (GridCacheEntryRemovedException ignored) {
- // No-op.
- }
+ return mgr != null ? mgr.entriesCount(false, true, ctx.affinity().affinityTopologyVersion()) : -1;
}
-
- Collection<GridCacheBatchSwapEntry> swapped = ctx.swap().readAndRemove(unswap);
-
- for (GridCacheBatchSwapEntry swapEntry : swapped) {
- KeyCacheObject key = swapEntry.key();
-
- GridCacheEntryEx entry = entryEx(key);
-
- try {
- entry.initialValue(key, swapEntry);
- }
- catch (GridCacheEntryRemovedException ignored) {
- if (log.isDebugEnabled())
- log.debug("Entry has been concurrently removed.");
- }
+ catch (IgniteCheckedException e) {
+ return 0;
}
}
/** {@inheritDoc} */
- @Override public long offHeapEntriesCount() {
- GridCacheSwapManager swapMgr = ctx.swap();
-
- return swapMgr != null ? swapMgr.offHeapEntriesCount() : -1;
- }
-
- /** {@inheritDoc} */
@Override public long offHeapAllocatedSize() {
- GridCacheSwapManager swapMgr = ctx.swap();
+ IgniteCacheOffheapManager mgr = ctx.offheap();
- return swapMgr != null ? swapMgr.offHeapAllocatedSize() : -1;
- }
-
- /** {@inheritDoc} */
- @Override public long swapSize() throws IgniteCheckedException {
- return ctx.swap().swapSize();
- }
-
- /** {@inheritDoc} */
- @Override public long swapKeys() throws IgniteCheckedException {
- return ctx.swap().swapKeys();
+ return mgr != null ? mgr.offHeapAllocatedSize() : -1;
}
/**
@@ -4592,7 +4486,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
try {
KeyCacheObject cacheKey = ctx.toCacheKeyObject(key);
- GridCacheEntryEx entry = ctx.isOffHeapEnabled() ? entryEx(cacheKey) : peekEx(cacheKey);
+ GridCacheEntryEx entry = entryEx(cacheKey);
if (entry != null)
return entry.clear(obsoleteVer, readers, null);
@@ -4629,7 +4523,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
GridCacheVersion obsoleteVer = ctx.versions().next();
- if (!ctx.evicts().evictSyncOrNearSync() && ctx.isOffHeapEnabled()) {
+ if (!ctx.evicts().evictSyncOrNearSync()) {
try {
ctx.evicts().batchEvict(keys, obsoleteVer);
}
@@ -4920,10 +4814,6 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
false,
false,
false,
- true,
- false,
- false,
- false,
null,
null,
null,
http://git-wip-us.apache.org/repos/asf/ignite/blob/49543e16/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheClearAllRunnable.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheClearAllRunnable.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheClearAllRunnable.java
index f627f4c..f6684d6 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheClearAllRunnable.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheClearAllRunnable.java
@@ -88,7 +88,7 @@ public class GridCacheClearAllRunnable<K, V> implements Runnable {
// Clear swapped entries.
if (!ctx.isNear()) {
// TODO GG-10884.
- ctx.offheap0().clear(readers);
+ ctx.offheap().clear(readers);
if (ctx.swap().offHeapEnabled()) {
if (GridQueryProcessor.isEnabled(ctx.config())) {
http://git-wip-us.apache.org/repos/asf/ignite/blob/49543e16/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
index 9c7c98f..e1c306a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
@@ -82,12 +82,10 @@ import org.apache.ignite.internal.processors.cache.version.GridCacheVersionManag
import org.apache.ignite.internal.processors.cache.version.GridCacheVersionedEntryEx;
import org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProcessor;
import org.apache.ignite.internal.processors.closure.GridClosureProcessor;
-import org.apache.ignite.internal.processors.offheap.GridOffHeapProcessor;
import org.apache.ignite.internal.processors.plugin.CachePluginManager;
import org.apache.ignite.internal.processors.timeout.GridTimeoutProcessor;
import org.apache.ignite.internal.util.F0;
import org.apache.ignite.internal.util.lang.GridFunc;
-import org.apache.ignite.internal.util.offheap.unsafe.GridUnsafeMemory;
import org.apache.ignite.internal.util.tostring.GridToStringExclude;
import org.apache.ignite.internal.util.typedef.C1;
import org.apache.ignite.internal.util.typedef.F;
@@ -144,9 +142,6 @@ public class GridCacheContext<K, V> implements Externalizable {
/** Cache configuration. */
private CacheConfiguration cacheCfg;
- /** Unsafe memory object for direct memory allocation. */
- private GridUnsafeMemory unsafeMemory;
-
/** Affinity manager. */
private GridCacheAffinityManager affMgr;
@@ -349,10 +344,6 @@ public class GridCacheContext<K, V> implements Externalizable {
log = ctx.log(getClass());
- // Create unsafe memory only if writing values
- unsafeMemory = (cacheCfg.getMemoryMode() == OFFHEAP_VALUES || cacheCfg.getMemoryMode() == OFFHEAP_TIERED) ?
- new GridUnsafeMemory(cacheCfg.getOffHeapMaxMemory()) : null;
-
gate = new GridCacheGateway<>(this);
cacheName = cacheCfg.getName();
@@ -666,13 +657,6 @@ public class GridCacheContext<K, V> implements Externalizable {
}
/**
- * @return Instance of {@link GridUnsafeMemory} object.
- */
- @Nullable public GridUnsafeMemory unsafeMemory() {
- return unsafeMemory;
- }
-
- /**
* @return Kernal context.
*/
public GridKernalContext kernalContext() {
@@ -903,13 +887,6 @@ public class GridCacheContext<K, V> implements Externalizable {
}
/**
- * @return Grid off-heap processor.
- */
- public GridOffHeapProcessor offheap() {
- return ctx.offheap();
- }
-
- /**
* @return Grid deployment manager.
*/
public GridDeploymentManager gridDeploy() {
@@ -1072,7 +1049,10 @@ public class GridCacheContext<K, V> implements Externalizable {
return drMgr;
}
- public IgniteCacheOffheapManager offheap0() {
+ /**
+ * @return Offheap manager.
+ */
+ public IgniteCacheOffheapManager offheap() {
return offheapMgr;
}
@@ -1425,17 +1405,10 @@ public class GridCacheContext<K, V> implements Externalizable {
}
/**
- * @return {@code True} if swap store of off-heap cache are enabled.
- */
- public boolean isSwapOrOffheapEnabled() {
- return isOffHeapEnabled();
- }
-
- /**
* @return {@code True} if offheap storage is enabled.
*/
public boolean isOffHeapEnabled() {
- return offheapMgr.enabled();
+ return true;
}
/**
@@ -1727,30 +1700,13 @@ public class GridCacheContext<K, V> implements Externalizable {
}
/**
- * @return {@code True} if OFFHEAP_TIERED memory mode is enabled.
- */
- public boolean offheapTiered() {
- return cacheCfg.getMemoryMode() == OFFHEAP_TIERED && isOffHeapEnabled();
- }
-
- /**
- * @return {@code True} if should use entry with offheap value pointer.
- */
- public boolean useOffheapEntry() {
- return cacheCfg.getMemoryMode() == OFFHEAP_TIERED || cacheCfg.getMemoryMode() == OFFHEAP_VALUES;
- }
-
- /**
* Converts temporary offheap object to heap-based.
*
* @param obj Object.
* @return Heap-based object.
*/
@Nullable public <T> T unwrapTemporary(@Nullable Object obj) {
- if (!offheapTiered())
- return (T)obj;
-
- return (T) cacheObjects().unwrapTemporary(this, obj);
+ return (T)cacheObjects().unwrapTemporary(this, obj);
}
/**
@@ -1881,19 +1837,6 @@ public class GridCacheContext<K, V> implements Externalizable {
}
/**
- * @param valPtr Value pointer.
- * @param tmp If {@code true} can return temporary instance which is valid while entry lock is held.
- * @return Cache object.
- * @throws IgniteCheckedException If failed.
- */
- public CacheObject fromOffheap(long valPtr, boolean tmp) throws IgniteCheckedException {
- assert config().getMemoryMode() == OFFHEAP_TIERED || config().getMemoryMode() == OFFHEAP_VALUES : cacheCfg;
- assert valPtr != 0;
-
- return ctx.cacheObjects().toCacheObject(this, valPtr, tmp);
- }
-
- /**
* @param map Map.
* @param key Key.
* @param val Value.
http://git-wip-us.apache.org/repos/asf/ignite/blob/49543e16/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java
index 076dfc0..3e509d8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java
@@ -116,15 +116,6 @@ public interface GridCacheEntryEx {
public CacheObject rawGet();
/**
- * @param tmp If {@code true} can return temporary instance which is valid while entry lock is held,
- * temporary object can used for filter evaluation or transform closure execution and
- * should not be returned to user.
- * @return Value (unmarshalled if needed).
- * @throws IgniteCheckedException If failed.
- */
- public CacheObject rawGetOrUnmarshal(boolean tmp) throws IgniteCheckedException;
-
- /**
* @return {@code True} if has value or value bytes.
*/
public boolean hasValue();
@@ -218,14 +209,13 @@ public interface GridCacheEntryEx {
throws GridCacheEntryRemovedException, IgniteCheckedException;
/**
- * @param swap Swap flag.
* @param obsoleteVer Version for eviction.
* @param filter Optional filter.
* @return {@code True} if entry could be evicted.
* @throws IgniteCheckedException In case of error.
*/
- public boolean evictInternal(boolean swap, GridCacheVersion obsoleteVer,
- @Nullable CacheEntryPredicate[] filter) throws IgniteCheckedException;
+ public boolean evictInternal(GridCacheVersion obsoleteVer, @Nullable CacheEntryPredicate[] filter)
+ throws IgniteCheckedException;
/**
* Evicts entry when batch evict is performed. When called, does not write entry data to swap, but instead
@@ -274,16 +264,9 @@ public interface GridCacheEntryEx {
/**
* @param tx Ongoing transaction (possibly null).
- * @param readSwap Flag indicating whether to check swap memory.
* @param readThrough Flag indicating whether to read through.
- * @param failFast If {@code true}, then throw {@link GridCacheFilterFailedException} if
- * filter didn't pass.
- * @param unmarshal Unmarshal flag.
* @param updateMetrics If {@code true} then metrics should be updated.
* @param evt Flag to signal event notification.
- * @param tmp If {@code true} can return temporary instance which is valid while entry lock is held,
- * temporary object can used for filter evaluation or transform closure execution and
- * should not be returned to user.
* @param subjId Subject ID initiated this read.
* @param transformClo Transform closure to record event.
* @param taskName Task name.
@@ -293,13 +276,9 @@ public interface GridCacheEntryEx {
* @throws GridCacheEntryRemovedException If entry was removed.
*/
@Nullable public CacheObject innerGet(@Nullable IgniteInternalTx tx,
- boolean readSwap,
boolean readThrough,
- boolean failFast,
- boolean unmarshal,
boolean updateMetrics,
boolean evt,
- boolean tmp,
UUID subjId,
Object transformClo,
String taskName,
@@ -309,8 +288,6 @@ public interface GridCacheEntryEx {
/**
* @param tx Cache transaction.
- * @param readSwap Flag indicating whether to check swap memory.
- * @param unmarshal Unmarshal flag.
* @param updateMetrics If {@code true} then metrics should be updated.
* @param evt Flag to signal event notification.
* @param subjId Subject ID initiated this read.
@@ -323,8 +300,6 @@ public interface GridCacheEntryEx {
*/
@Nullable public T2<CacheObject, GridCacheVersion> innerGetVersioned(
IgniteInternalTx tx,
- boolean readSwap,
- boolean unmarshal,
boolean updateMetrics,
boolean evt,
UUID subjId,
@@ -341,8 +316,7 @@ public interface GridCacheEntryEx {
* @throws IgniteCheckedException If reload failed.
* @throws GridCacheEntryRemovedException If entry has been removed.
*/
- @Nullable public CacheObject innerReload() throws IgniteCheckedException,
- GridCacheEntryRemovedException;
+ @Nullable public CacheObject innerReload() throws IgniteCheckedException, GridCacheEntryRemovedException;
/**
* @param tx Cache transaction.
http://git-wip-us.apache.org/repos/asf/ignite/blob/49543e16/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java
index 109167d..e85f224 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java
@@ -706,7 +706,7 @@ public class GridCacheEvictionManager extends GridCacheManagerAdapter {
boolean hasVal = recordable && entry.hasValue();
- boolean evicted = entry.evictInternal(cctx.isOffHeapEnabled(), obsoleteVer, filter);
+ boolean evicted = entry.evictInternal(obsoleteVer, filter);
if (evicted) {
// Remove manually evicted entry from policy.
@@ -955,7 +955,6 @@ public class GridCacheEvictionManager extends GridCacheManagerAdapter {
*/
public void batchEvict(Collection<?> keys, @Nullable GridCacheVersion obsoleteVer) throws IgniteCheckedException {
assert !evictSyncAgr;
- assert cctx.isOffHeapEnabled();
List<GridCacheEntryEx> locked = new ArrayList<>(keys.size());
http://git-wip-us.apache.org/repos/asf/ignite/blob/49543e16/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 267d8bc..48e6456 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
@@ -31,10 +31,7 @@ import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
import org.apache.ignite.IgniteLogger;
import org.apache.ignite.cache.CacheAtomicWriteOrderMode;
-import org.apache.ignite.cache.CacheMemoryMode;
import org.apache.ignite.cache.eviction.EvictableEntry;
-import org.apache.ignite.internal.managers.deployment.GridDeploymentInfo;
-import org.apache.ignite.internal.managers.deployment.GridDeploymentInfoBean;
import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheEntry;
import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtLocalPartition;
@@ -43,7 +40,6 @@ import org.apache.ignite.internal.processors.cache.extras.GridCacheEntryExtras;
import org.apache.ignite.internal.processors.cache.extras.GridCacheMvccEntryExtras;
import org.apache.ignite.internal.processors.cache.extras.GridCacheObsoleteEntryExtras;
import org.apache.ignite.internal.processors.cache.extras.GridCacheTtlEntryExtras;
-import org.apache.ignite.internal.processors.cache.query.GridCacheQueryManager;
import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx;
import org.apache.ignite.internal.processors.cache.transactions.IgniteTxEntry;
import org.apache.ignite.internal.processors.cache.transactions.IgniteTxKey;
@@ -58,7 +54,6 @@ import org.apache.ignite.internal.util.lang.GridClosureException;
import org.apache.ignite.internal.util.lang.GridMetadataAwareAdapter;
import org.apache.ignite.internal.util.lang.GridTuple;
import org.apache.ignite.internal.util.lang.GridTuple3;
-import org.apache.ignite.internal.util.offheap.unsafe.GridUnsafeMemory;
import org.apache.ignite.internal.util.tostring.GridToStringExclude;
import org.apache.ignite.internal.util.tostring.GridToStringInclude;
import org.apache.ignite.internal.util.typedef.F;
@@ -205,7 +200,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
if (cctx.cache().isIgfsDataCache() &&
cctx.kernalContext().igfsHelper().isIgfsBlockKey(key.value(cctx.cacheObjectContext(), false))) {
int newSize = valueLength0(val, null);
- int oldSize = valueLength0(this.val, (this.val == null && hasOffHeapPointer()) ? valueBytes0() : null);
+ int oldSize = valueLength0(this.val, null);
int delta = newSize - oldSize;
@@ -213,51 +208,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
cctx.cache().onIgfsDataSizeChanged(delta);
}
- if (!isOffHeapValuesOnly()) {
- this.val = val;
-
- offHeapPointer(0);
- }
- else {
- try {
- if (cctx.deploymentEnabled()) {
- Object val0 = null;
-
- if (val != null && val.cacheObjectType() != CacheObject.TYPE_BYTE_ARR) {
- val0 = cctx.cacheObjects().unmarshal(cctx.cacheObjectContext(),
- val.valueBytes(cctx.cacheObjectContext()), cctx.deploy().globalLoader());
-
- if (val0 != null)
- cctx.gridDeploy().deploy(val0.getClass(), val0.getClass().getClassLoader());
- }
-
- if (U.p2pLoader(val0)) {
- cctx.deploy().addDeploymentContext(
- new GridDeploymentInfoBean((GridDeploymentInfo)val0.getClass().getClassLoader()));
- }
- }
-
- GridUnsafeMemory mem = cctx.unsafeMemory();
-
- assert mem != null;
-
- if (val != null) {
- byte type = val.cacheObjectType();
-
- offHeapPointer(mem.putOffHeap(offHeapPointer(), val.valueBytes(cctx.cacheObjectContext()), type));
- }
- else {
- mem.removeOffHeap(offHeapPointer());
-
- offHeapPointer(0);
- }
- }
- catch (IgniteCheckedException e) {
- U.error(log, "Failed to deserialize value [entry=" + this + ", val=" + val + ']');
-
- throw new IgniteException(e);
- }
- }
+ this.val = val;
}
/**
@@ -279,23 +230,6 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
return valBytes.get1().length - (((valBytes.get2() == CacheObject.TYPE_BYTE_ARR) ? 0 : 6));
}
- /**
- * @return Value bytes.
- */
- protected CacheObject valueBytesUnlocked() {
- assert Thread.holdsLock(this);
-
- CacheObject val0 = val;
-
- if (val0 == null && hasOffHeapPointer()) {
- IgniteBiTuple<byte[], Byte> t = valueBytes0();
-
- return cctx.cacheObjects().toCacheObject(cctx.cacheObjectContext(), t.get2(), t.get1());
- }
-
- return val0;
- }
-
/** {@inheritDoc} */
@Override public int memorySize() throws IgniteCheckedException {
byte[] kb;
@@ -417,7 +351,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
info.setDeleted(deletedUnlocked());
if (!expired)
- info.value(valueBytesUnlocked());
+ info.value(val);
}
}
@@ -442,7 +376,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
checkObsolete();
if (isStartVersion() && ((flags & IS_UNSWAPPED_MASK) == 0)) {
- IgniteBiTuple<CacheObject, GridCacheVersion> read = cctx.offheap0().read(key, partition());
+ IgniteBiTuple<CacheObject, GridCacheVersion> read = cctx.offheap().read(key, partition());
flags |= IS_UNSWAPPED_MASK;
@@ -456,58 +390,58 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
}
// TODO GG-10884.
- if (false) {
- GridCacheSwapEntry e;
-
- if (cctx.offheapTiered()) {
- e = cctx.swap().readOffheapPointer(this);
-
- if (e != null) {
- if (e.offheapPointer() > 0) {
- offHeapPointer(e.offheapPointer());
-
- flags |= IS_OFFHEAP_PTR_MASK;
-
- if (needVal) {
- CacheObject val = cctx.fromOffheap(offHeapPointer(), false);
-
- e.value(val);
- }
- }
- else // Read from swap.
- offHeapPointer(0);
- }
- }
- else
- e = detached() ? cctx.swap().read(this, true, true, true, false) : cctx.swap().readAndRemove(this);
-
- if (log.isDebugEnabled())
- log.debug("Read swap entry [swapEntry=" + e + ", cacheEntry=" + this + ']');
-
- flags |= IS_UNSWAPPED_MASK;
-
- // If there is a value.
- if (e != null) {
- long delta = e.expireTime() == 0 ? 0 : e.expireTime() - U.currentTimeMillis();
-
- if (delta >= 0) {
- CacheObject val = e.value();
-
- val = cctx.kernalContext().cacheObjects().prepareForCache(val, cctx);
-
- // Set unswapped value.
- update(val, e.expireTime(), e.ttl(), e.version());
-
- // Must update valPtr again since update() will reset it.
- if (cctx.offheapTiered() && e.offheapPointer() > 0)
- offHeapPointer(e.offheapPointer());
-
- return val;
- }
- else
- clearIndex(e.value(), e.version());
- }
- }
+// if (false) {
+// GridCacheSwapEntry e;
+//
+// if (cctx.offheapTiered()) {
+// e = cctx.swap().readOffheapPointer(this);
+//
+// if (e != null) {
+// if (e.offheapPointer() > 0) {
+// offHeapPointer(e.offheapPointer());
+//
+// flags |= IS_OFFHEAP_PTR_MASK;
+//
+// if (needVal) {
+// CacheObject val = cctx.fromOffheap(offHeapPointer(), false);
+//
+// e.value(val);
+// }
+// }
+// else // Read from swap.
+// offHeapPointer(0);
+// }
+// }
+// else
+// e = detached() ? cctx.swap().read(this, true, true, true, false) : cctx.swap().readAndRemove(this);
+//
+// if (log.isDebugEnabled())
+// log.debug("Read swap entry [swapEntry=" + e + ", cacheEntry=" + this + ']');
+//
+// flags |= IS_UNSWAPPED_MASK;
+//
+// // If there is a value.
+// if (e != null) {
+// long delta = e.expireTime() == 0 ? 0 : e.expireTime() - U.currentTimeMillis();
+//
+// if (delta >= 0) {
+// CacheObject val = e.value();
+//
+// val = cctx.kernalContext().cacheObjects().prepareForCache(val, cctx);
+//
+// // Set unswapped value.
+// update(val, e.expireTime(), e.ttl(), e.version());
+//
+// // Must update valPtr again since update() will reset it.
+// if (cctx.offheapTiered() && e.offheapPointer() > 0)
+// offHeapPointer(e.offheapPointer());
+//
+// return val;
+// }
+// else
+// clearIndex(e.value(), e.version());
+// }
+// }
}
}
@@ -520,22 +454,15 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
protected IgniteBiTuple<byte[], Byte> valueBytes0() {
assert Thread.holdsLock(this);
- if (hasOffHeapPointer()) {
- assert isOffHeapValuesOnly() || cctx.offheapTiered();
+ assert val != null;
- return cctx.unsafeMemory().get(offHeapPointer());
- }
- else {
- assert val != null;
-
- try {
- byte[] bytes = val.valueBytes(cctx.cacheObjectContext());
+ try {
+ byte[] bytes = val.valueBytes(cctx.cacheObjectContext());
- return new IgniteBiTuple<>(bytes, val.cacheObjectType());
- }
- catch (IgniteCheckedException e) {
- throw new IgniteException(e);
- }
+ return new IgniteBiTuple<>(bytes, val.cacheObjectType());
+ }
+ catch (IgniteCheckedException e) {
+ throw new IgniteException(e);
}
}
@@ -556,13 +483,9 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
/** {@inheritDoc} */
@Nullable @Override public final CacheObject innerGet(@Nullable IgniteInternalTx tx,
- boolean readSwap,
boolean readThrough,
- boolean failFast,
- boolean unmarshal,
boolean updateMetrics,
boolean evt,
- boolean tmp,
UUID subjId,
Object transformClo,
String taskName,
@@ -570,12 +493,9 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
boolean keepBinary)
throws IgniteCheckedException, GridCacheEntryRemovedException {
return (CacheObject)innerGet0(tx,
- readSwap,
readThrough,
evt,
- unmarshal,
updateMetrics,
- tmp,
subjId,
transformClo,
taskName,
@@ -587,8 +507,6 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
/** {@inheritDoc} */
@Nullable @Override public T2<CacheObject, GridCacheVersion> innerGetVersioned(
IgniteInternalTx tx,
- boolean readSwap,
- boolean unmarshal,
boolean updateMetrics,
boolean evt,
UUID subjId,
@@ -598,12 +516,9 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
boolean keepBinary)
throws IgniteCheckedException, GridCacheEntryRemovedException {
return (T2<CacheObject, GridCacheVersion>)innerGet0(tx,
- readSwap,
false,
evt,
- unmarshal,
updateMetrics,
- false,
subjId,
transformClo,
taskName,
@@ -615,12 +530,9 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
/** {@inheritDoc} */
@SuppressWarnings({"unchecked", "RedundantTypeArguments", "TooBroadScope"})
private Object innerGet0(IgniteInternalTx tx,
- boolean readSwap,
boolean readThrough,
boolean evt,
- boolean unmarshal,
boolean updateMetrics,
- boolean tmp,
UUID subjId,
Object transformClo,
String taskName,
@@ -646,8 +558,6 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
CacheObject expiredVal = null;
- boolean hasOldBytes;
-
synchronized (this) {
checkObsolete();
@@ -674,34 +584,20 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
CacheObject val = this.val;
- hasOldBytes = hasOffHeapPointer();
-
- if ((unmarshal || isOffHeapValuesOnly()) && !expired && val == null && hasOldBytes)
- val = rawGetOrUnmarshalUnlocked(tmp);
-
boolean valid = valid(tx != null ? tx.topologyVersion() : cctx.affinity().affinityTopologyVersion());
// Attempt to load from swap.
- if (val == null && !hasOldBytes && readSwap) {
+ if (val == null && !isNear()) {
// Only promote when loading initial state.
if (isNew() || !valid) {
// If this entry is already expired (expiration time was too low),
// we simply remove from swap and clear index.
if (expired) {
// Previous value is guaranteed to be null
- clearIndex(null, ver);
-
- cctx.offheap0().remove(key);
+ removeValue(null, ver);
}
else {
- // Read and remove swap entry.
- if (tmp) {
- unswap(false);
-
- val = rawGetOrUnmarshalUnlocked(true);
- }
- else
- val = unswap();
+ val = unswap();
// Recalculate expiration after swap read.
if (expireTime > 0) {
@@ -726,7 +622,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
value(null);
}
- if (old == null && !hasOldBytes) {
+ if (old == null) {
if (updateMetrics && cctx.cache().configuration().isStatisticsEnabled())
cctx.cache().metrics0().onRead(false);
}
@@ -748,7 +644,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
null,
false,
expiredVal,
- expiredVal != null || hasOldBytes,
+ expiredVal != null,
subjId,
null,
taskName,
@@ -771,7 +667,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
ret,
ret != null,
old,
- hasOldBytes || old != null,
+ old != null,
subjId,
transformClo != null ? transformClo.getClass().getName() : null,
taskName,
@@ -829,22 +725,15 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
GridCacheVersion nextVer = nextVersion();
- CacheObject prevVal = rawGetOrUnmarshalUnlocked(false);
-
long expTime = CU.toExpireTime(ttl);
if (loadedFromStore)
// Update indexes before actual write to entry.
- updateIndex(ret, expTime, nextVer, prevVal);
-
- boolean hadValPtr = hasOffHeapPointer();
+ storeValue(ret, expTime, nextVer);
// Don't change version for read-through.
update(ret, expTime, ttl, nextVer);
- if (hadValPtr && cctx.offheapTiered())
- cctx.swap().removeOffheap(key);
-
if (cctx.deferredDelete() && deletedUnlocked() && !isInternal() && !detached())
deletedUnlocked(false);
}
@@ -859,7 +748,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
ret,
ret != null,
old,
- hasOldBytes,
+ old != null,
subjId,
transformClo != null ? transformClo.getClass().getName() : null,
taskName,
@@ -912,7 +801,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
// If version matched, set value.
if (startVer.equals(ver)) {
- CacheObject old = rawGetOrUnmarshalUnlocked(false);
+ CacheObject old = this.val;
long expTime = CU.toExpireTime(ttl);
@@ -921,13 +810,13 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
// Update indexes.
if (ret != null) {
- updateIndex(ret, expTime, nextVer, old);
+ storeValue(ret, expTime, nextVer);
if (cctx.deferredDelete() && !isInternal() && !detached() && deletedUnlocked())
deletedUnlocked(false);
}
else {
- clearIndex(old, ver);
+ removeValue(old, ver);
if (cctx.deferredDelete() && !isInternal() && !detached() && !deletedUnlocked())
deletedUnlocked(true);
@@ -935,11 +824,6 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
update(ret, expTime, ttl, nextVer);
- if (ret != null)
- cctx.offheap0().put(key, ret, nextVer, partition());
- else
- cctx.offheap0().remove(key);
-
touch = true;
// If value was set - return, otherwise try again.
@@ -1028,7 +912,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
assert newVer != null : "Failed to get write version for tx: " + tx;
- old = (retval || intercept) ? rawGetOrUnmarshalUnlocked(!retval) : this.val;
+ old = this.val;
if (intercept) {
val0 = CU.value(val, cctx, false);
@@ -1072,14 +956,12 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
// Detach value before index update.
val = cctx.kernalContext().cacheObjects().prepareForCache(val, cctx);
- // Update index inside synchronization since it can be updated
- // in load methods without actually holding entry lock.
- if (val != null) {
- updateIndex(val, expireTime, newVer, old);
+ assert val != null;
- if (cctx.deferredDelete() && deletedUnlocked() && !isInternal() && !detached())
- deletedUnlocked(false);
- }
+ storeValue(val, expireTime, newVer);
+
+ if (cctx.deferredDelete() && deletedUnlocked() && !isInternal() && !detached())
+ deletedUnlocked(false);
updateCntr0 = nextPartCounter(topVer);
@@ -1088,8 +970,6 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
update(val, expireTime, ttl, newVer);
- cctx.offheap0().put(key, val, newVer, partition());
-
drReplicate(drType, val, newVer);
recordNodeId(affNodeId, topVer);
@@ -1205,7 +1085,8 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
newVer = explicitVer != null ? explicitVer : tx == null ? nextVersion() : tx.writeVersion();
- old = (retval || intercept) ? rawGetOrUnmarshalUnlocked(!retval) : val;
+ // TODO GG-10884 need unswap?.
+ old = val;
if (intercept) {
entry0 = new CacheLazyEntry(cctx, key, old, keepBinary);
@@ -1222,22 +1103,10 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
if (old == null)
old = saveValueForIndexUnlocked();
- // Clear indexes inside of synchronization since indexes
- // can be updated without actually holding entry lock.
- clearIndex(old, ver);
-
- cctx.offheap0().remove(key);
-
- boolean hadValPtr = hasOffHeapPointer();
+ removeValue(old, ver);
update(null, 0, 0, newVer);
- if (cctx.offheapTiered() && hadValPtr) {
- boolean rmv = cctx.swap().removeOffheap(key);
-
- assert rmv;
- }
-
if (cctx.deferredDelete() && !detached() && !isInternal()) {
if (!deletedUnlocked()) {
deletedUnlocked(true);
@@ -1381,8 +1250,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
if (isNew())
unswap(retval);
- // Possibly get old value form store.
- old = needVal ? rawGetOrUnmarshalUnlocked(!retval) : val;
+ old = val;
boolean readFromStore = false;
@@ -1414,9 +1282,9 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
old = cctx.kernalContext().cacheObjects().prepareForCache(old, cctx);
if (old != null)
- updateIndex(old, expireTime, ver, null);
+ storeValue(old, expireTime, ver);
else
- clearIndex(null, ver);
+ removeValue(null, ver);
update(old, expireTime, ttl, ver);
}
@@ -1559,16 +1427,12 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
// Must persist inside synchronization in non-tx mode.
cctx.store().put(null, key, updated, ver);
- // Update index inside synchronization since it can be updated
- // in load methods without actually holding entry lock.
- updateIndex(updated, expireTime, ver, old);
+ storeValue(updated, expireTime, ver);
assert ttl != CU.TTL_ZERO;
update(updated, expireTime, ttl, ver);
- cctx.offheap0().put(key, updated, ver, partition());
-
if (evt) {
CacheObject evtOld = null;
@@ -1595,25 +1459,13 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
// Must persist inside synchronization in non-tx mode.
cctx.store().remove(null, key);
- boolean hasValPtr = hasOffHeapPointer();
-
if (old == null)
old = saveValueForIndexUnlocked();
- // Update index inside synchronization since it can be updated
- // in load methods without actually holding entry lock.
- clearIndex(old, this.ver);
+ removeValue(old, this.ver);
update(null, CU.TTL_ETERNAL, CU.EXPIRE_TIME_ETERNAL, ver);
- cctx.offheap0().remove(key);
-
- if (cctx.offheapTiered() && hasValPtr) {
- boolean rmv = cctx.swap().removeOffheap(key);
-
- assert rmv;
- }
-
if (evt) {
CacheObject evtOld = null;
@@ -1744,7 +1596,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
EntryProcessor<Object, Object, ?> entryProcessor = (EntryProcessor<Object, Object, ?>)writeObj;
- oldVal = rawGetOrUnmarshalUnlocked(true);
+ oldVal = this.val;
CacheInvokeEntry<Object, Object> entry = new CacheInvokeEntry(cctx, key, oldVal, version(), keepBinary);
@@ -1807,7 +1659,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
cctx.writeThrough() && // and store is enabled,
primary) // and we are primary.
{
- CacheObject val = rawGetOrUnmarshalUnlocked(false);
+ CacheObject val = this.val;
if (val == null) {
assert deletedUnlocked();
@@ -1819,7 +1671,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
}
return new GridCacheUpdateAtomicResult(false,
- retval ? rawGetOrUnmarshalUnlocked(false) : null,
+ retval ? this.val : null,
null,
invokeRes,
CU.TTL_ETERNAL,
@@ -1860,7 +1712,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
log.debug("Received entry update with same version as current (will update store) " +
"[entry=" + this + ", newVer=" + newVer + ']');
- CacheObject val = rawGetOrUnmarshalUnlocked(false);
+ CacheObject val = this.val;
if (val == null) {
assert deletedUnlocked();
@@ -1909,7 +1761,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
}
return new GridCacheUpdateAtomicResult(false,
- retval ? rawGetOrUnmarshalUnlocked(false) : null,
+ retval ? this.val : null,
null,
invokeRes,
CU.TTL_ETERNAL,
@@ -1926,7 +1778,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
}
// Prepare old value and value bytes.
- oldVal = needVal ? rawGetOrUnmarshalUnlocked(!retval) : val;
+ oldVal = this.val;
// Possibly read value from store.
boolean readFromStore = false;
@@ -1960,9 +1812,9 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
}
if (oldVal != null)
- updateIndex(oldVal, initExpireTime, ver, null);
+ storeValue(oldVal, initExpireTime, ver);
else
- clearIndex(null, ver);
+ removeValue(null, ver);
update(oldVal, initExpireTime, initTtl, ver);
@@ -2174,14 +2026,10 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
updated = cctx.kernalContext().cacheObjects().prepareForCache(updated, cctx);
- // Update index inside synchronization since it can be updated
- // in load methods without actually holding entry lock.
- updateIndex(updated, newExpireTime, newVer, oldVal);
+ storeValue(updated, newExpireTime, newVer);
update(updated, newExpireTime, newTtl, newVer);
- cctx.offheap0().put(key, updated, newVer, partition());
-
updateCntr0 = nextPartCounter(topVer);
if (updateCntr != null)
@@ -2238,9 +2086,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
if (oldVal == null)
oldVal = saveValueForIndexUnlocked();
- // Update index inside synchronization since it can be updated
- // in load methods without actually holding entry lock.
- clearIndex(oldVal, ver);
+ removeValue(oldVal, ver);
if (hadVal) {
assert !deletedUnlocked();
@@ -2262,22 +2108,12 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
enqueueVer = newVer;
- boolean hasValPtr = hasOffHeapPointer();
-
// Clear value on backup. Entry will be removed from cache when it got evicted from queue.
update(null, CU.TTL_ETERNAL, CU.EXPIRE_TIME_ETERNAL, newVer);
- cctx.offheap0().remove(key);
-
assert newSysTtl == CU.TTL_NOT_CHANGED;
assert newSysExpireTime == CU.EXPIRE_TIME_CALCULATE;
- if (cctx.offheapTiered() && hasValPtr) {
- boolean rmv = cctx.swap().removeOffheap(key);
-
- assert rmv;
- }
-
clearReaders();
recordNodeId(affNodeId, topVer);
@@ -2523,9 +2359,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
if (log.isDebugEnabled())
log.debug("Entry has been marked obsolete: " + this);
- clearIndex(val, ver);
-
- cctx.offheap0().remove(key);
+ removeValue(val, ver);
ret = true;
rmv = true;
@@ -2702,9 +2536,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
ver = newVer;
- clearIndex(val, ver);
-
- cctx.offheap0().remove(key);
+ removeValue(val, ver);
onInvalidate();
}
@@ -2846,13 +2678,6 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
}
/**
- * @return {@code True} if values should be stored off-heap.
- */
- protected boolean isOffHeapValuesOnly() {
- return cctx.config().getMemoryMode() == CacheMemoryMode.OFFHEAP_VALUES;
- }
-
- /**
* @throws GridCacheEntryRemovedException If entry is obsolete.
*/
protected void checkObsolete() throws GridCacheEntryRemovedException {
@@ -2989,7 +2814,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
checkObsolete();
ver = this.ver;
- val = rawGetOrUnmarshalUnlocked(false);
+ val = this.val;
if (val != null && expiryPlc != null)
updateTtl(expiryPlc);
@@ -3029,9 +2854,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
log.debug("Checked expiration time for entry [timeLeft=" + delta + ", entry=" + this + ']');
if (delta <= 0) {
- clearIndex(saveValueForIndexUnlocked(), ver);
-
- cctx.offheap0().remove(key);
+ removeValue(saveValueForIndexUnlocked(), ver);
return true;
}
@@ -3048,36 +2871,6 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
}
/** {@inheritDoc} */
- @Nullable @Override public synchronized CacheObject rawGetOrUnmarshal(boolean tmp) throws IgniteCheckedException {
- return rawGetOrUnmarshalUnlocked(tmp);
- }
-
- /**
- * @param tmp If {@code true} can return temporary instance.
- * @return Value (unmarshalled if needed).
- * @throws IgniteCheckedException If failed.
- */
- @Nullable public CacheObject rawGetOrUnmarshalUnlocked(boolean tmp) throws IgniteCheckedException {
- assert Thread.holdsLock(this);
-
- CacheObject val = this.val;
-
- if (val != null)
- return val;
-
- if (hasOffHeapPointer()) {
- CacheObject val0 = cctx.fromOffheap(offHeapPointer(), tmp);
-
- if (!tmp && cctx.kernalContext().config().isPeerClassLoadingEnabled())
- val0.finishUnmarshal(cctx.cacheObjectContext(), cctx.deploy().globalLoader());
-
- return val0;
- }
-
- return null;
- }
-
- /** {@inheritDoc} */
@Override public synchronized boolean hasValue() {
return hasValueUnlocked();
}
@@ -3088,7 +2881,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
protected boolean hasValueUnlocked() {
assert Thread.holdsLock(this);
- return val != null || hasOffHeapPointer();
+ return val != null;
}
/** {@inheritDoc} */
@@ -3120,7 +2913,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
val = cctx.kernalContext().cacheObjects().prepareForCache(val, cctx);
if (val != null)
- updateIndex(val, expTime, ver, null);
+ storeValue(val, expTime, ver);
// Version does not change for load ops.
update(val, expTime, ttl, ver);
@@ -3215,7 +3008,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
throws IgniteCheckedException, GridCacheEntryRemovedException {
boolean isNew = isStartVersion();
- CacheObject val = isNew ? unswap(true) : rawGetOrUnmarshalUnlocked(false);
+ CacheObject val = isNew ? unswap(true) : this.val;
return new GridCachePlainVersionedEntry<>(key.value(cctx.cacheObjectContext(), true),
CU.value(val, cctx, true),
@@ -3243,7 +3036,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
if (newVer == null)
newVer = cctx.versions().next();
- CacheObject old = rawGetOrUnmarshalUnlocked(false);
+ CacheObject old = this.val;
long ttl = ttlExtras();
@@ -3253,7 +3046,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
val = cctx.kernalContext().cacheObjects().prepareForCache(val, cctx);
if (val != null) {
- updateIndex(val, expTime, newVer, old);
+ storeValue(val, expTime, newVer);
if (deletedUnlocked())
deletedUnlocked(false);
@@ -3467,8 +3260,6 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
synchronized (this) {
CacheObject expiredVal = saveOldValueUnlocked(false);
- boolean hasOldBytes = hasOffHeapPointer();
-
boolean expired = checkExpired();
if (expired) {
@@ -3488,9 +3279,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
}
}
- clearIndex(expiredVal, ver);
-
- cctx.offheap0().remove(key);
+ removeValue(expiredVal, ver);
if (cctx.events().isRecordable(EVT_CACHE_OBJECT_EXPIRED)) {
cctx.events().addEvent(partition(),
@@ -3501,7 +3290,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
null,
false,
expiredVal,
- expiredVal != null || hasOldBytes,
+ expiredVal != null,
null,
null,
null,
@@ -3610,7 +3399,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
@Override public synchronized CacheObject valueBytes() throws GridCacheEntryRemovedException {
checkObsolete();
- return valueBytesUnlocked();
+ return this.val;
}
/** {@inheritDoc} */
@@ -3622,57 +3411,39 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
checkObsolete();
if (ver == null || this.ver.equals(ver))
- val = valueBytesUnlocked();
+ val = this.val;
}
return val;
}
/**
- * Updates cache index.
+ * Stores value in offheap.
*
* @param val Value.
* @param expireTime Expire time.
* @param ver New entry version.
- * @param prevVal Previous value.
* @throws IgniteCheckedException If update failed.
*/
- protected void updateIndex(@Nullable CacheObject val,
+ protected void storeValue(@Nullable CacheObject val,
long expireTime,
- GridCacheVersion ver,
- @Nullable CacheObject prevVal) throws IgniteCheckedException {
+ GridCacheVersion ver) throws IgniteCheckedException {
assert Thread.holdsLock(this);
- assert val != null : "null values in update index for key: " + key;
+ assert val != null : "null values in update for key: " + key;
- try {
- GridCacheQueryManager qryMgr = cctx.queries();
-
- if (qryMgr.enabled())
- qryMgr.store(key, partition(), val, ver, expireTime);
- }
- catch (IgniteCheckedException e) {
- throw new GridCacheIndexUpdateException(e);
- }
+ cctx.offheap().update(key, val, ver, expireTime, partition());
}
/**
- * Clears index.
+ * Removes value from offheap.
*
* @param prevVal Previous value (if needed for index update).
* @throws IgniteCheckedException If failed.
*/
- protected void clearIndex(CacheObject prevVal, GridCacheVersion prevVer) throws IgniteCheckedException {
+ protected void removeValue(CacheObject prevVal, GridCacheVersion prevVer) throws IgniteCheckedException {
assert Thread.holdsLock(this);
- try {
- GridCacheQueryManager<?, ?> qryMgr = cctx.queries();
-
- if (qryMgr.enabled())
- qryMgr.remove(key(), partition(), prevVal, prevVer);
- }
- catch (IgniteCheckedException e) {
- throw new GridCacheIndexUpdateException(e);
- }
+ cctx.offheap().remove(key, prevVal, prevVer, partition());
}
/**
@@ -3697,10 +3468,14 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
if (qryOnly && !cctx.queries().enabled())
return null;
- CacheObject val = rawGetOrUnmarshalUnlocked(false);
+ CacheObject val = this.val;
+
+ if (val == null && isStartVersion()) {
+ IgniteBiTuple<CacheObject, GridCacheVersion> t = cctx.offheap().read(key, partition());
- if (val == null)
- val = cctx.swap().readValue(key, true, true);
+ if (t != null)
+ val = t.get1();
+ }
return val;
}
@@ -3716,10 +3491,10 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
if (tx != null) {
GridTuple<CacheObject> peek = tx.peek(cctx, false, key, null);
- val = peek == null ? rawGetOrUnmarshal(false) : peek.get();
+ val = peek == null ? rawGet() : peek.get();
}
else
- val = rawGetOrUnmarshal(false);
+ val = rawGet();
return new CacheEntryImpl<>(key.<K>value(cctx.cacheObjectContext(), false),
CU.<V>value(val, cctx, false), ver);
@@ -3727,9 +3502,6 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
catch (GridCacheFilterFailedException ignored) {
throw new IgniteException("Should never happen.");
}
- catch (IgniteCheckedException e) {
- throw new IgniteException("Failed to wrap entry: " + this, e);
- }
}
/** {@inheritDoc} */
@@ -3796,7 +3568,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
}
/** {@inheritDoc} */
- @Override public boolean evictInternal(boolean swap, GridCacheVersion obsoleteVer,
+ @Override public boolean evictInternal(GridCacheVersion obsoleteVer,
@Nullable CacheEntryPredicate[] filter) throws IgniteCheckedException {
// TODO GG-10884: evictions from offheap are not supported.
@@ -3824,8 +3596,6 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
return true;
}
- else
- evictFailed(prev);
}
}
else {
@@ -3864,11 +3634,8 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
return true;
}
- else {
- evictFailed(prevVal);
-
+ else
return false;
- }
}
}
}
@@ -3887,27 +3654,6 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
return false;
}
- /**
- * @param prevVal Previous value.
- * @throws IgniteCheckedException If failed.
- */
- private void evictFailed(@Nullable CacheObject prevVal) throws IgniteCheckedException {
- if (cctx.offheapTiered() && ((flags & IS_OFFHEAP_PTR_MASK) != 0)) {
- flags &= ~IS_OFFHEAP_PTR_MASK;
-
- if (prevVal != null) {
- cctx.swap().removeOffheap(key());
-
- value(prevVal);
-
- GridCacheQueryManager qryMgr = cctx.queries();
-
- if (qryMgr.enabled())
- qryMgr.onUnswap(key, partition(), prevVal);
- }
- }
- }
-
/** {@inheritDoc} */
@Override public GridCacheBatchSwapEntry evictInBatchInternal(GridCacheVersion obsoleteVer)
throws IgniteCheckedException {
@@ -3920,13 +3666,6 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
try {
if (!hasReaders() && markObsolete0(obsoleteVer, false, null)) {
if (!isStartVersion() && hasValueUnlocked()) {
- if (cctx.offheapTiered() && hasOffHeapPointer()) {
- if (cctx.swap().offheapEvictionEnabled())
- cctx.swap().enableOffheapEviction(key(), partition());
-
- return null;
- }
-
IgniteUuid valClsLdrId = null;
IgniteUuid keyClsLdrId = null;
@@ -4147,27 +3886,6 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
}
/**
- * @return True if entry has off-heap value pointer.
- */
- protected boolean hasOffHeapPointer() {
- return false;
- }
-
- /**
- * @return Off-heap value pointer.
- */
- protected long offHeapPointer() {
- return 0;
- }
-
- /**
- * @param valPtr Off-heap value pointer.
- */
- protected void offHeapPointer(long valPtr) {
- // No-op.
- }
-
- /**
* @return Size of extras object.
*/
private int extrasSize() {
http://git-wip-us.apache.org/repos/asf/ignite/blob/49543e16/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
index fe439fd..97acf19 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
@@ -1300,9 +1300,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
boolean cacheIndexingEnabled = INDEXING.inClassPath() && GridQueryProcessor.isEnabled(cfg);
- IgniteCacheOffheapManager offheapMgr = new IgniteCacheOffheapManager(cfg.getCacheMode() == LOCAL ||
- !GridCacheUtils.isNearEnabled(cfg),
- cacheIndexingEnabled);
+ IgniteCacheOffheapManager offheapMgr = new IgniteCacheOffheapManager(cacheIndexingEnabled);
storeMgr.initialize(cfgStore, sesHolders);
@@ -1431,7 +1429,6 @@ public class GridCacheProcessor extends GridProcessorAdapter {
* ===============================================
*/
swapMgr = new GridCacheSwapManager(true);
- offheapMgr = new IgniteCacheOffheapManager(true, cacheIndexingEnabled);
evictMgr = new GridCacheEvictionManager();
evtMgr = new GridCacheEventManager();
pluginMgr = new CachePluginManager(ctx, cfg);