ignite-51
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/7bbc80a6 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/7bbc80a6 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/7bbc80a6 Branch: refs/heads/sprint-2 Commit: 7bbc80a678b57545027a239bf871143511aa0c1d Parents: d22706b Author: sboikov <semen.boi...@inria.fr> Authored: Mon Mar 9 18:56:47 2015 +0300 Committer: sboikov <semen.boi...@inria.fr> Committed: Mon Mar 9 18:56:47 2015 +0300 ---------------------------------------------------------------------- .../ignite/internal/GridKernalContext.java | 6 +- .../ignite/internal/GridKernalContextImpl.java | 18 +- .../apache/ignite/internal/IgniteKernal.java | 5 +- .../affinity/GridAffinityProcessor.java | 2 +- .../processors/cache/CacheObjectContext.java | 30 ++- .../processors/cache/CacheObjectImpl.java | 2 +- .../processors/cache/GridCacheAdapter.java | 34 +-- .../processors/cache/GridCacheContext.java | 39 +-- .../processors/cache/GridCacheEntryInfo.java | 4 +- .../processors/cache/GridCacheMapEntry.java | 32 +-- .../processors/cache/GridCacheProcessor.java | 8 +- .../cache/GridCacheProjectionImpl.java | 27 +- .../processors/cache/GridCacheStoreManager.java | 4 +- .../processors/cache/GridCacheSwapManager.java | 2 +- .../IgniteCacheOsSerializationManager.java | 43 ---- .../processors/cache/KeyCacheObjectImpl.java | 5 +- .../distributed/GridDistributedLockRequest.java | 4 - .../GridDistributedLockResponse.java | 26 -- .../GridDistributedUnlockRequest.java | 6 - .../distributed/dht/GridDhtLockRequest.java | 5 - .../distributed/dht/GridDhtUnlockRequest.java | 4 - .../local/atomic/GridLocalAtomicCache.java | 2 +- .../cache/query/GridCacheQueryManager.java | 5 +- .../IgniteCacheSerializationManager.java | 45 ---- .../dataload/IgniteDataLoaderImpl.java | 6 +- .../portable/GridPortableProcessor.java | 179 -------------- .../portable/IgniteCacheObjectProcessor.java | 175 +++++++++++++ .../IgniteCacheObjectProcessorAdapter.java | 193 --------------- .../IgniteCacheObjectProcessorImpl.java | 245 +++++++++++++++++++ .../portable/os/GridOsPortableProcessor.java | 92 ------- .../processors/portable/os/package.html | 24 -- .../processors/query/GridQueryProcessor.java | 22 +- .../handlers/task/GridTaskCommandHandler.java | 2 +- .../rest/protocols/tcp/GridTcpRestProtocol.java | 4 +- .../loadtests/hashmap/GridCacheTestContext.java | 1 - 35 files changed, 541 insertions(+), 760 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7bbc80a6/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 59ba1a9..d0bd35d 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 @@ -292,11 +292,11 @@ public interface GridKernalContext extends Iterable<GridComponent> { public ExecutorService utilityCachePool(); /** - * Gets portable processor. + * Gets cache object processor. * - * @return Portable processor. + * @return Cache object processor. */ - public GridPortableProcessor portable(); + public IgniteCacheObjectProcessor cacheObjects(); /** * Gets query processor. http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7bbc80a6/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 2bc44a3..2e0204d 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 @@ -33,7 +33,6 @@ import org.apache.ignite.internal.processors.affinity.*; import org.apache.ignite.internal.processors.cache.*; import org.apache.ignite.internal.processors.cache.dr.*; import org.apache.ignite.internal.processors.cache.dr.os.*; -import org.apache.ignite.internal.processors.cache.serialization.*; import org.apache.ignite.internal.processors.clock.*; import org.apache.ignite.internal.processors.closure.*; import org.apache.ignite.internal.processors.cluster.*; @@ -48,7 +47,6 @@ import org.apache.ignite.internal.processors.offheap.*; import org.apache.ignite.internal.processors.plugin.*; import org.apache.ignite.internal.processors.port.*; import org.apache.ignite.internal.processors.portable.*; -import org.apache.ignite.internal.processors.portable.os.*; import org.apache.ignite.internal.processors.query.*; import org.apache.ignite.internal.processors.resource.*; import org.apache.ignite.internal.processors.rest.*; @@ -238,7 +236,7 @@ public class GridKernalContextImpl implements GridKernalContext, Externalizable /** */ @GridToStringExclude - private GridPortableProcessor portableProc; + private IgniteCacheObjectProcessor cacheObjProc; /** */ @GridToStringExclude @@ -461,8 +459,8 @@ public class GridKernalContextImpl implements GridKernalContext, Externalizable contProc = (GridContinuousProcessor)comp; else if (comp instanceof HadoopProcessorAdapter) hadoopProc = (HadoopProcessorAdapter)comp; - else if (comp instanceof GridPortableProcessor) - portableProc = (GridPortableProcessor)comp; + else if (comp instanceof IgniteCacheObjectProcessor) + cacheObjProc = (IgniteCacheObjectProcessor)comp; else if (comp instanceof IgnitePluginProcessor) pluginProc = (IgnitePluginProcessor)comp; else if (comp instanceof GridQueryProcessor) @@ -693,8 +691,8 @@ public class GridKernalContextImpl implements GridKernalContext, Externalizable } /** {@inheritDoc} */ - @Override public GridPortableProcessor portable() { - return portableProc; + @Override public IgniteCacheObjectProcessor cacheObjects() { + return cacheObjProc; } /** {@inheritDoc} */ @@ -785,10 +783,8 @@ public class GridKernalContextImpl implements GridKernalContext, Externalizable if (cls.equals(GridCacheDrManager.class)) return (T)new GridOsCacheDrManager(); - else if (cls.equals(GridPortableProcessor.class)) - return (T)new GridOsPortableProcessor(this); - else if (cls.equals(IgniteCacheSerializationManager.class)) - return (T)new IgniteCacheOsSerializationManager(); + else if (cls.equals(IgniteCacheObjectProcessor.class)) + return (T)new IgniteCacheObjectProcessorImpl(this); throw new IgniteException("Unsupported component type: " + cls); } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7bbc80a6/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 81bbf89..89911ba 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 @@ -743,7 +743,7 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable { startProcessor(new GridClockSyncProcessor(ctx)); startProcessor(new GridAffinityProcessor(ctx)); startProcessor(createComponent(GridSegmentationProcessor.class, ctx)); - startProcessor(createComponent(GridPortableProcessor.class, ctx)); + startProcessor(createComponent(IgniteCacheObjectProcessor.class, ctx)); startProcessor(new GridQueryProcessor(ctx)); startProcessor(new GridCacheProcessor(ctx)); startProcessor(new GridTaskSessionProcessor(ctx)); @@ -2606,6 +2606,9 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable { if (comp != null) return comp; + if (cls.equals(IgniteCacheObjectProcessor.class)) + return (T)new IgniteCacheObjectProcessorImpl(ctx); + Class<T> implCls = null; try { http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7bbc80a6/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityProcessor.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityProcessor.java index 7458078..d09438c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityProcessor.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityProcessor.java @@ -422,7 +422,7 @@ public class GridAffinityProcessor extends GridProcessorAdapter { f.reset(); m.reset(); - return new AffinityInfo(f, m, t.get3(), ctx.portable().contextForCache(n, cacheName)); + return new AffinityInfo(f, m, t.get3(), ctx.cacheObjects().contextForCache(n, cacheName)); } /** http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7bbc80a6/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectContext.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectContext.java index a61be98..6c5bfc2 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectContext.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectContext.java @@ -21,6 +21,8 @@ import org.apache.ignite.cache.affinity.*; import org.apache.ignite.internal.*; import org.apache.ignite.internal.processors.portable.*; +import java.util.*; + /** * */ @@ -29,7 +31,7 @@ public class CacheObjectContext { private GridKernalContext kernalCtx; /** */ - private GridPortableProcessor proc; + private IgniteCacheObjectProcessor proc; /** */ private CacheAffinityKeyMapper dfltAffMapper; @@ -55,7 +57,7 @@ public class CacheObjectContext { this.cpyOnGet = cpyOnGet; this.unmarshalVals = unmarshalVals; - proc = kernalCtx.portable(); + proc = kernalCtx.cacheObjects(); } /** @@ -89,7 +91,29 @@ public class CacheObjectContext { /** * @return Processor. */ - public GridPortableProcessor processor() { + public IgniteCacheObjectProcessor processor() { return proc; } + + /** + * Unwraps object. + * + * @param o Object to unwrap. + * @param keepPortable Keep portable flag. + * @return Unwrapped object. + */ + public Object unwrapPortableIfNeeded(Object o, boolean keepPortable) { + return o; + } + + /** + * Unwraps collection. + * + * @param col Collection to unwrap. + * @param keepPortable Keep portable flag. + * @return Unwrapped collection. + */ + public Collection<Object> unwrapPortablesIfNeeded(Collection<Object> col, boolean keepPortable) { + return col; + } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7bbc80a6/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectImpl.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectImpl.java index e462acc..005974d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectImpl.java @@ -99,7 +99,7 @@ public class CacheObjectImpl extends CacheObjectAdapter { assert val != null || valBytes != null; if (valBytes == null && !byteArray()) - valBytes = ctx.kernalContext().portable().marshal(ctx, val); + valBytes = ctx.kernalContext().cacheObjects().marshal(ctx, val); } /** {@inheritDoc} */ http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7bbc80a6/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 6acf2e1..e2ac897 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 @@ -431,7 +431,7 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K, V>, null, null, null, - ctx.portableEnabled(), + true, null ); } @@ -449,7 +449,7 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K, V>, null, null, null, - ctx.portableEnabled(), + false, plc); } @@ -828,8 +828,7 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K, V>, Object val = CU.value(cacheVal, ctx, true); - if (ctx.portableEnabled()) - val = ctx.unwrapPortableIfNeeded(val, ctx.keepPortable()); + val = ctx.unwrapPortableIfNeeded(val, ctx.keepPortable()); return (V)val; } @@ -920,8 +919,7 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K, V>, Object val0 = CU.value(v, ctx, true); - if (ctx.portableEnabled()) - val0 = ctx.unwrapPortableIfNeeded(v, ctx.keepPortable()); + val0 = ctx.unwrapPortableIfNeeded(val0, ctx.keepPortable()); return F.t((V)val0); } @@ -935,10 +933,9 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K, V>, if (peek != null) { CacheObject v = peek.get(); - Object val0 = v.value(ctx.cacheObjectContext(), true); + Object val0 = CU.value(v, ctx, true); - if (ctx.portableEnabled()) - val0 = ctx.unwrapPortableIfNeeded(v, ctx.keepPortable()); + val0 = ctx.unwrapPortableIfNeeded(val0, ctx.keepPortable()); return F.t((V) val0); } @@ -1126,7 +1123,6 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K, V>, * @param key Entry key. * @return Entry or <tt>null</tt>. */ - // TODO IGNITE-51 (added for tests). @Nullable public GridCacheEntryEx peekEx(Object key) { return entry0(ctx.toCacheKeyObject(key), ctx.affinity().affinityTopologyVersion(), false, false); } @@ -1135,7 +1131,6 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K, V>, * @param key Entry key. * @return Entry (never {@code null}). */ - // TODO IGNITE-51 (added for tests). public GridCacheEntryEx entryEx(Object key) { return entryEx(ctx.toCacheKeyObject(key), false); } @@ -4400,10 +4395,7 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K, V>, Object val0 = val != null ? val.value(ctx.cacheObjectContext(), true) : null; - if (ctx.portableEnabled()) - return (V)ctx.unwrapPortableIfNeeded(val0, !deserializePortable); - else - return (V)ctx.cloneOnFlag(val0); + return (V)ctx.unwrapPortableIfNeeded(val0, !deserializePortable); } /** {@inheritDoc} */ @@ -5138,10 +5130,7 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K, V>, assert map.isEmpty() || map.size() == 1 : map.size(); - if (ctx.portableEnabled()) - return map.isEmpty() ? null : map.values().iterator().next(); - else - return map.get(key); + return map.get(key); } /** @@ -5166,10 +5155,7 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K, V>, assert map.isEmpty() || map.size() == 1 : map.size(); - if (ctx.portableEnabled()) - return map.isEmpty() ? null : map.values().iterator().next(); - else - return map.get(key); + return map.get(key); } }); } @@ -5440,7 +5426,7 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K, V>, Object key0 = key.value(ctx.cacheObjectContext(), true); Object val0 = val.value(ctx.cacheObjectContext(), true); - if (deserializePortable && ctx.portableEnabled()) { + if (deserializePortable) { key0 = ctx.unwrapPortableIfNeeded(key0, true); val0 = ctx.unwrapPortableIfNeeded(val0, true); } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7bbc80a6/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 21cfd55..8894325 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 @@ -37,7 +37,6 @@ import org.apache.ignite.internal.processors.cache.jta.*; import org.apache.ignite.internal.processors.cache.local.*; import org.apache.ignite.internal.processors.cache.query.*; import org.apache.ignite.internal.processors.cache.query.continuous.*; -import org.apache.ignite.internal.processors.cache.serialization.*; import org.apache.ignite.internal.processors.cache.transactions.*; import org.apache.ignite.internal.processors.cache.version.*; import org.apache.ignite.internal.processors.closure.*; @@ -132,9 +131,6 @@ public class GridCacheContext<K, V> implements Externalizable { /** Replication manager. */ private GridCacheDrManager drMgr; - /** Serialization manager. */ - private IgniteCacheSerializationManager<K, V> serMgr; - /** JTA manager. */ private CacheJtaManagerAdapter jtaMgr; @@ -231,7 +227,6 @@ public class GridCacheContext<K, V> implements Externalizable { GridCacheEventManager evtMgr, GridCacheSwapManager swapMgr, - IgniteCacheSerializationManager<K, V> serMgr, GridCacheStoreManager storeMgr, GridCacheEvictionManager<K, V> evictMgr, GridCacheQueryManager<K, V> qryMgr, @@ -265,7 +260,6 @@ public class GridCacheContext<K, V> implements Externalizable { */ this.evtMgr = add(evtMgr); this.swapMgr = add(swapMgr); - this.serMgr = add(serMgr); this.storeMgr = add(storeMgr); this.evictMgr = add(evictMgr); this.qryMgr = add(qryMgr); @@ -1691,15 +1685,8 @@ public class GridCacheContext<K, V> implements Externalizable { /** * @return Portable processor. */ - public GridPortableProcessor portable() { - return kernalContext().portable(); - } - - /** - * @return Portable enabled flag. - */ - public boolean portableEnabled() { - return serMgr.portableEnabled(); + public IgniteCacheObjectProcessor cacheObjects() { + return kernalContext().cacheObjects(); } /** @@ -1728,7 +1715,7 @@ public class GridCacheContext<K, V> implements Externalizable { if (!offheapTiered()) return (T)obj; - return (T)portable().unwrapTemporary(this, obj); + return (T) cacheObjects().unwrapTemporary(this, obj); } /** @@ -1739,7 +1726,7 @@ public class GridCacheContext<K, V> implements Externalizable { * @return Unwrapped collection. */ public Collection<Object> unwrapPortablesIfNeeded(Collection<Object> col, boolean keepPortable) { - return serMgr.unwrapPortablesIfNeeded(col, keepPortable); + return cacheObjCtx.unwrapPortablesIfNeeded(col, keepPortable); } /** @@ -1751,7 +1738,7 @@ public class GridCacheContext<K, V> implements Externalizable { */ @SuppressWarnings("IfMayBeConditional") public Object unwrapPortableIfNeeded(Object o, boolean keepPortable) { - return serMgr.unwrapPortableIfNeeded(o, keepPortable); + return cacheObjCtx.unwrapPortableIfNeeded(o, keepPortable); } /** @@ -1766,7 +1753,7 @@ public class GridCacheContext<K, V> implements Externalizable { * @return Cache object. */ @Nullable public CacheObject toCacheObject(@Nullable Object obj) { - return portable().toCacheObject(cacheObjCtx, obj); + return cacheObjects().toCacheObject(cacheObjCtx, obj); } /** @@ -1774,7 +1761,7 @@ public class GridCacheContext<K, V> implements Externalizable { * @return Cache key object. */ public KeyCacheObject toCacheKeyObject(Object obj) { - return portable().toCacheKeyObject(cacheObjCtx, obj); + return cacheObjects().toCacheKeyObject(cacheObjCtx, obj); } /** @@ -1782,9 +1769,9 @@ public class GridCacheContext<K, V> implements Externalizable { * @return Cache key object. */ public KeyCacheObject toCacheKeyObject(byte[] bytes) throws IgniteCheckedException { - Object obj = ctx.portable().unmarshal(cacheObjCtx, bytes, deploy().localLoader()); + Object obj = ctx.cacheObjects().unmarshal(cacheObjCtx, bytes, deploy().localLoader()); - return portable().toCacheKeyObject(cacheObjCtx, obj); + return cacheObjects().toCacheKeyObject(cacheObjCtx, obj); } /** @@ -1803,10 +1790,10 @@ public class GridCacheContext<K, V> implements Externalizable { if (ldr == null) return null; - return ctx.portable().toCacheObject(cacheObjCtx, ctx.portable().unmarshal(cacheObjCtx, bytes, ldr)); + return ctx.cacheObjects().toCacheObject(cacheObjCtx, ctx.cacheObjects().unmarshal(cacheObjCtx, bytes, ldr)); } - return ctx.portable().toCacheObject(cacheObjCtx, type, bytes); + return ctx.cacheObjects().toCacheObject(cacheObjCtx, type, bytes); } /** @@ -1819,7 +1806,7 @@ public class GridCacheContext<K, V> implements Externalizable { assert config().getMemoryMode() == OFFHEAP_TIERED || config().getMemoryMode() == OFFHEAP_VALUES; assert valPtr != 0; - return ctx.portable().toCacheObject(this, valPtr, tmp); + return ctx.cacheObjects().toCacheObject(this, valPtr, tmp); } /** @@ -1846,7 +1833,7 @@ public class GridCacheContext<K, V> implements Externalizable { Object key0 = key.value(cacheObjCtx, false); Object val0 = skipVals ? true : val.value(cacheObjCtx, cpy); - if (portableEnabled() && deserializePortable) { + if (deserializePortable) { key0 = unwrapPortableIfNeeded(key0, false); if (!skipVals) http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7bbc80a6/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryInfo.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryInfo.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryInfo.java index 8f47e0f..426465b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryInfo.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryInfo.java @@ -398,9 +398,9 @@ public class GridCacheEntryInfo implements Message { CacheObjectContext cacheObjCtx = ctx.cacheObjectContext(); - Object key0 = ctx.portable().unmarshal(cacheObjCtx, keyBytes, clsLdr); + Object key0 = ctx.cacheObjects().unmarshal(cacheObjCtx, keyBytes, clsLdr); - key = ctx.portable().toCacheKeyObject(cacheObjCtx, key0); + key = ctx.cacheObjects().toCacheKeyObject(cacheObjCtx, key0); } else key.finishUnmarshal(ctx.cacheObjectContext(), clsLdr); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7bbc80a6/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 8ef0f99..4762c03 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 @@ -153,7 +153,7 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx { { log = U.logger(cctx.kernalContext(), logRef, GridCacheMapEntry.class); - key = (KeyCacheObject)cctx.kernalContext().portable().prepareForCache(key, cctx); + key = (KeyCacheObject)cctx.kernalContext().cacheObjects().prepareForCache(key, cctx); assert key != null; @@ -163,7 +163,7 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx { ttlAndExpireTimeExtras(ttl, CU.toExpireTime(ttl)); - val = cctx.kernalContext().portable().prepareForCache(val, cctx); + val = cctx.kernalContext().cacheObjects().prepareForCache(val, cctx); synchronized (this) { value(val); @@ -212,7 +212,7 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx { Object val0 = null; if (val != null && val.type() != CacheObjectAdapter.TYPE_BYTE_ARR) { - val0 = cctx.portable().unmarshal(cctx.cacheObjectContext(), + val0 = cctx.cacheObjects().unmarshal(cctx.cacheObjectContext(), val.valueBytes(cctx.cacheObjectContext()), cctx.deploy().globalLoader()); if (val0 != null) @@ -278,7 +278,7 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx { if (val0 == null && valPtr != 0) { IgniteBiTuple<byte[], Byte> t = valueBytes0(); - return cctx.portable().toCacheObject(cctx.cacheObjectContext(), t.get2(), t.get1()); + return cctx.cacheObjects().toCacheObject(cctx.cacheObjectContext(), t.get2(), t.get1()); } return val0; @@ -467,7 +467,7 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx { if (delta >= 0) { CacheObject val = e.value(); - val = cctx.kernalContext().portable().prepareForCache(val, cctx); + val = cctx.kernalContext().cacheObjects().prepareForCache(val, cctx); // Set unswapped value. update(val, e.expireTime(), e.ttl(), e.version()); @@ -812,7 +812,7 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx { if (startVer.equals(ver)) { if (ret != null) { // Detach value before index update. - ret = cctx.kernalContext().portable().prepareForCache(ret, cctx); + ret = cctx.kernalContext().cacheObjects().prepareForCache(ret, cctx); GridCacheVersion nextVer = nextVersion(); @@ -895,7 +895,7 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx { long expTime = CU.toExpireTime(ttl); // Detach value before index update. - ret = cctx.kernalContext().portable().prepareForCache(ret, cctx); + ret = cctx.kernalContext().cacheObjects().prepareForCache(ret, cctx); // Update indexes. if (ret != null) { @@ -1034,7 +1034,7 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx { assert expireTime >= 0 : expireTime; // Detach value before index update. - val = cctx.kernalContext().portable().prepareForCache(val, cctx); + val = cctx.kernalContext().cacheObjects().prepareForCache(val, cctx); // Update index inside synchronization since it can be updated // in load methods without actually holding entry lock. @@ -1352,7 +1352,7 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx { } // Detach value before index update. - old = cctx.kernalContext().portable().prepareForCache(old, cctx); + old = cctx.kernalContext().cacheObjects().prepareForCache(old, cctx); if (old != null) updateIndex(old, expireTime, ver, null); @@ -1490,7 +1490,7 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx { // Try write-through. if (op == GridCacheOperation.UPDATE) { // Detach value before index update. - updated = cctx.kernalContext().portable().prepareForCache(updated, cctx); + updated = cctx.kernalContext().cacheObjects().prepareForCache(updated, cctx); if (writeThrough) // Must persist inside synchronization in non-tx mode. @@ -1791,7 +1791,7 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx { readThrough = true; // Detach value before index update. - oldVal = cctx.kernalContext().portable().prepareForCache(oldVal, cctx); + oldVal = cctx.kernalContext().cacheObjects().prepareForCache(oldVal, cctx); // Calculate initial TTL and expire time. long initTtl; @@ -2020,7 +2020,7 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx { // Do not change size. } - updated = cctx.kernalContext().portable().prepareForCache(updated, cctx); + updated = cctx.kernalContext().cacheObjects().prepareForCache(updated, cctx); // Update index inside synchronization since it can be updated // in load methods without actually holding entry lock. @@ -2928,7 +2928,7 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx { // in load methods without actually holding entry lock. long expireTime = expireTimeExtras(); - val = cctx.kernalContext().portable().prepareForCache(val, cctx); + val = cctx.kernalContext().cacheObjects().prepareForCache(val, cctx); updateIndex(val, expireTime, nextVer, old); @@ -3203,7 +3203,7 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx { if (isNew() || (!preload && deletedUnlocked())) { long expTime = expireTime < 0 ? CU.toExpireTime(ttl) : expireTime; - val = cctx.kernalContext().portable().prepareForCache(val, cctx); + val = cctx.kernalContext().cacheObjects().prepareForCache(val, cctx); if (val != null) updateIndex(val, expTime, ver, null); @@ -3255,7 +3255,7 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx { if (isNew()) { CacheObject val = unswapped.value(); - val = cctx.kernalContext().portable().prepareForCache(val, cctx); + val = cctx.kernalContext().cacheObjects().prepareForCache(val, cctx); // Version does not change for load ops. update(val, @@ -3304,7 +3304,7 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx { long expTime = CU.toExpireTime(ttl); // Detach value before index update. - val = cctx.kernalContext().portable().prepareForCache(val, cctx); + val = cctx.kernalContext().cacheObjects().prepareForCache(val, cctx); if (val != null) { updateIndex(val, expTime, newVer, old); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7bbc80a6/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 c98b9a1..61d929c 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 @@ -38,7 +38,6 @@ import org.apache.ignite.internal.processors.cache.local.*; import org.apache.ignite.internal.processors.cache.local.atomic.*; import org.apache.ignite.internal.processors.cache.query.*; import org.apache.ignite.internal.processors.cache.query.continuous.*; -import org.apache.ignite.internal.processors.cache.serialization.*; import org.apache.ignite.internal.processors.cache.transactions.*; import org.apache.ignite.internal.processors.cache.version.*; import org.apache.ignite.internal.util.*; @@ -580,7 +579,7 @@ public class GridCacheProcessor extends GridProcessorAdapter { for (int i = 0; i < cfgs.length; i++) { CacheConfiguration<?, ?> cfg = new CacheConfiguration(cfgs[i]); - CacheObjectContext cacheObjCtx = ctx.portable().contextForCache(null, cfg.getName()); + CacheObjectContext cacheObjCtx = ctx.cacheObjects().contextForCache(null, cfg.getName()); // Initialize defaults. initialize(cfg, cacheObjCtx); @@ -626,7 +625,6 @@ public class GridCacheProcessor extends GridProcessorAdapter { CacheDataStructuresManager dataStructuresMgr = new CacheDataStructuresManager(); GridCacheTtlManager ttlMgr = new GridCacheTtlManager(); GridCacheDrManager drMgr = ctx.createComponent(GridCacheDrManager.class); - IgniteCacheSerializationManager serMgr = ctx.createComponent(IgniteCacheSerializationManager.class); GridCacheStoreManager storeMgr = new GridCacheStoreManager(ctx, sesHolders, cfgStore, cfg); @@ -641,7 +639,6 @@ public class GridCacheProcessor extends GridProcessorAdapter { */ evtMgr, swapMgr, - serMgr, storeMgr, evictMgr, qryMgr, @@ -781,7 +778,6 @@ public class GridCacheProcessor extends GridProcessorAdapter { */ evtMgr, swapMgr, - serMgr, storeMgr, evictMgr, qryMgr, @@ -1324,7 +1320,7 @@ public class GridCacheProcessor extends GridProcessorAdapter { } } - ctx.portable().onCacheProcessorStarted(); + ctx.cacheObjects().onCacheProcessorStarted(); } /** {@inheritDoc} */ http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7bbc80a6/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProjectionImpl.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProjectionImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProjectionImpl.java index 8afe378..86ac962 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProjectionImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProjectionImpl.java @@ -386,23 +386,16 @@ public class GridCacheProjectionImpl<K, V> implements GridCacheProjectionEx<K, V /** {@inheritDoc} */ @Override public <K1, V1> CacheProjection<K1, V1> keepPortable() { - if (cctx.portableEnabled()) { - GridCacheProjectionImpl<K1, V1> prj = new GridCacheProjectionImpl<>( - (CacheProjection<K1, V1>)this, - (GridCacheContext<K1, V1>)cctx, - filter, - flags, - subjId, - true, - expiryPlc); - - return new GridCacheProxyImpl<>((GridCacheContext<K1, V1>)cctx, prj, prj); - } - else - return new GridCacheProxyImpl<>( - (GridCacheContext<K1, V1>)cctx, - (GridCacheProjectionEx<K1, V1>)this, - (GridCacheProjectionImpl<K1, V1>)this); + GridCacheProjectionImpl<K1, V1> prj = new GridCacheProjectionImpl<>( + (CacheProjection<K1, V1>)this, + (GridCacheContext<K1, V1>)cctx, + filter, + flags, + subjId, + true, + expiryPlc); + + return new GridCacheProxyImpl<>((GridCacheContext<K1, V1>)cctx, prj, prj); } /** {@inheritDoc} */ http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7bbc80a6/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheStoreManager.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheStoreManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheStoreManager.java index 4bc5658..57555cf 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheStoreManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheStoreManager.java @@ -180,7 +180,7 @@ public class GridCacheStoreManager extends GridCacheManagerAdapter { } } - convertPortable = !cctx.portable().keepPortableInStore(cctx.name()); + convertPortable = !cctx.cacheObjects().keepPortableInStore(cctx.name()); } /** {@inheritDoc} */ @@ -796,7 +796,7 @@ public class GridCacheStoreManager extends GridCacheManagerAdapter { private void handleClassCastException(ClassCastException e) throws IgniteCheckedException { assert e != null; - if (cctx.portableEnabled() && e.getMessage() != null) { + if (e.getMessage() != null) { throw new IgniteCheckedException("Cache store must work with portable objects if portables are " + "enabled for cache [cacheName=" + cctx.namex() + ']', e); } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7bbc80a6/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 d52c6ad..b572ad9 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 @@ -1733,7 +1733,7 @@ public class GridCacheSwapManager extends GridCacheManagerAdapter { swapEntry.value() == null && swapEntry.type() != CacheObjectAdapter.TYPE_BYTE_ARR) { // We need value here only for classloading purposes. - Object val = cctx.portable().unmarshal(cctx.cacheObjectContext(), + Object val = cctx.cacheObjects().unmarshal(cctx.cacheObjectContext(), swapEntry.valueBytes(), cctx.deploy().globalLoader()); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7bbc80a6/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOsSerializationManager.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOsSerializationManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOsSerializationManager.java deleted file mode 100644 index 80d87a8..0000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOsSerializationManager.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.internal.processors.cache; - -import org.apache.ignite.internal.processors.cache.serialization.*; - -import java.util.*; - -/** - * Cache manager responsible for translating user objects into cache objects. - */ -public class IgniteCacheOsSerializationManager<K, V> extends GridCacheManagerAdapter<K, V> - implements IgniteCacheSerializationManager<K, V> { - /** {@inheritDoc} */ - @Override public boolean portableEnabled() { - return false; - } - - /** {@inheritDoc} */ - @Override public Object unwrapPortableIfNeeded(Object o, boolean keepPortable) { - return o; - } - - /** {@inheritDoc} */ - @Override public Collection<Object> unwrapPortablesIfNeeded(Collection<Object> col, boolean keepPortable) { - return col; - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7bbc80a6/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/KeyCacheObjectImpl.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/KeyCacheObjectImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/KeyCacheObjectImpl.java index 469237d..1cf6d00 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/KeyCacheObjectImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/KeyCacheObjectImpl.java @@ -18,7 +18,6 @@ package org.apache.ignite.internal.processors.cache; import org.apache.ignite.*; -import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.plugin.extensions.communication.*; import org.jetbrains.annotations.*; @@ -166,7 +165,7 @@ public class KeyCacheObjectImpl extends CacheObjectAdapter implements KeyCacheOb /** {@inheritDoc} */ @Override public void prepareMarshal(CacheObjectContext ctx) throws IgniteCheckedException { if (valBytes == null) - valBytes = ctx.kernalContext().portable().marshal(ctx, val); + valBytes = ctx.kernalContext().cacheObjects().marshal(ctx, val); } /** {@inheritDoc} */ @@ -174,7 +173,7 @@ public class KeyCacheObjectImpl extends CacheObjectAdapter implements KeyCacheOb if (val == null) { assert valBytes != null; - val = ctx.kernalContext().portable().unmarshal(ctx, valBytes, ldr); + val = ctx.kernalContext().cacheObjects().unmarshal(ctx, valBytes, ldr); } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7bbc80a6/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockRequest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockRequest.java index c5baf72..37b34e7 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockRequest.java @@ -246,10 +246,6 @@ public class GridDistributedLockRequest extends GridDistributedBaseMessage { @Nullable Collection<GridCacheMvccCandidate> cands, GridCacheContext ctx ) throws IgniteCheckedException { -// TODO IGNITE-51. -// if (ctx.deploymentEnabled()) -// prepareObject(key, ctx.shared()); - if (keys == null) keys = new ArrayList<>(keysCount()); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7bbc80a6/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java index 679b179..b5e8d61 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockResponse.java @@ -181,22 +181,6 @@ public class GridDistributedLockResponse extends GridDistributedBaseMessage { */ public void addValue(CacheObject val) { vals.add(val); -// TODO IGNITE-51. -// if (ctx.deploymentEnabled()) -// prepareObject(val, ctx.shared()); -// -// GridCacheValueBytes vb = null; -// -// if (val != null) { -// vb = val instanceof byte[] ? GridCacheValueBytes.plain(val) : valBytes != null ? -// GridCacheValueBytes.marshaled(valBytes) : null; -// } -// else if (valBytes != null) -// vb = GridCacheValueBytes.marshaled(valBytes); -// -// this.valBytes.add(vb); -// -// vals.add(val); } /** @@ -214,16 +198,6 @@ public class GridDistributedLockResponse extends GridDistributedBaseMessage { if (!F.isEmpty(vals)) return vals.get(idx); - // If there was no value in values collection, then it could be in value bytes collection in case of byte[]. -// TODO IGNITE-51. -// if (!F.isEmpty(valBytes)) { -// GridCacheValueBytes res = valBytes.get(idx); -// -// if (res != null && res.isPlain()) -// return (V)res.get(); -// } - - // Value is not found in both value and value bytes collections. return null; } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7bbc80a6/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedUnlockRequest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedUnlockRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedUnlockRequest.java index 7601f35..c0f2472 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedUnlockRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedUnlockRequest.java @@ -70,12 +70,6 @@ public class GridDistributedUnlockRequest extends GridDistributedBaseMessage { * @throws IgniteCheckedException If failed. */ public void addKey(KeyCacheObject key, GridCacheContext ctx) throws IgniteCheckedException { -// TODO IGNITE-51. -// boolean depEnabled = ctx.deploymentEnabled(); -// -// if (depEnabled) -// prepareObject(key.value(ctx, false), ctx.shared()); - if (keys == null) keys = new ArrayList<>(keysCount()); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7bbc80a6/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java index 87c786d..834cc18 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockRequest.java @@ -201,10 +201,6 @@ public class GridDhtLockRequest extends GridDistributedLockRequest { */ public void addNearKey(KeyCacheObject key, GridCacheSharedContext ctx) throws IgniteCheckedException { -// TODO IGNITE-51. -// if (ctx.deploymentEnabled()) -// prepareObject(key, ctx); - nearKeys.add(key); } @@ -257,7 +253,6 @@ public class GridDhtLockRequest extends GridDistributedLockRequest { * Sets owner and its mapped version. * * @param key Key. - * @param keyBytes Key bytes. * @param ownerMapped Owner mapped version. */ public void owned(KeyCacheObject key, GridCacheVersion ownerMapped) { http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7bbc80a6/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtUnlockRequest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtUnlockRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtUnlockRequest.java index c7bc2ff..a305dc4 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtUnlockRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtUnlockRequest.java @@ -70,10 +70,6 @@ public class GridDhtUnlockRequest extends GridDistributedUnlockRequest { */ public void addNearKey(KeyCacheObject key, GridCacheSharedContext ctx) throws IgniteCheckedException { -// TODO IGNITE-51. -// if (ctx.deploymentEnabled()) -// prepareObject(key, ctx); - if (nearKeys == null) nearKeys = new ArrayList<>(); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7bbc80a6/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java index 792504d..11571d0 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java @@ -499,7 +499,7 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> { assert m.isEmpty() || m.size() == 1 : m.size(); - return m.isEmpty() ? null : m.values().iterator().next(); + return m.get(key); } /** {@inheritDoc} */ http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7bbc80a6/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java index 9f79452..7a0c52d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java @@ -32,7 +32,6 @@ import org.apache.ignite.internal.processors.query.*; import org.apache.ignite.internal.processors.task.*; import org.apache.ignite.internal.util.*; import org.apache.ignite.internal.util.future.*; -import org.apache.ignite.internal.util.io.*; import org.apache.ignite.internal.util.lang.*; import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.internal.util.typedef.internal.*; @@ -909,7 +908,7 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte IgniteBiPredicate<K, V> filter = qry.scanFilter(); - if ((cctx.portableEnabled() && cctx.offheapTiered()) && (prjPred != null || filter != null)) { + if (cctx.offheapTiered() && (prjPred != null || filter != null)) { OffheapIteratorClosure c = new OffheapIteratorClosure(prjPred, filter, qry.keepPortable()); return cctx.swap().rawOffHeapIterator(c); @@ -2400,7 +2399,7 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte @Override protected V unmarshalValue() throws IgniteCheckedException { IgniteBiTuple<byte[], Byte> t = GridCacheSwapEntryImpl.getValue(e.getValue()); - CacheObject obj = cctx.portable().toCacheObject(cctx.cacheObjectContext(), t.get2(), t.get1()); + CacheObject obj = cctx.cacheObjects().toCacheObject(cctx.cacheObjectContext(), t.get2(), t.get1()); return obj.value(cctx.cacheObjectContext(), false); } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7bbc80a6/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/serialization/IgniteCacheSerializationManager.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/serialization/IgniteCacheSerializationManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/serialization/IgniteCacheSerializationManager.java deleted file mode 100644 index 0f6ce2b..0000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/serialization/IgniteCacheSerializationManager.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.internal.processors.cache.serialization; - -import org.apache.ignite.internal.processors.cache.*; - -import java.util.*; - -/** - * - */ -public interface IgniteCacheSerializationManager<K, V> extends GridCacheManager<K, V> { - /** - * TODO this method should be removed from Ignite internals as a part of work on cache objects. - * - * @return Portable enabled flag for cache. - */ - public boolean portableEnabled(); - - public Object unwrapPortableIfNeeded(Object o, boolean keepPortable); - - /** - * Unwraps collection. - * - * @param col Collection to unwrap. - * @param keepPortable Keep portable flag. - * @return Unwrapped collection. - */ - public Collection<Object> unwrapPortablesIfNeeded(Collection<Object> col, boolean keepPortable); -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7bbc80a6/modules/core/src/main/java/org/apache/ignite/internal/processors/dataload/IgniteDataLoaderImpl.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/dataload/IgniteDataLoaderImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/dataload/IgniteDataLoaderImpl.java index 53b2c3a..0678d1f 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/dataload/IgniteDataLoaderImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/dataload/IgniteDataLoaderImpl.java @@ -98,7 +98,7 @@ public class IgniteDataLoaderImpl<K, V> implements IgniteDataLoader<K, V>, Delay private final GridKernalContext ctx; /** */ - private final GridPortableProcessor cacheObjProc; + private final IgniteCacheObjectProcessor cacheObjProc; /** */ private final CacheObjectContext cacheObjCtx; @@ -169,14 +169,14 @@ public class IgniteDataLoaderImpl<K, V> implements IgniteDataLoader<K, V>, Delay assert ctx != null; this.ctx = ctx; - this.cacheObjProc = ctx.portable(); + this.cacheObjProc = ctx.cacheObjects(); ClusterNode node = F.first(ctx.grid().cluster().forCacheNodes(cacheName).nodes()); if (node == null) throw new IllegalStateException("Cache doesn't exist: " + cacheName); - this.cacheObjCtx = ctx.portable().contextForCache(node, cacheName); + this.cacheObjCtx = ctx.cacheObjects().contextForCache(node, cacheName); this.cacheName = cacheName; this.flushQ = flushQ; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7bbc80a6/modules/core/src/main/java/org/apache/ignite/internal/processors/portable/GridPortableProcessor.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/portable/GridPortableProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/portable/GridPortableProcessor.java deleted file mode 100644 index b33051e..0000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/portable/GridPortableProcessor.java +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.internal.processors.portable; - -import org.apache.ignite.*; -import org.apache.ignite.cache.*; -import org.apache.ignite.cluster.*; -import org.apache.ignite.internal.client.marshaller.*; -import org.apache.ignite.internal.processors.*; -import org.apache.ignite.internal.processors.cache.*; -import org.jetbrains.annotations.*; - -import java.nio.*; - -/** - * Portable processor. - * - * TODO IGNITE-51: rename. - */ -public interface GridPortableProcessor extends GridProcessor { - /** {@inheritDoc} */ - public void onCacheProcessorStarted(); - - /** - * @param typeName Type name. - * @return Type ID. - */ - public int typeId(String typeName); - - /** - * @param obj Object to get type ID for. - * @return Type ID. - */ - public int typeId(Object obj); - - /** - * Converts temporary offheap object to heap-based. - * - * @param ctx Context. - * @param obj Object. - * @return Heap-based object. - * @throws IgniteException In case of error. - */ - @Nullable public Object unwrapTemporary(GridCacheContext ctx, @Nullable Object obj) throws IgniteException; - - /** - * @param obj Object to marshal. - * @return Portable object. - * @throws IgniteException In case of error. - */ - public Object marshalToPortable(@Nullable Object obj) throws IgniteException; - - /** - * Prepares cache object for cache (e.g. copies user-provided object if needed). - * - * @param obj Cache object. - * @param cctx Cache context. - * @return Object to be store in cache. - */ - @Nullable public CacheObject prepareForCache(@Nullable CacheObject obj, GridCacheContext cctx); - - /** - * @return Portable marshaller for client connectivity or {@code null} if it's not - * supported (in case of OS edition). - */ - @Nullable public GridClientMarshaller portableMarshaller(); - - /** - * @param marsh Client marshaller. - * @return Whether marshaller is portable. - */ - public boolean isPortable(GridClientMarshaller marsh); - - /** - * Checks whether object is portable object. - * - * @param obj Object to check. - * @return {@code True} if object is already a portable object, {@code false} otherwise. - */ - public boolean isPortableObject(Object obj); - - /** - * @param obj Portable object to get field from. - * @param fieldName Field name. - * @return Field value. - */ - public Object field(Object obj, String fieldName); - - /** - * Checks whether field is set in the object. - * - * @param obj Object. - * @param fieldName Field name. - * @return {@code true} if field is set. - */ - public boolean hasField(Object obj, String fieldName); - - /** - * @param ctx Cache object context. - * @param val Value. - * @return Value bytes. - * @throws IgniteCheckedException If failed. - */ - public byte[] marshal(CacheObjectContext ctx, Object val) throws IgniteCheckedException; - - /** - * @param ctx Context. - * @param bytes Bytes. - * @param clsLdr Class loader. - * @return Unmarshalled object. - * @throws IgniteCheckedException If failed. - */ - public Object unmarshal(CacheObjectContext ctx, byte[] bytes, ClassLoader clsLdr) throws IgniteCheckedException; - - /** - * @param node Node. - * @param cacheName Cache name. - * @return Cache object context. - */ - public CacheObjectContext contextForCache(ClusterNode node, @Nullable String cacheName); - - /** - * @param ctx Cache context. - * @param obj Object. - * @return Cache object. - */ - @Nullable public CacheObject toCacheObject(CacheObjectContext ctx, @Nullable Object obj); - - /** - * @param ctx Cache context. - * @param type Object type. - * @param bytes Object bytes. - * @return Cache object. - */ - public CacheObject toCacheObject(CacheObjectContext ctx, byte type, byte[] bytes); - - /** - * @param ctx Context. - * @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 toCacheObject(GridCacheContext ctx, long valPtr, boolean tmp) throws IgniteCheckedException; - - /** - * @param ctx Cache context. - * @param obj Key value. - * @return Cache key object. - */ - public KeyCacheObject toCacheKeyObject(CacheObjectContext ctx, Object obj); - - /** - * @param obj Value. - * @return {@code True} if object is of known immutable type of it is marked - * with {@link IgniteImmutable} annotation. - */ - public boolean immutable(Object obj); - - /** - * @return {@code True} if portable format should be preserved when passing values to cache store. - */ - public boolean keepPortableInStore(@Nullable String cacheName); -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7bbc80a6/modules/core/src/main/java/org/apache/ignite/internal/processors/portable/IgniteCacheObjectProcessor.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/portable/IgniteCacheObjectProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/portable/IgniteCacheObjectProcessor.java new file mode 100644 index 0000000..aaf615c --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/portable/IgniteCacheObjectProcessor.java @@ -0,0 +1,175 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.portable; + +import org.apache.ignite.*; +import org.apache.ignite.cache.*; +import org.apache.ignite.cluster.*; +import org.apache.ignite.internal.client.marshaller.*; +import org.apache.ignite.internal.processors.*; +import org.apache.ignite.internal.processors.cache.*; +import org.jetbrains.annotations.*; + +/** + * Cache objects processor. + */ +public interface IgniteCacheObjectProcessor extends GridProcessor { + /** {@inheritDoc} */ + public void onCacheProcessorStarted(); + + /** + * @param typeName Type name. + * @return Type ID. + */ + public int typeId(String typeName); + + /** + * @param obj Object to get type ID for. + * @return Type ID. + */ + public int typeId(Object obj); + + /** + * Converts temporary offheap object to heap-based. + * + * @param ctx Context. + * @param obj Object. + * @return Heap-based object. + * @throws IgniteException In case of error. + */ + @Nullable public Object unwrapTemporary(GridCacheContext ctx, @Nullable Object obj) throws IgniteException; + + /** + * @param obj Object to marshal. + * @return Portable object. + * @throws IgniteException In case of error. + */ + public Object marshalToPortable(@Nullable Object obj) throws IgniteException; + + /** + * Prepares cache object for cache (e.g. copies user-provided object if needed). + * + * @param obj Cache object. + * @param cctx Cache context. + * @return Object to be store in cache. + */ + @Nullable public CacheObject prepareForCache(@Nullable CacheObject obj, GridCacheContext cctx); + + /** + * @return Portable marshaller for client connectivity or {@code null} if it's not + * supported (in case of OS edition). + */ + @Nullable public GridClientMarshaller portableMarshaller(); + + /** + * @param marsh Client marshaller. + * @return Whether marshaller is portable. + */ + public boolean isPortable(GridClientMarshaller marsh); + + /** + * Checks whether object is portable object. + * + * @param obj Object to check. + * @return {@code True} if object is already a portable object, {@code false} otherwise. + */ + public boolean isPortableObject(Object obj); + + /** + * @param obj Portable object to get field from. + * @param fieldName Field name. + * @return Field value. + */ + public Object field(Object obj, String fieldName); + + /** + * Checks whether field is set in the object. + * + * @param obj Object. + * @param fieldName Field name. + * @return {@code true} if field is set. + */ + public boolean hasField(Object obj, String fieldName); + + /** + * @param ctx Cache object context. + * @param val Value. + * @return Value bytes. + * @throws IgniteCheckedException If failed. + */ + public byte[] marshal(CacheObjectContext ctx, Object val) throws IgniteCheckedException; + + /** + * @param ctx Context. + * @param bytes Bytes. + * @param clsLdr Class loader. + * @return Unmarshalled object. + * @throws IgniteCheckedException If failed. + */ + public Object unmarshal(CacheObjectContext ctx, byte[] bytes, ClassLoader clsLdr) throws IgniteCheckedException; + + /** + * @param node Node. + * @param cacheName Cache name. + * @return Cache object context. + */ + public CacheObjectContext contextForCache(ClusterNode node, @Nullable String cacheName); + + /** + * @param ctx Cache context. + * @param obj Object. + * @return Cache object. + */ + @Nullable public CacheObject toCacheObject(CacheObjectContext ctx, @Nullable Object obj); + + /** + * @param ctx Cache context. + * @param type Object type. + * @param bytes Object bytes. + * @return Cache object. + */ + public CacheObject toCacheObject(CacheObjectContext ctx, byte type, byte[] bytes); + + /** + * @param ctx Context. + * @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 toCacheObject(GridCacheContext ctx, long valPtr, boolean tmp) throws IgniteCheckedException; + + /** + * @param ctx Cache context. + * @param obj Key value. + * @return Cache key object. + */ + public KeyCacheObject toCacheKeyObject(CacheObjectContext ctx, Object obj); + + /** + * @param obj Value. + * @return {@code True} if object is of known immutable type of it is marked + * with {@link IgniteImmutable} annotation. + */ + public boolean immutable(Object obj); + + /** + * @return {@code True} if portable format should be preserved when passing values to cache store. + */ + public boolean keepPortableInStore(@Nullable String cacheName); +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7bbc80a6/modules/core/src/main/java/org/apache/ignite/internal/processors/portable/IgniteCacheObjectProcessorAdapter.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/portable/IgniteCacheObjectProcessorAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/portable/IgniteCacheObjectProcessorAdapter.java deleted file mode 100644 index 53e7bb7..0000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/portable/IgniteCacheObjectProcessorAdapter.java +++ /dev/null @@ -1,193 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.internal.processors.portable; - -import org.apache.ignite.*; -import org.apache.ignite.cache.*; -import org.apache.ignite.cluster.*; -import org.apache.ignite.configuration.*; -import org.apache.ignite.internal.*; -import org.apache.ignite.internal.processors.*; -import org.apache.ignite.internal.processors.cache.*; -import org.apache.ignite.internal.util.*; -import org.apache.ignite.internal.util.typedef.*; -import org.apache.ignite.internal.util.typedef.internal.*; -import org.apache.ignite.lang.*; -import org.jetbrains.annotations.*; - -import java.math.*; -import java.util.*; - -/** - * - */ -public abstract class IgniteCacheObjectProcessorAdapter extends GridProcessorAdapter implements GridPortableProcessor { - /** */ - private static final sun.misc.Unsafe UNSAFE = GridUnsafe.unsafe(); - - /** Immutable classes. */ - private static final Collection<Class<?>> IMMUTABLE_CLS = new HashSet<>(); - - /** */ - private final GridBoundedConcurrentLinkedHashMap<Class<?>, Boolean> reflectionCache = - new GridBoundedConcurrentLinkedHashMap<>(1024, 1024); - - /** - * - */ - static { - IMMUTABLE_CLS.add(String.class); - IMMUTABLE_CLS.add(Boolean.class); - IMMUTABLE_CLS.add(Byte.class); - IMMUTABLE_CLS.add(Short.class); - IMMUTABLE_CLS.add(Character.class); - IMMUTABLE_CLS.add(Integer.class); - IMMUTABLE_CLS.add(Long.class); - IMMUTABLE_CLS.add(Float.class); - IMMUTABLE_CLS.add(Double.class); - IMMUTABLE_CLS.add(UUID.class); - IMMUTABLE_CLS.add(IgniteUuid.class); - IMMUTABLE_CLS.add(BigDecimal.class); - } - - /** - * @param ctx Context. - */ - public IgniteCacheObjectProcessorAdapter(GridKernalContext ctx) { - super(ctx); - } - - /** {@inheritDoc} */ - @Nullable @Override public CacheObject prepareForCache(@Nullable CacheObject obj, GridCacheContext cctx) { - if (obj == null) - return null; - - return obj.prepareForCache(cctx.cacheObjectContext()); - } - - /** {@inheritDoc} */ - @Override public byte[] marshal(CacheObjectContext ctx, Object val) throws IgniteCheckedException { - return CU.marshal(ctx.kernalContext().cache().context(), val); - } - - /** {@inheritDoc} */ - @Override public Object unmarshal(CacheObjectContext ctx, byte[] bytes, ClassLoader clsLdr) - throws IgniteCheckedException - { - return ctx.kernalContext().cache().context().marshaller().unmarshal(bytes, clsLdr); - } - - /** {@inheritDoc} */ - @Nullable public KeyCacheObject toCacheKeyObject(CacheObjectContext ctx, Object obj) { - if (obj instanceof KeyCacheObject) - return (KeyCacheObject)obj; - - return new UserKeyCacheObjectImpl(obj, null); - } - - /** {@inheritDoc} */ - @Override public CacheObject toCacheObject(GridCacheContext ctx, long valPtr, boolean tmp) - throws IgniteCheckedException - { - assert valPtr != 0; - - int size = UNSAFE.getInt(valPtr); - - byte type = UNSAFE.getByte(valPtr + 4); - - byte[] bytes = U.copyMemory(valPtr + 5, size); - - if (ctx.kernalContext().config().isPeerClassLoadingEnabled() && - ctx.offheapTiered() && - type != CacheObjectAdapter.TYPE_BYTE_ARR) { - IgniteUuid valClsLdrId = U.readGridUuid(valPtr + 5 + size); - - ClassLoader ldr = - valClsLdrId != null ? ctx.deploy().getClassLoader(valClsLdrId) : ctx.deploy().localLoader(); - - return toCacheObject(ctx.cacheObjectContext(), unmarshal(ctx.cacheObjectContext(), bytes, ldr)); - } - else - return toCacheObject(ctx.cacheObjectContext(), type, bytes); - } - - /** {@inheritDoc} */ - @Override public CacheObject toCacheObject(CacheObjectContext ctx, byte type, byte[] bytes) { - switch (type) { - case CacheObjectAdapter.TYPE_BYTE_ARR: - return new CacheObjectImpl(bytes, null); - - case CacheObjectAdapter.TYPE_REGULAR: - return new CacheObjectImpl(null, bytes); - } - - throw new IllegalArgumentException("Invalid object type: " + type); - } - - /** {@inheritDoc} */ - @Nullable @Override public CacheObject toCacheObject(CacheObjectContext ctx, @Nullable Object obj) { - if (obj == null || obj instanceof CacheObject) - return (CacheObject)obj; - - return new UserCacheObjectImpl(obj); - } - - /** {@inheritDoc} */ - @Override public CacheObjectContext contextForCache(ClusterNode node, @Nullable String cacheName) { - CacheConfiguration ccfg = null; - - for (CacheConfiguration ccfg0 : ctx.config().getCacheConfiguration()) { - if (F.eq(cacheName, ccfg0.getName())) { - ccfg = ccfg0; - - break; - } - } - - return new CacheObjectContext(ctx, - new GridCacheDefaultAffinityKeyMapper(), - ccfg != null && ccfg.isCopyOnGet(), - ccfg != null && ccfg.isQueryIndexEnabled()); - } - - /** {@inheritDoc} */ - @Override public boolean immutable(Object obj) { - assert obj != null; - - Class<?> cls = obj.getClass(); - - if (IMMUTABLE_CLS.contains(cls)) - return true; - - Boolean immutable = reflectionCache.get(cls); - - if (immutable != null) - return immutable; - - immutable = IgniteUtils.hasAnnotation(cls, IgniteImmutable.class); - - reflectionCache.putIfAbsent(cls, immutable); - - return immutable; - } - - /** {@inheritDoc} */ - @Override public boolean keepPortableInStore(@Nullable String cacheName) { - return false; - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7bbc80a6/modules/core/src/main/java/org/apache/ignite/internal/processors/portable/IgniteCacheObjectProcessorImpl.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/portable/IgniteCacheObjectProcessorImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/portable/IgniteCacheObjectProcessorImpl.java new file mode 100644 index 0000000..b259593 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/portable/IgniteCacheObjectProcessorImpl.java @@ -0,0 +1,245 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.portable; + +import org.apache.ignite.*; +import org.apache.ignite.cache.*; +import org.apache.ignite.cluster.*; +import org.apache.ignite.configuration.*; +import org.apache.ignite.internal.*; +import org.apache.ignite.internal.client.marshaller.*; +import org.apache.ignite.internal.processors.*; +import org.apache.ignite.internal.processors.cache.*; +import org.apache.ignite.internal.util.*; +import org.apache.ignite.internal.util.typedef.*; +import org.apache.ignite.internal.util.typedef.internal.*; +import org.apache.ignite.lang.*; +import org.jetbrains.annotations.*; + +import java.math.*; +import java.util.*; + +/** + * + */ +public class IgniteCacheObjectProcessorImpl extends GridProcessorAdapter implements IgniteCacheObjectProcessor { + /** */ + private static final sun.misc.Unsafe UNSAFE = GridUnsafe.unsafe(); + + /** Immutable classes. */ + private static final Collection<Class<?>> IMMUTABLE_CLS = new HashSet<>(); + + /** */ + private final GridBoundedConcurrentLinkedHashMap<Class<?>, Boolean> reflectionCache = + new GridBoundedConcurrentLinkedHashMap<>(1024, 1024); + + /** + * + */ + static { + IMMUTABLE_CLS.add(String.class); + IMMUTABLE_CLS.add(Boolean.class); + IMMUTABLE_CLS.add(Byte.class); + IMMUTABLE_CLS.add(Short.class); + IMMUTABLE_CLS.add(Character.class); + IMMUTABLE_CLS.add(Integer.class); + IMMUTABLE_CLS.add(Long.class); + IMMUTABLE_CLS.add(Float.class); + IMMUTABLE_CLS.add(Double.class); + IMMUTABLE_CLS.add(UUID.class); + IMMUTABLE_CLS.add(IgniteUuid.class); + IMMUTABLE_CLS.add(BigDecimal.class); + } + + /** + * @param ctx Context. + */ + public IgniteCacheObjectProcessorImpl(GridKernalContext ctx) { + super(ctx); + } + + /** {@inheritDoc} */ + @Nullable @Override public CacheObject prepareForCache(@Nullable CacheObject obj, GridCacheContext cctx) { + if (obj == null) + return null; + + return obj.prepareForCache(cctx.cacheObjectContext()); + } + + /** {@inheritDoc} */ + @Override public byte[] marshal(CacheObjectContext ctx, Object val) throws IgniteCheckedException { + return CU.marshal(ctx.kernalContext().cache().context(), val); + } + + /** {@inheritDoc} */ + @Override public Object unmarshal(CacheObjectContext ctx, byte[] bytes, ClassLoader clsLdr) + throws IgniteCheckedException + { + return ctx.kernalContext().cache().context().marshaller().unmarshal(bytes, clsLdr); + } + + /** {@inheritDoc} */ + @Nullable public KeyCacheObject toCacheKeyObject(CacheObjectContext ctx, Object obj) { + if (obj instanceof KeyCacheObject) + return (KeyCacheObject)obj; + + return new UserKeyCacheObjectImpl(obj, null); + } + + /** {@inheritDoc} */ + @Override public CacheObject toCacheObject(GridCacheContext ctx, long valPtr, boolean tmp) + throws IgniteCheckedException + { + assert valPtr != 0; + + int size = UNSAFE.getInt(valPtr); + + byte type = UNSAFE.getByte(valPtr + 4); + + byte[] bytes = U.copyMemory(valPtr + 5, size); + + if (ctx.kernalContext().config().isPeerClassLoadingEnabled() && + ctx.offheapTiered() && + type != CacheObjectAdapter.TYPE_BYTE_ARR) { + IgniteUuid valClsLdrId = U.readGridUuid(valPtr + 5 + size); + + ClassLoader ldr = + valClsLdrId != null ? ctx.deploy().getClassLoader(valClsLdrId) : ctx.deploy().localLoader(); + + return toCacheObject(ctx.cacheObjectContext(), unmarshal(ctx.cacheObjectContext(), bytes, ldr)); + } + else + return toCacheObject(ctx.cacheObjectContext(), type, bytes); + } + + /** {@inheritDoc} */ + @Override public CacheObject toCacheObject(CacheObjectContext ctx, byte type, byte[] bytes) { + switch (type) { + case CacheObjectAdapter.TYPE_BYTE_ARR: + return new CacheObjectImpl(bytes, null); + + case CacheObjectAdapter.TYPE_REGULAR: + return new CacheObjectImpl(null, bytes); + } + + throw new IllegalArgumentException("Invalid object type: " + type); + } + + /** {@inheritDoc} */ + @Nullable @Override public CacheObject toCacheObject(CacheObjectContext ctx, @Nullable Object obj) { + if (obj == null || obj instanceof CacheObject) + return (CacheObject)obj; + + return new UserCacheObjectImpl(obj); + } + + /** {@inheritDoc} */ + @Override public CacheObjectContext contextForCache(ClusterNode node, @Nullable String cacheName) { + CacheConfiguration ccfg = null; + + for (CacheConfiguration ccfg0 : ctx.config().getCacheConfiguration()) { + if (F.eq(cacheName, ccfg0.getName())) { + ccfg = ccfg0; + + break; + } + } + + return new CacheObjectContext(ctx, + new GridCacheDefaultAffinityKeyMapper(), + ccfg != null && ccfg.isCopyOnGet(), + ccfg != null && ccfg.isQueryIndexEnabled()); + } + + /** {@inheritDoc} */ + @Override public boolean immutable(Object obj) { + assert obj != null; + + Class<?> cls = obj.getClass(); + + if (IMMUTABLE_CLS.contains(cls)) + return true; + + Boolean immutable = reflectionCache.get(cls); + + if (immutable != null) + return immutable; + + immutable = IgniteUtils.hasAnnotation(cls, IgniteImmutable.class); + + reflectionCache.putIfAbsent(cls, immutable); + + return immutable; + } + + /** {@inheritDoc} */ + @Override public boolean keepPortableInStore(@Nullable String cacheName) { + return false; + } + + /** {@inheritDoc} */ + @Override public void onCacheProcessorStarted() { + // No-op. + } + + /** {@inheritDoc} */ + @Override public int typeId(String typeName) { + return 0; + } + + + /** {@inheritDoc} */ + @Override public Object unwrapTemporary(GridCacheContext ctx, Object obj) throws IgniteException { + return obj; + } + + /** {@inheritDoc} */ + @Nullable @Override public Object marshalToPortable(@Nullable Object obj) throws IgniteException { + return obj; + } + + /** {@inheritDoc} */ + @Nullable @Override public GridClientMarshaller portableMarshaller() { + return null; + } + + /** {@inheritDoc} */ + @Override public boolean isPortable(GridClientMarshaller marsh) { + return false; + } + + /** {@inheritDoc} */ + @Override public boolean isPortableObject(Object obj) { + return false; + } + + /** {@inheritDoc} */ + @Override public int typeId(Object obj) { + return 0; + } + + /** {@inheritDoc} */ + @Override public Object field(Object obj, String fieldName) { + return null; + } + + /** {@inheritDoc} */ + @Override public boolean hasField(Object obj, String fieldName) { + return false; + } +}