ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [48/50] [abbrv] incubator-ignite git commit: # ignite-51
Date Tue, 10 Mar 2015 09:52:12 GMT
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d7dac569/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
index e1bfaae..6fcc507 100644
--- 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
@@ -34,6 +34,8 @@ import org.jetbrains.annotations.*;
 import java.math.*;
 import java.util.*;
 
+import static org.apache.ignite.cache.CacheMemoryMode.*;
+
 /**
  *
  */
@@ -94,11 +96,52 @@ public class IgniteCacheObjectProcessorImpl extends GridProcessorAdapter
impleme
     }
 
     /** {@inheritDoc} */
-    @Nullable public KeyCacheObject toCacheKeyObject(CacheObjectContext ctx, Object obj)
{
+    @Nullable public KeyCacheObject toCacheKeyObject(CacheObjectContext ctx, Object obj,
boolean userObj) {
         if (obj instanceof KeyCacheObject)
             return (KeyCacheObject)obj;
 
-        return new UserKeyCacheObjectImpl(obj, null);
+        return toCacheKeyObject0(obj, userObj);
+    }
+
+    /**
+     * @param obj Object.
+     * @param userObj If {@code true} then given object is object provided by user and should
be copied
+     *        before stored in cache.
+     * @return Key cache object.
+     */
+    @SuppressWarnings("ExternalizableWithoutPublicNoArgConstructor")
+    protected KeyCacheObject toCacheKeyObject0(Object obj, boolean userObj) {
+        if (!userObj)
+            return new KeyCacheObjectImpl(obj, null);
+
+        return new KeyCacheObjectImpl(obj, null) {
+            @Nullable @Override public <T> T value(CacheObjectContext ctx, boolean
cpy) {
+                return super.value(ctx, false);  // Do not need copy since user value is
not in cache.
+            }
+
+            @Override public CacheObject prepareForCache(CacheObjectContext ctx) {
+                try {
+                    if (!ctx.processor().immutable(val)) {
+                        if (valBytes == null)
+                            valBytes = ctx.processor().marshal(ctx, val);
+
+                        ClassLoader ldr = ctx.p2pEnabled() ?
+                            IgniteUtils.detectClass(this.val).getClassLoader() : val.getClass().getClassLoader();
+
+                        Object val = ctx.processor().unmarshal(ctx,
+                            valBytes,
+                            ldr);
+
+                        return new KeyCacheObjectImpl(val, valBytes);
+                    }
+
+                    return new KeyCacheObjectImpl(val, valBytes);
+                }
+                catch (IgniteCheckedException e) {
+                    throw new IgniteException("Failed to marshal object: " + val, e);
+                }
+            }
+        };
     }
 
     /** {@inheritDoc} */
@@ -121,7 +164,7 @@ public class IgniteCacheObjectProcessorImpl extends GridProcessorAdapter
impleme
             ClassLoader ldr =
                 valClsLdrId != null ? ctx.deploy().getClassLoader(valClsLdrId) : ctx.deploy().localLoader();
 
-            return toCacheObject(ctx.cacheObjectContext(), unmarshal(ctx.cacheObjectContext(),
bytes, ldr));
+            return toCacheObject(ctx.cacheObjectContext(), unmarshal(ctx.cacheObjectContext(),
bytes, ldr), false);
         }
         else
             return toCacheObject(ctx.cacheObjectContext(), type, bytes);
@@ -131,7 +174,7 @@ public class IgniteCacheObjectProcessorImpl extends GridProcessorAdapter
impleme
     @Override public CacheObject toCacheObject(CacheObjectContext ctx, byte type, byte[]
bytes) {
         switch (type) {
             case CacheObjectAdapter.TYPE_BYTE_ARR:
-                return new CacheObjectImpl(bytes, null);
+                return new CacheObjectByteArrayImpl(bytes);
 
             case CacheObjectAdapter.TYPE_REGULAR:
                 return new CacheObjectImpl(null, bytes);
@@ -141,11 +184,76 @@ public class IgniteCacheObjectProcessorImpl extends GridProcessorAdapter
impleme
     }
 
     /** {@inheritDoc} */
-    @Nullable @Override public CacheObject toCacheObject(CacheObjectContext ctx, @Nullable
Object obj) {
+    @Nullable @Override public CacheObject toCacheObject(CacheObjectContext ctx,
+        @Nullable Object obj,
+        boolean userObj)
+    {
         if (obj == null || obj instanceof CacheObject)
             return (CacheObject)obj;
 
-        return new UserCacheObjectImpl(obj);
+        return toCacheObject0(obj, userObj);
+    }
+
+    /**
+     * @param obj Object.
+     * @param userObj If {@code true} then given object is object provided by user and should
be copied
+     *        before stored in cache.
+     * @return Cache object.
+     */
+    @SuppressWarnings("ExternalizableWithoutPublicNoArgConstructor")
+    protected CacheObject toCacheObject0(@Nullable Object obj, boolean userObj) {
+        assert obj != null;
+
+        if (obj instanceof byte[]) {
+            if (!userObj)
+                return new CacheObjectByteArrayImpl((byte[])obj);
+
+            return new CacheObjectByteArrayImpl((byte[]) obj) {
+                @Nullable @Override public <T> T value(CacheObjectContext ctx, boolean
cpy) {
+                    return super.value(ctx, false); // Do not need copy since user value
is not in cache.
+                }
+
+                @Override public CacheObject prepareForCache(CacheObjectContext ctx) {
+                    byte[] valCpy = Arrays.copyOf(val, val.length);
+
+                    return new CacheObjectByteArrayImpl(valCpy);
+                }
+            };
+        }
+
+        if (!userObj)
+            new CacheObjectImpl(obj, null);
+
+        return new CacheObjectImpl(obj, null) {
+            @Nullable @Override public <T> T value(CacheObjectContext ctx, boolean
cpy) {
+                return super.value(ctx, false); // Do not need copy since user value is not
in cache.
+            }
+
+            @Override public CacheObject prepareForCache(CacheObjectContext ctx) {
+                if (!ctx.processor().immutable(val)) {
+                    try {
+                        if (valBytes == null)
+                            valBytes = ctx.processor().marshal(ctx, val);
+
+                        if (ctx.unmarshalValues()) {
+                            ClassLoader ldr = ctx.p2pEnabled() ?
+                                IgniteUtils.detectClass(this.val).getClassLoader() : val.getClass().getClassLoader();
+
+                            Object val = ctx.processor().unmarshal(ctx, valBytes, ldr);
+
+                            return new CacheObjectImpl(val, valBytes);
+                        }
+
+                        return new CacheObjectImpl(null, valBytes);
+                    }
+                    catch (IgniteCheckedException e) {
+                        throw new IgniteException("Failed to marshal object: " + val, e);
+                    }
+                }
+                else
+                    return new CacheObjectImpl(val, valBytes);
+            }
+        };
     }
 
     /** {@inheritDoc} */
@@ -160,10 +268,20 @@ public class IgniteCacheObjectProcessorImpl extends GridProcessorAdapter
impleme
             }
         }
 
-        return new CacheObjectContext(ctx,
-            new GridCacheDefaultAffinityKeyMapper(),
-            ccfg != null && ccfg.isCopyOnGet(),
-            ctx.config().isPeerClassLoadingEnabled() || (ccfg != null && ccfg.isQueryIndexEnabled()));
+        if (ccfg != null) {
+            CacheMemoryMode memMode = ccfg.getMemoryMode();
+
+            return new CacheObjectContext(ctx,
+                new GridCacheDefaultAffinityKeyMapper(),
+                ccfg.isCopyOnGet() && memMode == ONHEAP_TIERED,
+                ctx.config().isPeerClassLoadingEnabled() || ccfg.isQueryIndexEnabled());
+        }
+        else
+            return new CacheObjectContext(
+                ctx,
+                new GridCacheDefaultAffinityKeyMapper(),
+                false,
+                ctx.config().isPeerClassLoadingEnabled());
     }
 
     /** {@inheritDoc} */
@@ -209,21 +327,6 @@ public class IgniteCacheObjectProcessorImpl extends GridProcessorAdapter
impleme
     }
 
     /** {@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;
     }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d7dac569/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheCommandHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheCommandHandler.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheCommandHandler.java
index c63e414..0f45991 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheCommandHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheCommandHandler.java
@@ -153,7 +153,7 @@ public class GridCacheCommandHandler extends GridRestCommandHandlerAdapter
{
             switch (cmd) {
                 case CACHE_GET: {
                     fut = executeCommand(req.destinationId(), req.clientId(), cacheName,
flags, key,
-                        new GetCommand(key), req.portableMode());
+                        new GetCommand(key));
 
                     break;
                 }
@@ -175,7 +175,7 @@ public class GridCacheCommandHandler extends GridRestCommandHandlerAdapter
{
                     }
 
                     fut = executeCommand(req.destinationId(), req.clientId(), cacheName,
flags, key,
-                        new GetAllCommand(keys0), req.portableMode());
+                        new GetAllCommand(keys0));
 
                     break;
                 }
@@ -187,7 +187,7 @@ public class GridCacheCommandHandler extends GridRestCommandHandlerAdapter
{
                         throw new IgniteCheckedException(GridRestCommandHandlerAdapter.missingParameter("val"));
 
                     fut = executeCommand(req.destinationId(), req.clientId(), cacheName,
flags, key, new
-                        PutCommand(key, ttl, val), req.portableMode());
+                        PutCommand(key, ttl, val));
 
                     break;
                 }
@@ -199,7 +199,7 @@ public class GridCacheCommandHandler extends GridRestCommandHandlerAdapter
{
                         throw new IgniteCheckedException(GridRestCommandHandlerAdapter.missingParameter("val"));
 
                     fut = executeCommand(req.destinationId(), req.clientId(), cacheName,
flags, key,
-                        new AddCommand(key, ttl, val), req.portableMode());
+                        new AddCommand(key, ttl, val));
 
                     break;
                 }
@@ -222,14 +222,14 @@ public class GridCacheCommandHandler extends GridRestCommandHandlerAdapter
{
                     map = new HashMap<>(map);
 
                     fut = executeCommand(req.destinationId(), req.clientId(), cacheName,
flags, key,
-                        new PutAllCommand(map), req.portableMode());
+                        new PutAllCommand(map));
 
                     break;
                 }
 
                 case CACHE_REMOVE: {
                     fut = executeCommand(req.destinationId(), req.clientId(), cacheName,
flags, key,
-                        new RemoveCommand(key), req.portableMode());
+                        new RemoveCommand(key));
 
                     break;
                 }
@@ -241,7 +241,7 @@ public class GridCacheCommandHandler extends GridRestCommandHandlerAdapter
{
                     Set<Object> keys = map == null ? null : new HashSet<>(map.keySet());
 
                     fut = executeCommand(req.destinationId(), req.clientId(), cacheName,
flags, key,
-                        new RemoveAllCommand(keys), req.portableMode());
+                        new RemoveAllCommand(keys));
 
                     break;
                 }
@@ -253,7 +253,7 @@ public class GridCacheCommandHandler extends GridRestCommandHandlerAdapter
{
                         throw new IgniteCheckedException(GridRestCommandHandlerAdapter.missingParameter("val"));
 
                     fut = executeCommand(req.destinationId(), req.clientId(), cacheName,
flags, key,
-                        new ReplaceCommand(key, ttl, val), req.portableMode());
+                        new ReplaceCommand(key, ttl, val));
 
                     break;
                 }
@@ -263,21 +263,21 @@ public class GridCacheCommandHandler extends GridRestCommandHandlerAdapter
{
                     final Object val2 = req0.value2();
 
                     fut = executeCommand(req.destinationId(), req.clientId(), cacheName,
flags, key,
-                        new CasCommand(val2, val1, key), req.portableMode());
+                        new CasCommand(val2, val1, key));
 
                     break;
                 }
 
                 case CACHE_APPEND: {
                     fut = executeCommand(req.destinationId(), req.clientId(), cacheName,
flags, key,
-                        new AppendCommand(key, req0), req.portableMode());
+                        new AppendCommand(key, req0));
 
                     break;
                 }
 
                 case CACHE_PREPEND: {
                     fut = executeCommand(req.destinationId(), req.clientId(), cacheName,
flags, key,
-                        new PrependCommand(key, req0), req.portableMode());
+                        new PrependCommand(key, req0));
 
                     break;
                 }
@@ -321,7 +321,6 @@ public class GridCacheCommandHandler extends GridRestCommandHandlerAdapter
{
      * @param flags Cache flags.
      * @param key Key to set affinity mapping in the response.
      * @param op Operation to perform.
-     * @param keepPortable Keep portable flag.
      * @return Operation result in future.
      * @throws IgniteCheckedException If failed
      */
@@ -331,8 +330,7 @@ public class GridCacheCommandHandler extends GridRestCommandHandlerAdapter
{
         final String cacheName,
         final CacheFlag[] flags,
         final Object key,
-        final CacheProjectionCommand op,
-        final boolean keepPortable) throws IgniteCheckedException {
+        final CacheProjectionCommand op) throws IgniteCheckedException {
 
         final boolean locExec =
             destId == null || destId.equals(ctx.localNodeId()) || replicatedCacheAvailable(cacheName);
@@ -340,9 +338,6 @@ public class GridCacheCommandHandler extends GridRestCommandHandlerAdapter
{
         if (locExec) {
             CacheProjection<?,?> prj = localCache(cacheName).forSubjectId(clientId).flagsOn(flags);
 
-            if (keepPortable)
-                prj = prj.keepPortable();
-
             return op.apply((CacheProjection<Object, Object>)prj, ctx).
                 chain(resultWrapper((CacheProjection<Object, Object>)prj, key));
         }
@@ -352,7 +347,7 @@ public class GridCacheCommandHandler extends GridRestCommandHandlerAdapter
{
             ctx.task().setThreadContext(TC_NO_FAILOVER, true);
 
             return ctx.closure().callAsync(BALANCE,
-                new FlaggedCacheOperationCallable(clientId, cacheName, flags, op, key, keepPortable),
+                new FlaggedCacheOperationCallable(clientId, cacheName, flags, op, key),
                 prj.nodes());
         }
     }
@@ -640,9 +635,6 @@ public class GridCacheCommandHandler extends GridRestCommandHandlerAdapter
{
         private final Object key;
 
         /** */
-        private final boolean keepPortable;
-
-        /** */
         @IgniteInstanceResource
         private Ignite g;
 
@@ -652,25 +644,23 @@ public class GridCacheCommandHandler extends GridRestCommandHandlerAdapter
{
          * @param flags Flags.
          * @param op Operation.
          * @param key Key.
-         * @param keepPortable Keep portable flag.
          */
-        private FlaggedCacheOperationCallable(UUID clientId, String cacheName, CacheFlag[]
flags,
-            CacheProjectionCommand op, Object key, boolean keepPortable) {
+        private FlaggedCacheOperationCallable(UUID clientId,
+            String cacheName,
+            CacheFlag[] flags,
+            CacheProjectionCommand op,
+            Object key) {
             this.clientId = clientId;
             this.cacheName = cacheName;
             this.flags = flags;
             this.op = op;
             this.key = key;
-            this.keepPortable = keepPortable;
         }
 
         /** {@inheritDoc} */
         @Override public GridRestResponse call() throws Exception {
             CacheProjection<?, ?> prj = cache(g, cacheName).forSubjectId(clientId).flagsOn(flags);
 
-            if (keepPortable)
-                prj = prj.keepPortable();
-
             // Need to apply both operation and response transformation remotely
             // as cache could be inaccessible on local node and
             // exception processing should be consistent with local execution.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d7dac569/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskCommandHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskCommandHandler.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskCommandHandler.java
index e2e230b..e42ae58 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskCommandHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/task/GridTaskCommandHandler.java
@@ -256,8 +256,7 @@ public class GridTaskCommandHandler extends GridRestCommandHandlerAdapter
{
                                 if (desc.error() == null) {
                                     try {
                                         taskRestRes.setFinished(true);
-                                        taskRestRes.setResult(req.portableMode() ?
-                                            ctx.cacheObjects().marshalToPortable(desc.result())
: desc.result());
+                                        taskRestRes.setResult(desc.result());
 
                                         res.setResponse(taskRestRes);
                                         fut.onDone(res);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d7dac569/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestNioListener.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestNioListener.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestNioListener.java
index 2cd50e5..3da47bb 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestNioListener.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestNioListener.java
@@ -252,7 +252,6 @@ public class GridTcpRestNioListener extends GridNioServerListenerAdapter<GridCli
             restCacheReq.key(req.key());
             restCacheReq.value(req.value());
             restCacheReq.value2(req.value2());
-            restCacheReq.portableMode(proto.portableMode(ses));
 
             Map vals = req.values();
             if (vals != null)
@@ -295,8 +294,6 @@ public class GridTcpRestNioListener extends GridNioServerListenerAdapter<GridCli
 
             restTaskReq.taskName(req.taskName());
             restTaskReq.params(Arrays.asList(req.argument()));
-            restTaskReq.keepPortables(req.keepPortables());
-            restTaskReq.portableMode(proto.portableMode(ses));
 
             restReq = restTaskReq;
         }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d7dac569/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestProtocol.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestProtocol.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestProtocol.java
index a0f7264..5645cf5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestProtocol.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestProtocol.java
@@ -82,14 +82,6 @@ public class GridTcpRestProtocol extends GridRestProtocolAdapter {
         return marsh;
     }
 
-    /**
-     * @param ses Session.
-     * @return Whether portable marshaller is used.
-     */
-    boolean portableMode(GridNioSession ses) {
-        return ctx.cacheObjects().isPortable(marshaller(ses));
-    }
-
     /** {@inheritDoc} */
     @Override public String name() {
         return "TCP binary";
@@ -159,7 +151,6 @@ public class GridTcpRestProtocol extends GridRestProtocolAdapter {
 
         marshMap.put(GridClientOptimizedMarshaller.ID, new GridClientOptimizedMarshaller());
         marshMap.put(GridClientJdkMarshaller.ID, new GridClientJdkMarshaller());
-        marshMap.put((byte)0, ctx.cacheObjects().portableMarshaller());
 
         lsnr.marshallers(marshMap);
     }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d7dac569/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/request/GridRestRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/request/GridRestRequest.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/request/GridRestRequest.java
index f638703..2a80bbc 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/request/GridRestRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/request/GridRestRequest.java
@@ -47,9 +47,6 @@ public class GridRestRequest {
     /** Command. */
     private GridRestCommand cmd;
 
-    /** Portable mode flag. */
-    private boolean portableMode;
-
     /**
      * @return Destination ID.
      */
@@ -146,20 +143,6 @@ public class GridRestRequest {
         this.addr = addr;
     }
 
-    /**
-     * @return Portable mode flag.
-     */
-    public boolean portableMode() {
-        return portableMode;
-    }
-
-    /**
-     * @param portableMode Portable mode flag.
-     */
-    public void portableMode(boolean portableMode) {
-        this.portableMode = portableMode;
-    }
-
     /** {@inheritDoc} */
     @Override public String toString() {
         return S.toString(GridRestRequest.class, this);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d7dac569/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/request/GridRestTaskRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/request/GridRestTaskRequest.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/request/GridRestTaskRequest.java
index a8ad183..5b9bfa3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/request/GridRestTaskRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/request/GridRestTaskRequest.java
@@ -40,9 +40,6 @@ public class GridRestTaskRequest extends GridRestRequest {
     /** Timeout. */
     private long timeout;
 
-    /** Keep portables flag. */
-    private boolean keepPortables;
-
     /**
      * @return Task name, if specified, {@code null} otherwise.
      */
@@ -113,20 +110,6 @@ public class GridRestTaskRequest extends GridRestRequest {
         this.timeout = timeout;
     }
 
-    /**
-     * @return Keep portables flag.
-     */
-    public boolean keepPortables() {
-        return keepPortables;
-    }
-
-    /**
-     * @param keepPortables Keep portables flag.
-     */
-    public void keepPortables(boolean keepPortables) {
-        this.keepPortables = keepPortables;
-    }
-
     /** {@inheritDoc} */
     @Override public String toString() {
         return S.toString(GridRestTaskRequest.class, this, super.toString());

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d7dac569/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheCompactTask.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheCompactTask.java
b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheCompactTask.java
index 207ba15..d422217 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheCompactTask.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheCompactTask.java
@@ -56,31 +56,8 @@ public class VisorCacheCompactTask extends VisorOneNodeTask<Set<String>,
Map<Str
 
         /** {@inheritDoc} */
         @Override protected Map<String, IgniteBiTuple<Integer, Integer>> run(Set<String>
names) {
-            try {
-                final Map<String, IgniteBiTuple<Integer, Integer>> res = new
HashMap<>();
-
-                for (GridCache cache : ignite.cachesx()) {
-                    String cacheName = cache.name();
-
-                    if (names.contains(cacheName)) {
-                        final Set keys = cache.keySet();
-
-                        int before = keys.size(), after = before;
-
-                        for (Object key : keys) {
-                            if (cache.compact(key))
-                                after--;
-                        }
-
-                        res.put(cacheName, new IgniteBiTuple<>(before, after));
-                    }
-                }
-
-                return res;
-            }
-            catch (IgniteCheckedException e) {
-                throw U.convertException(e);
-            }
+            // TODO IGNITE-436 remove command.
+            return Collections.emptyMap();
         }
 
         /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d7dac569/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOnCopyFlagAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOnCopyFlagAbstractSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOnCopyFlagAbstractSelfTest.java
index 20f7f58..4042546 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOnCopyFlagAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOnCopyFlagAbstractSelfTest.java
@@ -35,7 +35,7 @@ import static org.apache.ignite.cache.CacheDistributionMode.*;
 import static org.junit.Assert.*;
 
 /**
- * Tests {@link org.apache.ignite.cache.CacheInterceptor}.
+ * Tests that cache value is copied for get, interceptor and invoke closure.
  */
 public abstract class GridCacheOnCopyFlagAbstractSelfTest extends GridCacheAbstractSelfTest
{
     /** */
@@ -50,6 +50,9 @@ public abstract class GridCacheOnCopyFlagAbstractSelfTest extends GridCacheAbstr
     /** */
     private static Interceptor interceptor;
 
+    /** */
+    private static boolean noInterceptor;
+
     /** {@inheritDoc} */
     @Override protected int gridCount() {
         return 1;
@@ -65,10 +68,19 @@ public abstract class GridCacheOnCopyFlagAbstractSelfTest extends GridCacheAbstr
     }
 
     /** {@inheritDoc} */
+    @Override protected void beforeTest() throws Exception {
+        super.beforeTest();
+
+        noInterceptor = false;
+    }
+
+    /** {@inheritDoc} */
     @Override protected void afterTest() throws Exception {
         super.afterTest();
 
-        interceptor.delegate(new CacheInterceptorAdapter<TestKey, TestValue>());
+        noInterceptor = true;
+
+        interceptor.delegate(null);
 
         for (int i = 0; i < gridCount(); i++)
             cache(i, null).clearLocally();
@@ -90,6 +102,7 @@ public abstract class GridCacheOnCopyFlagAbstractSelfTest extends GridCacheAbstr
     }
 
     /** {@inheritDoc} */
+    @SuppressWarnings("unchecked")
     @Override protected CacheConfiguration cacheConfiguration(String gridName) throws Exception
{
         CacheConfiguration ccfg = super.cacheConfiguration(gridName);
 
@@ -251,6 +264,8 @@ public abstract class GridCacheOnCopyFlagAbstractSelfTest extends GridCacheAbstr
      * @throws Exception If failed.
      */
     public void testPutGet() throws Exception {
+        noInterceptor = true;
+
         IgniteCache<TestKey, TestValue> cache = grid(0).jcache(null);
 
         Map<TestKey, TestValue> map = new HashMap<>();
@@ -292,6 +307,52 @@ public abstract class GridCacheOnCopyFlagAbstractSelfTest extends GridCacheAbstr
     }
 
     /**
+     * @throws Exception If failed.
+     */
+    public void testPutGetByteArray() throws Exception {
+        noInterceptor = true;
+
+        IgniteCache<TestKey, byte[]> cache = grid(0).jcache(null);
+
+        Map<TestKey, byte[]> map = new HashMap<>();
+
+        for (int i = 0; i < ITER_CNT; i++) {
+            TestKey key = new TestKey(i, i);
+            byte[] val = new byte[10];
+
+            cache.put(key, val);
+
+            map.put(key, val);
+        }
+
+        GridCacheAdapter cache0 = internalCache(cache);
+
+        GridCacheContext cctx = cache0.context();
+
+        for (Map.Entry<TestKey, byte[]> e : map.entrySet()) {
+            GridCacheEntryEx entry = cache0.peekEx(e.getKey());
+
+            assertNotNull("No entry for key: " + e.getKey(), entry);
+
+            TestKey key0 = entry.key().value(cctx.cacheObjectContext(), false);
+
+            assertNotSame(key0, e.getKey());
+
+            TestKey key1 = entry.key().value(cctx.cacheObjectContext(), true);
+
+            assertNotSame(key0, key1);
+
+            byte[] val0 = entry.rawGet().value(cctx.cacheObjectContext(), false);
+
+            assertNotSame(val0, e.getValue());
+
+            byte[] val1 = entry.rawGet().value(cctx.cacheObjectContext(), true);
+
+            assertNotSame(val0, val1);
+        }
+    }
+
+    /**
      *
      */
     public static class TestKey implements Externalizable {
@@ -444,33 +505,44 @@ public abstract class GridCacheOnCopyFlagAbstractSelfTest extends GridCacheAbstr
     /**
      *
      */
-    private class Interceptor implements CacheInterceptor<TestKey, TestValue> {
+    private class Interceptor implements CacheInterceptor<TestKey, Object> {
         /** */
         CacheInterceptor<TestKey, TestValue> delegate = new CacheInterceptorAdapter<>();
 
         /** {@inheritDoc} */
-        @Override public TestValue onGet(TestKey key, @Nullable TestValue val) {
-            return delegate.onGet(key, val);
+        @Override public Object onGet(TestKey key, @Nullable Object val) {
+            if (!noInterceptor)
+                return delegate.onGet(key, (TestValue)val);
+
+            return val;
         }
 
         /** {@inheritDoc} */
-        @Override public TestValue onBeforePut(Cache.Entry<TestKey, TestValue> entry,
TestValue newVal) {
-            return delegate.onBeforePut(entry, newVal);
+        @Override public Object onBeforePut(Cache.Entry<TestKey, Object> entry, Object
newVal) {
+            if (!noInterceptor)
+                return delegate.onBeforePut((Cache.Entry)entry, (TestValue)newVal);
+
+            return newVal;
         }
 
         /** {@inheritDoc} */
-        @Override public void onAfterPut(Cache.Entry<TestKey, TestValue> entry) {
-            delegate.onAfterPut(entry);
+        @Override public void onAfterPut(Cache.Entry<TestKey, Object> entry) {
+            if (!noInterceptor)
+                delegate.onAfterPut((Cache.Entry)entry);
         }
 
         /** {@inheritDoc} */
-        @Override public IgniteBiTuple<Boolean, TestValue> onBeforeRemove(Cache.Entry<TestKey,
TestValue> entry) {
-            return delegate.onBeforeRemove(entry);
+        @Override public IgniteBiTuple<Boolean, Object> onBeforeRemove(Cache.Entry<TestKey,
Object> entry) {
+            if (!noInterceptor)
+                return (IgniteBiTuple)delegate.onBeforeRemove((Cache.Entry)entry);
+
+            return new IgniteBiTuple<>(false, entry.getValue());
         }
 
         /** {@inheritDoc} */
-        @Override public void onAfterRemove(Cache.Entry<TestKey, TestValue> entry)
{
-            delegate.onAfterRemove(entry);
+        @Override public void onAfterRemove(Cache.Entry<TestKey, Object> entry) {
+            if (!noInterceptor)
+                delegate.onAfterRemove((Cache.Entry)entry);
         }
 
         /**

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d7dac569/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestEntryEx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestEntryEx.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestEntryEx.java
index d967a51..bd62b8d 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestEntryEx.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestEntryEx.java
@@ -396,14 +396,6 @@ public class GridCacheTestEntryEx extends GridMetadataAwareAdapter implements
Gr
     }
 
     /** @inheritDoc */
-    @Override public boolean compact(@Nullable CacheEntryPredicate[] filter)
-        throws GridCacheEntryRemovedException, IgniteCheckedException {
-        assert false;
-
-        return false;
-    }
-
-    /** @inheritDoc */
     @Override public boolean evictInternal(boolean swap, GridCacheVersion obsoleteVer,
         @Nullable CacheEntryPredicate[] filter) {
         assert false;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d7dac569/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCachePartitionedReloadAllAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCachePartitionedReloadAllAbstractSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCachePartitionedReloadAllAbstractSelfTest.java
index bce3072..8522c81 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCachePartitionedReloadAllAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCachePartitionedReloadAllAbstractSelfTest.java
@@ -205,8 +205,7 @@ public abstract class GridCachePartitionedReloadAllAbstractSelfTest extends
Grid
 
         for (IgniteCache<Integer, String> cache : caches) {
             for (Integer key : map.keySet()) {
-                if (aff.isPrimaryOrBackup(grid(caches.indexOf(cache)).localNode(), key) ||
-                    nearEnabled())
+                if (aff.isPrimaryOrBackup(grid(caches.indexOf(cache)).localNode(), key))
                     assertEquals(map.get(key), cache.localPeek(key));
                 else
                     assertNull(cache.localPeek(key));

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d7dac569/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractQuerySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractQuerySelfTest.java
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractQuerySelfTest.java
index 6c9ca23..1748fd9 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractQuerySelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractQuerySelfTest.java
@@ -470,25 +470,14 @@ public abstract class GridCacheAbstractQuerySelfTest extends GridCommonAbstractT
         cache.putx(1, new ObjectValue("test", 1));
         cache.putx(2, new ObjectValue("test", 2));
 
-        CacheEntryPredicate p = new  CacheEntrySerializablePredicate(new CacheEntryPredicateAdapter()
{
-            @Override public boolean apply(GridCacheEntryEx e) {
-                ObjectValue val = CU.value(e.rawGet(), e.context(), false);
-
-                return val != null && val.intVal == 1;
-            }
-        });
-
-        CacheProjection<Integer, ObjectValue> cachePrj = ((IgniteKernal)grid(0))
-            .<Integer, ObjectValue>cache(null).projection(p);
-
         CacheQuery<Map.Entry<Integer, ObjectValue>> qry =
-            cachePrj.queries().createFullTextQuery(ObjectValue.class, "test");
+            cache.queries().createFullTextQuery(ObjectValue.class, "test");
 
         CacheQueryFuture<Map.Entry<Integer, ObjectValue>> iter = qry.execute();
 
         assert iter != null;
 
-        int expCnt = 1;
+        int expCnt = 2;
 
         for (int i = 0; i < expCnt; i++)
             assert iter.next() != null;
@@ -850,36 +839,6 @@ public abstract class GridCacheAbstractQuerySelfTest extends GridCommonAbstractT
     /**
      * @throws Exception If failed.
      */
-    public void testReduceQueryOnProjection() throws Exception {
-        CacheProjection<String, Integer> c = ((IgniteKernal)ignite).cache(null);
-
-        assert c.putx("key1", 1);
-        assert c.putx("key2", 2);
-        assert c.putx("key3", 3);
-        assert c.putx("key4", 4);
-        assert c.putx("key5", 5);
-
-        // Filter values less than 3.
-        CacheEntryPredicate p = new  CacheEntrySerializablePredicate(new CacheEntryPredicateAdapter()
{
-            @Override public boolean apply(GridCacheEntryEx e) {
-                Integer val = CU.value(e.rawGet(), e.context(), false);
-
-                return val != null && val > 3;
-            }
-        });
-
-        CacheProjection<String, Integer> cachePrj = ((IgniteKernal)ignite).<String,
Integer>cache(null).projection(p);
-
-        CacheQuery<Map.Entry<String, Integer>> q = cachePrj.queries().createSqlQuery(Integer.class,
"_val > 2");
-
-        Collection<Integer> res = q.execute(new SumRemoteReducer()).get();
-
-        assertEquals(9, F.sumInt(res));
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
     public void testEmptyObject() throws Exception {
         GridCache<EmptyObject, EmptyObject> cache = ((IgniteKernal)ignite).cache(null);
 


Mime
View raw message