ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [2/3] incubator-ignite git commit: ignite-471: revert changes in gridcacheobjectprocessor
Date Fri, 15 May 2015 15:55:45 GMT
ignite-471: revert changes in gridcacheobjectprocessor


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/4b5d9fcd
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/4b5d9fcd
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/4b5d9fcd

Branch: refs/heads/ignite-471
Commit: 4b5d9fcde29e5fba35a1f325256486a31cfeb277
Parents: c55b867
Author: Denis Magda <dmagda@gridgain.com>
Authored: Fri May 15 10:50:00 2015 +0300
Committer: Denis Magda <dmagda@gridgain.com>
Committed: Fri May 15 10:50:00 2015 +0300

----------------------------------------------------------------------
 .../processors/cache/CacheObjectContext.java    | 28 --------------------
 .../processors/cache/CacheObjectImpl.java       | 12 ++++-----
 .../processors/cache/GridCacheContext.java      |  4 +--
 .../processors/cache/GridCacheEntryInfo.java    |  2 +-
 .../processors/cache/GridCacheMapEntry.java     |  4 +--
 .../processors/cache/GridCacheSwapManager.java  |  3 ++-
 .../processors/cache/KeyCacheObjectImpl.java    | 16 ++++-------
 .../cacheobject/IgniteCacheObjectProcessor.java | 17 ++++++++++++
 .../IgniteCacheObjectProcessorImpl.java         | 24 ++++++++++++-----
 .../query/h2/opt/GridLuceneIndex.java           |  2 +-
 10 files changed, 54 insertions(+), 58 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b5d9fcd/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 f4810ce..7b9c22e 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
@@ -109,34 +109,6 @@ public class CacheObjectContext {
     }
 
     /**
-     * @param obj Object.
-     * @return Bytes.
-     * @throws IgniteCheckedException In case of error.
-     */
-    public ByteBuffer marshal(Object obj) throws IgniteCheckedException {
-        return kernalCtx.config().getMarshaller().marshal(obj);
-    }
-
-    /**
-     * @param buf Bytes.
-     * @return Object.
-     * @throws IgniteCheckedException In case of error.
-     */
-    public <T> T unmarshal(ByteBuffer buf) throws IgniteCheckedException {
-        return kernalCtx.config().getMarshaller().unmarshal(buf, kernalCtx.config().getClassLoader());
-    }
-
-    /**
-     * @param buf Bytes.
-     * @param ldr Class loader.
-     * @return Object.
-     * @throws IgniteCheckedException In case of error.
-     */
-    public <T> T unmarshal(ByteBuffer buf, ClassLoader ldr) throws IgniteCheckedException
{
-        return kernalCtx.config().getMarshaller().unmarshal(buf, ldr);
-    }
-
-    /**
      * Unwraps object.
      *
      * @param o Object to unwrap.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b5d9fcd/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 eaa6f59..124807f 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
@@ -57,10 +57,10 @@ public class CacheObjectImpl extends CacheObjectAdapter {
                 if (valBytes == null) {
                     assert val != null;
 
-                    valBytes = ctx.marshal(val);
+                    valBytes = ctx.processor().marshal(ctx, val);
                 }
 
-                return (T)ctx.unmarshal(valBytes,
+                return (T)ctx.processor().unmarshal(ctx, valBytes,
                     val == null ? ctx.kernalContext().config().getClassLoader() : val.getClass().getClassLoader());
             }
 
@@ -69,7 +69,7 @@ public class CacheObjectImpl extends CacheObjectAdapter {
 
             assert valBytes != null;
 
-            Object val = ctx.unmarshal(valBytes, ctx.kernalContext().config().getClassLoader());
+            Object val = ctx.processor().unmarshal(ctx, valBytes, ctx.kernalContext().config().getClassLoader());
 
             if (ctx.storeValue())
                 this.val = val;
@@ -85,7 +85,7 @@ public class CacheObjectImpl extends CacheObjectAdapter {
     /** {@inheritDoc} */
     @Override public ByteBuffer valueBytes(CacheObjectContext ctx) throws IgniteCheckedException
{
         if (valBytes == null)
-            valBytes = ctx.marshal(val);
+            valBytes = ctx.processor().marshal(ctx, val);
 
         return valBytes;
     }
@@ -95,7 +95,7 @@ public class CacheObjectImpl extends CacheObjectAdapter {
         assert val != null || valBytes != null;
 
         if (valBytes == null)
-            valBytes = ctx.marshal(val);
+            valBytes = ctx.kernalContext().cacheObjects().marshal(ctx, val);
     }
 
     /** {@inheritDoc} */
@@ -103,7 +103,7 @@ public class CacheObjectImpl extends CacheObjectAdapter {
         assert val != null || valBytes != null;
 
         if (val == null && ctx.storeValue())
-            val = ctx.unmarshal(valBytes, ldr);
+            val = ctx.processor().unmarshal(ctx, valBytes, ldr);
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b5d9fcd/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 e256b46..57d1684 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
@@ -1720,7 +1720,7 @@ public class GridCacheContext<K, V> implements Externalizable
{
      * @throws IgniteCheckedException If failed.
      */
     public KeyCacheObject bytesToCacheKeyObject(ByteBuffer bytes) throws IgniteCheckedException
{
-        Object obj = marshaller().unmarshal(bytes, deploy().localLoader());
+        Object obj = ctx.cacheObjects().unmarshal(cacheObjCtx, bytes, deploy().localLoader());
 
         return cacheObjects().toCacheKeyObject(cacheObjCtx, obj, false);
     }
@@ -1742,7 +1742,7 @@ public class GridCacheContext<K, V> implements Externalizable
{
                 return null;
 
             return ctx.cacheObjects().toCacheObject(cacheObjCtx,
-                marshaller().unmarshal(bytes, ldr),
+                ctx.cacheObjects().unmarshal(cacheObjCtx, bytes, ldr),
                 false);
         }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b5d9fcd/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 1409588..1bbce6d 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,7 +398,7 @@ public class GridCacheEntryInfo implements Message {
 
             CacheObjectContext cacheObjCtx = ctx.cacheObjectContext();
 
-            Object key0 = ctx.marshaller().unmarshal(keyBytes, clsLdr);
+            Object key0 = ctx.cacheObjects().unmarshal(cacheObjCtx, keyBytes, clsLdr);
 
             key = ctx.cacheObjects().toCacheKeyObject(cacheObjCtx, key0, false);
         }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b5d9fcd/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 686242a..1c2f8d5 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
@@ -207,8 +207,8 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx {
                     Object val0 = null;
 
                     if (val != null && val.type() != CacheObject.TYPE_BYTE_ARR) {
-                        val0 = cctx.marshaller().unmarshal(val.valueBytes(cctx.cacheObjectContext()),
-                            cctx.deploy().globalLoader());
+                        val0 = cctx.cacheObjects().unmarshal(cctx.cacheObjectContext(),
+                            val.valueBytes(cctx.cacheObjectContext()), cctx.deploy().globalLoader());
 
                         if (val0 != null)
                             cctx.gridDeploy().deploy(val0.getClass(), val0.getClass().getClassLoader());

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b5d9fcd/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 eda57cf..be85b5d 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
@@ -1798,7 +1798,8 @@ public class GridCacheSwapManager extends GridCacheManagerAdapter {
                                     swapEntry.value() == null &&
                                     swapEntry.type() != CacheObject.TYPE_BYTE_ARR) {
                                     // We need value here only for classloading purposes.
-                                    Object val =  cctx.marshaller().unmarshal(ByteBuffer.wrap(swapEntry.valueBytes()),
+                                    Object val =  cctx.cacheObjects().unmarshal(cctx.cacheObjectContext(),
+                                        ByteBuffer.wrap(swapEntry.valueBytes()),
                                         cctx.deploy().globalLoader());
 
                                     if (val != null)

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b5d9fcd/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 e65ac3c..e8f202b 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.jetbrains.annotations.*;
 
 import java.nio.*;
@@ -60,9 +59,9 @@ public class KeyCacheObjectImpl extends CacheObjectAdapter implements KeyCacheOb
     /** {@inheritDoc} */
     @Override public ByteBuffer valueBytes(CacheObjectContext ctx) throws IgniteCheckedException
{
         if (valBytes == null)
-            valBytes = ctx.marshal(val);
+            valBytes = ctx.processor().marshal(ctx, val);
 
-        return valBytes.duplicate();
+        return valBytes;
     }
 
     /** {@inheritDoc} */
@@ -82,12 +81,7 @@ public class KeyCacheObjectImpl extends CacheObjectAdapter implements KeyCacheOb
 
     /** {@inheritDoc} */
     @Override public CacheObject prepareForCache(CacheObjectContext ctx) {
-        ByteBuffer valBytes0 = U.trim(valBytes);
-
-        if (valBytes0 != valBytes)
-            return new KeyCacheObjectImpl(val, valBytes0);
-        else
-            return this;
+        return this;
     }
 
     /** {@inheritDoc} */
@@ -105,7 +99,7 @@ public class KeyCacheObjectImpl extends CacheObjectAdapter implements KeyCacheOb
     /** {@inheritDoc} */
     @Override public void prepareMarshal(CacheObjectContext ctx) throws IgniteCheckedException
{
         if (valBytes == null)
-            valBytes = ctx.marshal(val);
+            valBytes = ctx.kernalContext().cacheObjects().marshal(ctx, val);
     }
 
     /** {@inheritDoc} */
@@ -113,7 +107,7 @@ public class KeyCacheObjectImpl extends CacheObjectAdapter implements
KeyCacheOb
         if (val == null) {
             assert valBytes != null;
 
-            val = ctx.unmarshal(valBytes, ldr);
+            val = ctx.kernalContext().cacheObjects().unmarshal(ctx, valBytes, ldr);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b5d9fcd/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessor.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessor.java
index a82b302..d04f6bf 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessor.java
@@ -101,6 +101,23 @@ public interface IgniteCacheObjectProcessor extends GridProcessor {
     public boolean hasField(Object obj, String fieldName);
 
     /**
+     * @param ctx Cache object context.
+     * @param val Value.
+     * @return Value bytes.
+     * @throws IgniteCheckedException If failed.
+     */
+    public ByteBuffer 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, ByteBuffer bytes, ClassLoader clsLdr)
throws IgniteCheckedException;
+
+    /**
      * @return Cache object context.
      */
     public CacheObjectContext contextForCache(CacheConfiguration ccfg);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b5d9fcd/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java
index f4b0ba4..37b4588 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java
@@ -84,6 +84,18 @@ public class IgniteCacheObjectProcessorImpl extends GridProcessorAdapter
impleme
     }
 
     /** {@inheritDoc} */
+    @Override public ByteBuffer marshal(CacheObjectContext ctx, Object val) throws IgniteCheckedException
{
+        return CU.marshal(ctx.kernalContext().cache().context(), val);
+    }
+
+    /** {@inheritDoc} */
+    @Override public Object unmarshal(CacheObjectContext ctx, ByteBuffer bytes, ClassLoader
clsLdr)
+        throws IgniteCheckedException
+    {
+        return ctx.kernalContext().cache().context().marshaller().unmarshal(bytes, clsLdr);
+    }
+
+    /** {@inheritDoc} */
     @Override @Nullable public KeyCacheObject toCacheKeyObject(CacheObjectContext ctx, Object
obj, boolean userObj) {
         if (obj instanceof KeyCacheObject)
             return (KeyCacheObject)obj;
@@ -125,8 +137,8 @@ public class IgniteCacheObjectProcessorImpl extends GridProcessorAdapter
impleme
             ClassLoader ldr =
                 valClsLdrId != null ? ctx.deploy().getClassLoader(valClsLdrId) : ctx.deploy().localLoader();
 
-            return toCacheObject(ctx.cacheObjectContext(), ctx.marshaller().unmarshal(ByteBuffer.wrap(bytes),
ldr),
-                false);
+            return toCacheObject(ctx.cacheObjectContext(), unmarshal(ctx.cacheObjectContext(),
+                ByteBuffer.wrap(bytes), ldr), false);
         }
         else
             return toCacheObject(ctx.cacheObjectContext(), type, ByteBuffer.wrap(bytes));
@@ -290,12 +302,12 @@ public class IgniteCacheObjectProcessorImpl extends GridProcessorAdapter
impleme
             try {
                 if (!ctx.processor().immutable(val)) {
                     if (valBytes == null)
-                        valBytes = ctx.marshal(val);
+                        valBytes = ctx.processor().marshal(ctx, val);
 
                     ClassLoader ldr = ctx.p2pEnabled() ?
                         IgniteUtils.detectClassLoader(IgniteUtils.detectClass(this.val))
: U.gridClassLoader();
 
-                        Object val = ctx.unmarshal(valBytes, ldr);
+                     Object val = ctx.processor().unmarshal(ctx, valBytes, ldr);
 
                     return new KeyCacheObjectImpl(val, valBytes);
                 }
@@ -339,14 +351,14 @@ public class IgniteCacheObjectProcessorImpl extends GridProcessorAdapter
impleme
         @Override public CacheObject prepareForCache(CacheObjectContext ctx) {
             try {
                 if (valBytes == null)
-                    valBytes = ctx.marshal(val);
+                    valBytes = ctx.processor().marshal(ctx, val);
 
                 if (ctx.storeValue()) {
                     ClassLoader ldr = ctx.p2pEnabled() ?
                         IgniteUtils.detectClass(this.val).getClassLoader() : val.getClass().getClassLoader();
 
                     Object val = this.val != null && ctx.processor().immutable(this.val)
? this.val :
-                        ctx.unmarshal(valBytes, ldr);
+                        ctx.processor().unmarshal(ctx, valBytes, ldr);
 
                     return new CacheObjectImpl(val, valBytes);
                 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b5d9fcd/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridLuceneIndex.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridLuceneIndex.java
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridLuceneIndex.java
index b3dae86..9c095e3 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridLuceneIndex.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridLuceneIndex.java
@@ -352,7 +352,7 @@ public class GridLuceneIndex implements Closeable {
             if (coctx == null) // For tests.
                 return (Z)Utils.deserialize(bytes, null);
 
-            return (Z)coctx.unmarshal(ByteBuffer.wrap(bytes), ldr);
+            return (Z)coctx.processor().unmarshal(coctx, ByteBuffer.wrap(bytes), ldr);
         }
 
         /**


Mime
View raw message