You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ag...@apache.org on 2015/10/22 12:31:13 UTC

[1/5] ignite git commit: ignite-950 - Merge portable API changes.

Repository: ignite
Updated Branches:
  refs/heads/ignite-950-new [created] 54e0b63a3


ignite-950 - Merge portable API changes.


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

Branch: refs/heads/ignite-950-new
Commit: 80c71a89695008999203c9be21673c073bcd3be4
Parents: 962fcce e7eb2b3
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Thu Oct 15 12:02:37 2015 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Thu Oct 15 12:02:37 2015 +0300

----------------------------------------------------------------------
 examples/config/example-default.xml             |   76 +
 examples/config/example-ignite.xml              |   56 +-
 .../config/portable/example-ignite-portable.xml |   44 +
 .../ignite/examples/portable/Address.java       |   72 +
 .../ignite/examples/portable/Employee.java      |   93 +
 .../ignite/examples/portable/EmployeeKey.java   |   90 +
 .../portable/ExamplePortableNodeStartup.java    |   36 +
 .../ignite/examples/portable/Organization.java  |   93 +
 .../examples/portable/OrganizationType.java     |   32 +
 ...mputeClientPortableTaskExecutionExample.java |  154 +
 .../portable/computegrid/ComputeClientTask.java |  116 +
 .../portable/computegrid/package-info.java      |   21 +
 .../CacheClientPortablePutGetExample.java       |  230 ++
 .../CacheClientPortableQueryExample.java        |  325 ++
 .../portable/datagrid/package-info.java         |   21 +
 .../ignite/examples/portable/package-info.java  |   21 +
 .../CacheClientPortableExampleTest.java         |   46 +
 .../ComputeClientPortableExampleTest.java       |   37 +
 .../testsuites/IgniteExamplesSelfTestSuite.java |    6 +
 modules/core/pom.xml                            |   21 +
 .../src/main/java/org/apache/ignite/Ignite.java |    7 +
 .../java/org/apache/ignite/IgniteCache.java     |   44 +-
 .../java/org/apache/ignite/IgnitePortables.java |  370 ++
 .../configuration/CacheConfiguration.java       |   62 +-
 .../org/apache/ignite/internal/IgniteEx.java    |    9 -
 .../apache/ignite/internal/IgniteKernal.java    |    6 +
 .../ignite/internal/IgniteNodeAttributes.java   |    5 +-
 .../discovery/GridDiscoveryManager.java         |   10 +
 .../portable/GridPortableMarshaller.java        |    2 +-
 .../portable/PortableClassDescriptor.java       |   10 +-
 .../internal/portable/PortableContext.java      |   14 +-
 .../portable/PortableMetaDataCollector.java     |    6 +-
 .../portable/PortableMetaDataHandler.java       |    4 +-
 .../internal/portable/PortableMetaDataImpl.java |   14 +-
 .../internal/portable/PortableObjectEx.java     |    6 +-
 .../internal/portable/PortableObjectImpl.java   |    6 +-
 .../portable/PortableObjectOffheapImpl.java     |    6 +-
 .../internal/portable/PortableRawReaderEx.java  |    4 +-
 .../internal/portable/PortableRawWriterEx.java  |    4 +-
 .../portable/PortableReaderContext.java         |    2 +-
 .../internal/portable/PortableReaderExImpl.java |   10 +-
 .../ignite/internal/portable/PortableUtils.java |    2 +-
 .../internal/portable/PortableWriterExImpl.java |   11 +-
 .../internal/portable/api/IgnitePortables.java  |  362 --
 .../internal/portable/api/PortableBuilder.java  |  136 -
 .../portable/api/PortableException.java         |   57 -
 .../internal/portable/api/PortableIdMapper.java |   54 -
 .../api/PortableInvalidClassException.java      |   58 -
 .../portable/api/PortableMarshalAware.java      |   48 -
 .../portable/api/PortableMarshaller.java        |  352 --
 .../internal/portable/api/PortableMetadata.java |   60 -
 .../internal/portable/api/PortableObject.java   |  152 -
 .../portable/api/PortableProtocolVersion.java   |   41 -
 .../portable/api/PortableRawReader.java         |  234 --
 .../portable/api/PortableRawWriter.java         |  219 -
 .../internal/portable/api/PortableReader.java   |  284 --
 .../portable/api/PortableSerializer.java        |   47 -
 .../portable/api/PortableTypeConfiguration.java |  195 -
 .../internal/portable/api/PortableWriter.java   |  266 --
 .../portable/builder/PortableBuilderEnum.java   |    2 +-
 .../portable/builder/PortableBuilderImpl.java   |   14 +-
 .../portable/builder/PortableBuilderReader.java |    2 +-
 .../builder/PortableBuilderSerializer.java      |    2 +-
 .../builder/PortableEnumArrayLazyValue.java     |    4 +-
 .../builder/PortableObjectArrayLazyValue.java   |    2 +-
 .../builder/PortablePlainPortableObject.java    |    2 +-
 .../streams/PortableAbstractInputStream.java    |    2 +-
 .../processors/cache/GridCacheProcessor.java    |    7 +
 .../processors/cache/IgniteCacheProxy.java      |    5 +
 .../CacheDefaultPortableAffinityKeyMapper.java  |    2 +-
 .../portable/CacheObjectPortableContext.java    |    2 +-
 .../portable/CacheObjectPortableProcessor.java  |    8 +-
 .../CacheObjectPortableProcessorImpl.java       |   12 +-
 .../cache/portable/IgnitePortablesImpl.java     |   10 +-
 .../cache/store/CacheOsStoreManager.java        |    4 +-
 .../dotnet/PlatformDotNetConfiguration.java     |   12 +-
 .../PlatformDotNetPortableConfiguration.java    |   12 +-
 ...PlatformDotNetPortableTypeConfiguration.java |   12 +-
 .../marshaller/portable/PortableMarshaller.java |  358 ++
 .../marshaller/portable/package-info.java       |   22 +
 .../apache/ignite/portable/PortableBuilder.java |  137 +
 .../ignite/portable/PortableException.java      |   57 +
 .../ignite/portable/PortableIdMapper.java       |   56 +
 .../portable/PortableInvalidClassException.java |   58 +
 .../ignite/portable/PortableMarshalAware.java   |   48 +
 .../ignite/portable/PortableMetadata.java       |   61 +
 .../apache/ignite/portable/PortableObject.java  |  154 +
 .../portable/PortableProtocolVersion.java       |   41 +
 .../ignite/portable/PortableRawReader.java      |  234 ++
 .../ignite/portable/PortableRawWriter.java      |  219 +
 .../apache/ignite/portable/PortableReader.java  |  284 ++
 .../ignite/portable/PortableSerializer.java     |   49 +
 .../portable/PortableTypeConfiguration.java     |  196 +
 .../apache/ignite/portable/PortableWriter.java  |  266 ++
 .../apache/ignite/portable/package-info.java    |   22 +
 .../resources/META-INF/classnames.properties    |    8 +-
 .../GridDiscoveryManagerAttributesSelfTest.java |   45 +
 .../GridPortableAffinityKeySelfTest.java        |  218 +
 .../GridPortableBuilderAdditionalSelfTest.java  | 1226 ++++++
 .../portable/GridPortableBuilderSelfTest.java   | 1021 +++++
 ...eBuilderStringAsCharsAdditionalSelfTest.java |   28 +
 ...ridPortableBuilderStringAsCharsSelfTest.java |   28 +
 ...idPortableMarshallerCtxDisabledSelfTest.java |  256 ++
 .../GridPortableMarshallerSelfTest.java         | 3807 ++++++++++++++++++
 .../GridPortableMetaDataDisabledSelfTest.java   |  238 ++
 .../portable/GridPortableMetaDataSelfTest.java  |  371 ++
 .../portable/GridPortableWildcardsSelfTest.java |  482 +++
 .../GridPortableMarshalerAwareTestClass.java    |   67 +
 .../mutabletest/GridPortableTestClasses.java    |  434 ++
 .../portable/mutabletest/package-info.java      |   22 +
 .../ignite/internal/portable/package-info.java  |   22 +
 .../portable/test/GridPortableTestClass1.java   |   28 +
 .../portable/test/GridPortableTestClass2.java   |   24 +
 .../internal/portable/test/package-info.java    |   22 +
 .../test/subpackage/GridPortableTestClass3.java |   24 +
 .../portable/test/subpackage/package-info.java  |   22 +
 ...ClientNodePortableMetadataMultinodeTest.java |  295 ++
 ...GridCacheClientNodePortableMetadataTest.java |  286 ++
 ...ableObjectsAbstractDataStreamerSelfTest.java |  190 +
 ...bleObjectsAbstractMultiThreadedSelfTest.java |  231 ++
 ...ridCachePortableObjectsAbstractSelfTest.java |  978 +++++
 .../GridCachePortableStoreAbstractSelfTest.java |  297 ++
 .../GridCachePortableStoreObjectsSelfTest.java  |   55 +
 ...GridCachePortableStorePortablesSelfTest.java |   66 +
 ...ridPortableCacheEntryMemorySizeSelfTest.java |   55 +
 ...leDuplicateIndexObjectsAbstractSelfTest.java |  158 +
 .../DataStreamProcessorPortableSelfTest.java    |   66 +
 .../GridDataStreamerImplSelfTest.java           |  345 ++
 ...ridCacheAffinityRoutingPortableSelfTest.java |   47 +
 ...lyPortableDataStreamerMultiNodeSelfTest.java |   29 +
 ...rtableDataStreamerMultithreadedSelfTest.java |   47 +
 ...artitionedOnlyPortableMultiNodeSelfTest.java |   28 +
 ...tionedOnlyPortableMultithreadedSelfTest.java |   47 +
 .../GridCacheMemoryModePortableSelfTest.java    |   36 +
 ...acheOffHeapTieredAtomicPortableSelfTest.java |   47 +
 ...eapTieredEvictionAtomicPortableSelfTest.java |   95 +
 ...heOffHeapTieredEvictionPortableSelfTest.java |   95 +
 .../GridCacheOffHeapTieredPortableSelfTest.java |   47 +
 ...ateIndexObjectPartitionedAtomicSelfTest.java |   38 +
 ...xObjectPartitionedTransactionalSelfTest.java |   41 +
 ...AtomicNearDisabledOffheapTieredSelfTest.java |   29 +
 ...rtableObjectsAtomicNearDisabledSelfTest.java |   51 +
 ...tableObjectsAtomicOffheapTieredSelfTest.java |   29 +
 .../GridCachePortableObjectsAtomicSelfTest.java |   51 +
 ...tionedNearDisabledOffheapTieredSelfTest.java |   30 +
 ...eObjectsPartitionedNearDisabledSelfTest.java |   51 +
 ...ObjectsPartitionedOffheapTieredSelfTest.java |   30 +
 ...CachePortableObjectsPartitionedSelfTest.java |   51 +
 ...sNearPartitionedByteArrayValuesSelfTest.java |   41 +
 ...sPartitionedOnlyByteArrayValuesSelfTest.java |   42 +
 ...dCachePortableObjectsReplicatedSelfTest.java |   51 +
 ...CachePortableObjectsAtomicLocalSelfTest.java |   32 +
 ...rtableObjectsLocalOffheapTieredSelfTest.java |   29 +
 .../GridCachePortableObjectsLocalSelfTest.java  |   51 +
 .../ignite/testframework/junits/IgniteMock.java |    8 +-
 .../multijvm/IgniteCacheProcessProxy.java       |    7 +-
 .../junits/multijvm/IgniteProcessProxy.java     |    2 +-
 .../IgnitePortableCacheFullApiTestSuite.java    |   37 +
 .../IgnitePortableCacheTestSuite.java           |  103 +
 .../IgnitePortableObjectsTestSuite.java         |   92 +
 .../ignite/portable/test1/1.1/test1-1.1.jar     |  Bin 0 -> 2548 bytes
 .../ignite/portable/test1/1.1/test1-1.1.pom     |    9 +
 .../portable/test1/maven-metadata-local.xml     |   12 +
 .../ignite/portable/test2/1.1/test2-1.1.jar     |  Bin 0 -> 1361 bytes
 .../ignite/portable/test2/1.1/test2-1.1.pom     |    9 +
 .../portable/test2/maven-metadata-local.xml     |   12 +
 .../HadoopDefaultMapReducePlannerSelfTest.java  |    6 -
 .../IgnitePortableCacheQueryTestSuite.java      |  117 +
 .../platform/PlatformContextImpl.java           |    4 +-
 .../platform/compute/PlatformCompute.java       |    2 +-
 .../cpp/PlatformCppConfigurationClosure.java    |    2 +-
 .../PlatformDotNetConfigurationClosure.java     |    6 +-
 .../Config/Compute/compute-grid1.xml            |    8 +-
 .../PlatformComputePortableArgTask.java         |    8 +-
 .../org/apache/ignite/IgniteSpringBean.java     |    7 +
 parent/pom.xml                                  |   10 +
 176 files changed, 17425 insertions(+), 2763 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/80c71a89/modules/core/src/main/java/org/apache/ignite/IgnitePortables.java
----------------------------------------------------------------------
diff --cc modules/core/src/main/java/org/apache/ignite/IgnitePortables.java
index 0000000,ee0a4ec..1c63df7
mode 000000,100644..100644
--- a/modules/core/src/main/java/org/apache/ignite/IgnitePortables.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgnitePortables.java
@@@ -1,0 -1,370 +1,370 @@@
+ /*
+  * 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;
+ 
+ import java.sql.Timestamp;
+ import java.util.ArrayList;
+ import java.util.Collection;
+ import java.util.Date;
+ import java.util.HashMap;
+ import java.util.LinkedList;
+ import java.util.TreeMap;
+ import java.util.UUID;
+ import org.apache.ignite.marshaller.portable.PortableMarshaller;
+ import org.apache.ignite.portable.PortableBuilder;
+ import org.apache.ignite.portable.PortableException;
+ import org.apache.ignite.portable.PortableIdMapper;
+ import org.apache.ignite.portable.PortableMarshalAware;
+ import org.apache.ignite.portable.PortableMetadata;
+ import org.apache.ignite.portable.PortableObject;
+ import org.apache.ignite.portable.PortableSerializer;
+ import org.apache.ignite.portable.PortableTypeConfiguration;
+ import org.jetbrains.annotations.Nullable;
+ 
+ /**
+  * Defines portable objects functionality. With portable objects you are able to:
+  * <ul>
+  * <li>Seamlessly interoperate between Java, .NET, and C++.</li>
+  * <li>Make any object portable with zero code change to your existing code.</li>
+  * <li>Nest portable objects within each other.</li>
+  * <li>Automatically handle {@code circular} or {@code null} references.</li>
+  * <li>Automatically convert collections and maps between Java, .NET, and C++.</li>
+  * <li>
+  *      Optionally avoid deserialization of objects on the server side
+  *      (objects are stored in {@link PortableObject} format).
+  * </li>
+  * <li>Avoid need to have concrete class definitions on the server side.</li>
+  * <li>Dynamically change structure of the classes without having to restart the cluster.</li>
+  * <li>Index into portable objects for querying purposes.</li>
+  * </ul>
+  * <h1 class="header">Working With Portables Directly</h1>
+  * Once an object is defined as portable,
+  * Ignite will always store it in memory in the portable (i.e. binary) format.
+  * User can choose to work either with the portable format or with the deserialized form
+  * (assuming that class definitions are present in the classpath).
+  * <p>
+  * To work with the portable format directly, user should create a special cache projection
 - * using {@link IgniteCache#withKeepPortable()} method and then retrieve individual fields as needed:
++ * using IgniteCache.withKeepPortable() method and then retrieve individual fields as needed:
+  * <pre name=code class=java>
+  * IgniteCache&lt;PortableObject, PortableObject&gt; prj = cache.withKeepPortable();
+  *
+  * // Convert instance of MyKey to portable format.
+  * // We could also use PortableBuilder to create the key in portable format directly.
+  * PortableObject key = grid.portables().toPortable(new MyKey());
+  *
+  * PortableObject val = prj.get(key);
+  *
+  * String field = val.field("myFieldName");
+  * </pre>
+  * Alternatively, if we have class definitions in the classpath, we may choose to work with deserialized
+  * typed objects at all times. In this case we do incur the deserialization cost. However, if
+  * {@link PortableMarshaller#isKeepDeserialized()} is {@code true} then Ignite will only deserialize on the first access
+  * and will cache the deserialized object, so it does not have to be deserialized again:
+  * <pre name=code class=java>
+  * IgniteCache&lt;MyKey.class, MyValue.class&gt; cache = grid.cache(null);
+  *
+  * MyValue val = cache.get(new MyKey());
+  *
+  * // Normal java getter.
+  * String fieldVal = val.getMyFieldName();
+  * </pre>
+  * If we used, for example, one of the automatically handled portable types for a key, like integer,
+  * and still wanted to work with binary portable format for values, then we would declare cache projection
+  * as follows:
+  * <pre name=code class=java>
+  * IgniteCache&lt;Integer.class, PortableObject&gt; prj = cache.withKeepPortable();
+  * </pre>
+  * <h1 class="header">Automatic Portable Types</h1>
+  * Note that only portable classes are converted to {@link PortableObject} format. Following
+  * classes are never converted (e.g., {@link #toPortable(Object)} method will return original
+  * object, and instances of these classes will be stored in cache without changes):
+  * <ul>
+  *     <li>All primitives (byte, int, ...) and there boxed versions (Byte, Integer, ...)</li>
+  *     <li>Arrays of primitives (byte[], int[], ...)</li>
+  *     <li>{@link String} and array of {@link String}s</li>
+  *     <li>{@link UUID} and array of {@link UUID}s</li>
+  *     <li>{@link Date} and array of {@link Date}s</li>
+  *     <li>{@link Timestamp} and array of {@link Timestamp}s</li>
+  *     <li>Enums and array of enums</li>
+  *     <li>
+  *         Maps, collections and array of objects (but objects inside
+  *         them will still be converted if they are portable)
+  *     </li>
+  * </ul>
+  * <h1 class="header">Working With Maps and Collections</h1>
+  * All maps and collections in the portable objects are serialized automatically. When working
+  * with different platforms, e.g. C++ or .NET, Ignite will automatically pick the most
+  * adequate collection or map in either language. For example, {@link ArrayList} in Java will become
+  * {@code List} in C#, {@link LinkedList} in Java is {@link LinkedList} in C#, {@link HashMap}
+  * in Java is {@code Dictionary} in C#, and {@link TreeMap} in Java becomes {@code SortedDictionary}
+  * in C#, etc.
+  * <h1 class="header">Building Portable Objects</h1>
+  * Ignite comes with {@link PortableBuilder} which allows to build portable objects dynamically:
+  * <pre name=code class=java>
+  * PortableBuilder builder = Ignition.ignite().portables().builder();
+  *
+  * builder.typeId("MyObject");
+  *
+  * builder.stringField("fieldA", "A");
+  * build.intField("fieldB", "B");
+  *
+  * PortableObject portableObj = builder.build();
+  * </pre>
+  * For the cases when class definition is present
+  * in the class path, it is also possible to populate a standard POJO and then
+  * convert it to portable format, like so:
+  * <pre name=code class=java>
+  * MyObject obj = new MyObject();
+  *
+  * obj.setFieldA("A");
+  * obj.setFieldB(123);
+  *
+  * PortableObject portableObj = Ignition.ignite().portables().toPortable(obj);
+  * </pre>
+  * NOTE: you don't need to convert typed objects to portable format before storing
+  * them in cache, Ignite will do that automatically.
+  * <h1 class="header">Portable Metadata</h1>
+  * Even though Ignite portable protocol only works with hash codes for type and field names
+  * to achieve better performance, Ignite provides metadata for all portable types which
+  * can be queried ar runtime via any of the {@link IgnitePortables#metadata(Class)}
+  * methods. Having metadata also allows for proper formatting of {@code PortableObject#toString()} method,
+  * even when portable objects are kept in binary format only, which may be necessary for audit reasons.
+  * <h1 class="header">Dynamic Structure Changes</h1>
+  * Since objects are always cached in the portable binary format, server does not need to
+  * be aware of the class definitions. Moreover, if class definitions are not present or not
+  * used on the server, then clients can continuously change the structure of the portable
+  * objects without having to restart the cluster. For example, if one client stores a
+  * certain class with fields A and B, and another client stores the same class with
+  * fields B and C, then the server-side portable object will have the fields A, B, and C.
+  * As the structure of a portable object changes, the new fields become available for SQL queries
+  * automatically.
+  * <h1 class="header">Configuration</h1>
+  * By default all your objects are considered as portables and no specific configuration is needed.
+  * However, in some cases, like when an object is used by both Java and .Net, you may need to specify portable objects
+  * explicitly by calling {@link PortableMarshaller#setClassNames(Collection)}.
+  * The only requirement Ignite imposes is that your object has an empty
+  * constructor. Note, that since server side does not have to know the class definition,
+  * you only need to list portable objects in configuration on the client side. However, if you
+  * list them on the server side as well, then you get the ability to deserialize portable objects
+  * into concrete types on the server as well as on the client.
+  * <p>
+  * Here is an example of portable configuration (note that star (*) notation is supported):
+  * <pre name=code class=xml>
+  * ...
+  * &lt;!-- Explicit portable objects configuration. --&gt;
+  * &lt;property name="marshaller"&gt;
+  *     &lt;bean class="org.apache.ignite.marshaller.portable.PortableMarshaller"&gt;
+  *         &lt;property name="classNames"&gt;
+  *             &lt;list&gt;
+  *                 &lt;value&gt;my.package.for.portable.objects.*&lt;/value&gt;
+  *                 &lt;value&gt;org.apache.ignite.examples.client.portable.Employee&lt;/value&gt;
+  *             &lt;/list&gt;
+  *         &lt;/property&gt;
+  *     &lt;/bean&gt;
+  * &lt;/property&gt;
+  * ...
+  * </pre>
+  * or from code:
+  * <pre name=code class=java>
+  * IgniteConfiguration cfg = new IgniteConfiguration();
+  *
+  * PortableMarshaller marsh = new PortableMarshaller();
+  *
+  * marsh.setClassNames(Arrays.asList(
+  *     Employee.class.getName(),
+  *     Address.class.getName())
+  * );
+  *
+  * cfg.setMarshaller(marsh);
+  * </pre>
+  * You can also specify class name for a portable object via {@link PortableTypeConfiguration}.
+  * Do it in case if you need to override other configuration properties on per-type level, like
+  * ID-mapper, or serializer.
+  * <h1 class="header">Custom Affinity Keys</h1>
+  * Often you need to specify an alternate key (not the cache key) for affinity routing whenever
+  * storing objects in cache. For example, if you are caching {@code Employee} object with
+  * {@code Organization}, and want to colocate employees with organization they work for,
+  * so you can process them together, you need to specify an alternate affinity key.
+  * With portable objects you would have to do it as following:
+  * <pre name=code class=xml>
+  * &lt;property name="marshaller"&gt;
+  *     &lt;bean class="org.gridgain.grid.marshaller.portable.PortableMarshaller"&gt;
+  *         ...
+  *         &lt;property name="typeConfigurations"&gt;
+  *             &lt;list&gt;
+  *                 &lt;bean class="org.apache.ignite.portable.PortableTypeConfiguration"&gt;
+  *                     &lt;property name="className" value="org.apache.ignite.examples.client.portable.EmployeeKey"/&gt;
+  *                     &lt;property name="affinityKeyFieldName" value="organizationId"/&gt;
+  *                 &lt;/bean&gt;
+  *             &lt;/list&gt;
+  *         &lt;/property&gt;
+  *         ...
+  *     &lt;/bean&gt;
+  * &lt;/property&gt;
+  * </pre>
+  * <h1 class="header">Serialization</h1>
+  * Serialization and deserialization works out-of-the-box in Ignite. However, you can provide your own custom
+  * serialization logic by optionally implementing {@link PortableMarshalAware} interface, like so:
+  * <pre name=code class=java>
+  * public class Address implements PortableMarshalAware {
+  *     private String street;
+  *     private int zip;
+  *
+  *     // Empty constructor required for portable deserialization.
+  *     public Address() {}
+  *
+  *     &#64;Override public void writePortable(PortableWriter writer) throws PortableException {
+  *         writer.writeString("street", street);
+  *         writer.writeInt("zip", zip);
+  *     }
+  *
+  *     &#64;Override public void readPortable(PortableReader reader) throws PortableException {
+  *         street = reader.readString("street");
+  *         zip = reader.readInt("zip");
+  *     }
+  * }
+  * </pre>
+  * Alternatively, if you cannot change class definitions, you can provide custom serialization
+  * logic in {@link PortableSerializer} either globally in {@link PortableMarshaller} or
+  * for a specific type via {@link PortableTypeConfiguration} instance.
+  * <p>
+  * Similar to java serialization you can use {@code writeReplace()} and {@code readResolve()} methods.
+  * <ul>
+  *     <li>
+  *         {@code readResolve} is defined as follows: {@code ANY-ACCESS-MODIFIER Object readResolve()}.
+  *         It may be used to replace the de-serialized object by another one of your choice.
+  *     </li>
+  *     <li>
+  *          {@code writeReplace} is defined as follows: {@code ANY-ACCESS-MODIFIER Object writeReplace()}. This method
+  *          allows the developer to provide a replacement object that will be serialized instead of the original one.
+  *     </li>
+  * </ul>
+  *
+  * <h1 class="header">Custom ID Mappers</h1>
+  * Ignite implementation uses name hash codes to generate IDs for class names or field names
+  * internally. However, in cases when you want to provide your own ID mapping schema,
+  * you can provide your own {@link PortableIdMapper} implementation.
+  * <p>
+  * ID-mapper may be provided either globally in {@link PortableMarshaller},
+  * or for a specific type via {@link PortableTypeConfiguration} instance.
+  * <h1 class="header">Query Indexing</h1>
+  * Portable objects can be indexed for querying by specifying index fields in
+  * {@link org.apache.ignite.cache.CacheTypeMetadata} inside of specific
+  * {@link org.apache.ignite.configuration.CacheConfiguration} instance,
+  * like so:
+  * <pre name=code class=xml>
+  * ...
+  * &lt;bean class="org.apache.ignite.cache.CacheConfiguration"&gt;
+  *     ...
+  *     &lt;property name="typeMetadata"&gt;
+  *         &lt;list&gt;
+  *             &lt;bean class="CacheTypeMetadata"&gt;
+  *                 &lt;property name="type" value="Employee"/&gt;
+  *
+  *                 &lt;!-- Fields to index in ascending order. --&gt;
+  *                 &lt;property name="ascendingFields"&gt;
+  *                     &lt;map&gt;
+  *                     &lt;entry key="name" value="java.lang.String"/&gt;
+  *
+  *                         &lt;!-- Nested portable objects can also be indexed. --&gt;
+  *                         &lt;entry key="address.zip" value="java.lang.Integer"/&gt;
+  *                     &lt;/map&gt;
+  *                 &lt;/property&gt;
+  *             &lt;/bean&gt;
+  *         &lt;/list&gt;
+  *     &lt;/property&gt;
+  * &lt;/bean&gt;
+  * </pre>
+  */
+ public interface IgnitePortables {
+     /**
+      * Gets type ID for given type name.
+      *
+      * @param typeName Type name.
+      * @return Type ID.
+      */
+     public int typeId(String typeName);
+ 
+     /**
+      * Converts provided object to instance of {@link PortableObject}.
+      *
+      * @param obj Object to convert.
+      * @return Converted object.
+      * @throws PortableException In case of error.
+      */
+     public <T> T toPortable(@Nullable Object obj) throws PortableException;
+ 
+     /**
+      * Creates new portable builder.
+      *
+      * @param typeId ID of the type.
+      * @return Newly portable builder.
+      */
+     public PortableBuilder builder(int typeId);
+ 
+     /**
+      * Creates new portable builder.
+      *
+      * @param typeName Type name.
+      * @return Newly portable builder.
+      */
+     public PortableBuilder builder(String typeName);
+ 
+     /**
+      * Creates portable builder initialized by existing portable object.
+      *
+      * @param portableObj Portable object to initialize builder.
+      * @return Portable builder.
+      */
+     public PortableBuilder builder(PortableObject portableObj);
+ 
+     /**
+      * Gets metadata for provided class.
+      *
+      * @param cls Class.
+      * @return Metadata.
+      * @throws PortableException In case of error.
+      */
+     @Nullable public PortableMetadata metadata(Class<?> cls) throws PortableException;
+ 
+     /**
+      * Gets metadata for provided class name.
+      *
+      * @param typeName Type name.
+      * @return Metadata.
+      * @throws PortableException In case of error.
+      */
+     @Nullable public PortableMetadata metadata(String typeName) throws PortableException;
+ 
+     /**
+      * Gets metadata for provided type ID.
+      *
+      * @param typeId Type ID.
+      * @return Metadata.
+      * @throws PortableException In case of error.
+      */
+     @Nullable public PortableMetadata metadata(int typeId) throws PortableException;
+ 
+     /**
+      * Gets metadata for all known types.
+      *
+      * @return Metadata.
+      * @throws PortableException In case of error.
+      */
+     public Collection<PortableMetadata> metadata() throws PortableException;
+ }

http://git-wip-us.apache.org/repos/asf/ignite/blob/80c71a89/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
----------------------------------------------------------------------
diff --cc modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
index 6ac2b64,9fb56bc..eafaf65
--- a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
@@@ -17,25 -17,10 +17,17 @@@
  
  package org.apache.ignite.configuration;
  
 +import java.io.Serializable;
 +import java.util.Collection;
 +import java.util.HashSet;
 +import javax.cache.Cache;
 +import javax.cache.configuration.CompleteConfiguration;
 +import javax.cache.configuration.Factory;
 +import javax.cache.configuration.MutableConfiguration;
 +import javax.cache.expiry.ExpiryPolicy;
  import org.apache.ignite.Ignite;
  import org.apache.ignite.IgniteCache;
- import org.apache.ignite.cache.CacheAtomicWriteOrderMode;
- import org.apache.ignite.cache.CacheAtomicityMode;
- import org.apache.ignite.cache.CacheEntryProcessor;
- import org.apache.ignite.cache.CacheInterceptor;
- import org.apache.ignite.cache.CacheMemoryMode;
- import org.apache.ignite.cache.CacheMode;
- import org.apache.ignite.cache.CacheRebalanceMode;
- import org.apache.ignite.cache.CacheTypeMetadata;
- import org.apache.ignite.cache.CacheWriteSynchronizationMode;
 -import org.apache.ignite.IgniteException;
+ import org.apache.ignite.cache.*;
  import org.apache.ignite.cache.affinity.AffinityFunction;
  import org.apache.ignite.cache.affinity.AffinityKeyMapper;
  import org.apache.ignite.cache.eviction.EvictionFilter;

http://git-wip-us.apache.org/repos/asf/ignite/blob/80c71a89/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/ignite/blob/80c71a89/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/ignite/blob/80c71a89/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/ignite/blob/80c71a89/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/ignite/blob/80c71a89/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/ignite/blob/80c71a89/modules/core/src/main/java/org/apache/ignite/marshaller/portable/PortableMarshaller.java
----------------------------------------------------------------------
diff --cc modules/core/src/main/java/org/apache/ignite/marshaller/portable/PortableMarshaller.java
index 0000000,bfc34cd..e3905cd
mode 000000,100644..100644
--- a/modules/core/src/main/java/org/apache/ignite/marshaller/portable/PortableMarshaller.java
+++ b/modules/core/src/main/java/org/apache/ignite/marshaller/portable/PortableMarshaller.java
@@@ -1,0 -1,358 +1,358 @@@
+ /*
+  * 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.marshaller.portable;
+ 
+ import java.io.ByteArrayOutputStream;
+ import java.io.IOException;
+ import java.io.InputStream;
+ import java.io.OutputStream;
+ import java.sql.Timestamp;
+ import java.util.ArrayList;
+ import java.util.Collection;
+ import org.apache.ignite.IgniteCheckedException;
+ import org.apache.ignite.internal.portable.GridPortableMarshaller;
+ import org.apache.ignite.internal.portable.PortableContext;
+ import org.apache.ignite.marshaller.AbstractMarshaller;
+ import org.apache.ignite.marshaller.MarshallerContext;
+ import org.apache.ignite.portable.PortableException;
+ import org.apache.ignite.portable.PortableIdMapper;
+ import org.apache.ignite.portable.PortableObject;
+ import org.apache.ignite.portable.PortableProtocolVersion;
+ import org.apache.ignite.portable.PortableSerializer;
+ import org.apache.ignite.portable.PortableTypeConfiguration;
+ import org.jetbrains.annotations.Nullable;
+ 
+ /**
+  * Implementation of {@link org.apache.ignite.marshaller.Marshaller} that lets to serialize and deserialize all objects
+  * in the portable format.
+  * <p>
+  * {@code PortableMarshaller} is tested only on Java HotSpot VM on other VMs it could yield unexpected results.
+  * <p>
+  * <h1 class="header">Configuration</h1>
+  * <h2 class="header">Mandatory</h2>
+  * This marshaller has no mandatory configuration parameters.
+  * <h2 class="header">Java Example</h2>
+  * <pre name="code" class="java">
+  * PortableMarshaller marshaller = new PortableMarshaller();
+  *
+  * IgniteConfiguration cfg = new IgniteConfiguration();
+  *
+  * // Override marshaller.
+  * cfg.setMarshaller(marshaller);
+  *
+  * // Starts grid.
+  * G.start(cfg);
+  * </pre>
+  * <h2 class="header">Spring Example</h2>
+  * PortableMarshaller can be configured from Spring XML configuration file:
+  * <pre name="code" class="xml">
+  * &lt;bean id="grid.custom.cfg" class="org.apache.ignite.configuration.IgniteConfiguration" singleton="true"&gt;
+  *     ...
+  *     &lt;property name="marshaller"&gt;
+  *         &lt;bean class="org.apache.ignite.marshaller.portable.PortableMarshaller"&gt;
+  *            ...
+  *         &lt;/bean&gt;
+  *     &lt;/property&gt;
+  *     ...
+  * &lt;/bean&gt;
+  * </pre>
+  * <p>
+  * <img src="http://ignite.apache.org/images/spring-small.png">
+  * <br>
+  * For information about Spring framework visit <a href="http://www.springframework.org/">www.springframework.org</a>
+  */
+ public class PortableMarshaller extends AbstractMarshaller {
+     /** Default portable protocol version. */
+     public static final PortableProtocolVersion DFLT_PORTABLE_PROTO_VER = PortableProtocolVersion.VER_1_4_0;
+ 
+     /** Class names. */
+     private Collection<String> clsNames;
+ 
+     /** ID mapper. */
+     private PortableIdMapper idMapper;
+ 
+     /** Serializer. */
+     private PortableSerializer serializer;
+ 
+     /** Types. */
+     private Collection<PortableTypeConfiguration> typeCfgs;
+ 
+     /** Use timestamp flag. */
+     private boolean useTs = true;
+ 
+     /** Whether to convert string to bytes using UTF-8 encoding. */
+     private boolean convertString = true;
+ 
+     /** Meta data enabled flag. */
+     private boolean metaDataEnabled = true;
+ 
+     /** Keep deserialized flag. */
+     private boolean keepDeserialized = true;
+ 
+     /** Protocol version. */
+     private PortableProtocolVersion protoVer = DFLT_PORTABLE_PROTO_VER;
+ 
+     /** */
+     private GridPortableMarshaller impl;
+ 
+     /**
+      * Gets class names.
+      *
+      * @return Class names.
+      */
+     public Collection<String> getClassNames() {
+         return clsNames;
+     }
+ 
+     /**
+      * Sets class names of portable objects explicitly.
+      *
+      * @param clsNames Class names.
+      */
+     public void setClassNames(Collection<String> clsNames) {
+         this.clsNames = new ArrayList<>(clsNames.size());
+ 
+         for (String clsName : clsNames)
+             this.clsNames.add(clsName.trim());
+     }
+ 
+     /**
+      * Gets ID mapper.
+      *
+      * @return ID mapper.
+      */
+     public PortableIdMapper getIdMapper() {
+         return idMapper;
+     }
+ 
+     /**
+      * Sets ID mapper.
+      *
+      * @param idMapper ID mapper.
+      */
+     public void setIdMapper(PortableIdMapper idMapper) {
+         this.idMapper = idMapper;
+     }
+ 
+     /**
+      * Gets serializer.
+      *
+      * @return Serializer.
+      */
+     public PortableSerializer getSerializer() {
+         return serializer;
+     }
+ 
+     /**
+      * Sets serializer.
+      *
+      * @param serializer Serializer.
+      */
+     public void setSerializer(PortableSerializer serializer) {
+         this.serializer = serializer;
+     }
+ 
+     /**
+      * Gets types configuration.
+      *
+      * @return Types configuration.
+      */
+     public Collection<PortableTypeConfiguration> getTypeConfigurations() {
+         return typeCfgs;
+     }
+ 
+     /**
+      * Sets type configurations.
+      *
+      * @param typeCfgs Type configurations.
+      */
+     public void setTypeConfigurations(Collection<PortableTypeConfiguration> typeCfgs) {
+         this.typeCfgs = typeCfgs;
+     }
+ 
+     /**
+      * If {@code true} then date values converted to {@link Timestamp} on deserialization.
+      * <p>
+      * Default value is {@code true}.
+      *
+      * @return Flag indicating whether date values converted to {@link Timestamp} during unmarshalling.
+      */
+     public boolean isUseTimestamp() {
+         return useTs;
+     }
+ 
+     /**
+      * @param useTs Flag indicating whether date values converted to {@link Timestamp} during unmarshalling.
+      */
+     public void setUseTimestamp(boolean useTs) {
+         this.useTs = useTs;
+     }
+ 
+     /**
+      * Gets strings must be converted to or from bytes using UTF-8 encoding.
+      * <p>
+      * Default value is {@code true}.
+      *
+      * @return Flag indicating whether string must be converted to byte array using UTF-8 encoding.
+      */
+     public boolean isConvertStringToBytes() {
+         return convertString;
+     }
+ 
+     /**
+      * Sets strings must be converted to or from bytes using UTF-8 encoding.
+      * <p>
+      * Default value is {@code true}.
+      *
+      * @param convertString Flag indicating whether string must be converted to byte array using UTF-8 encoding.
+      */
+     public void setConvertStringToBytes(boolean convertString) {
+         this.convertString = convertString;
+     }
+ 
+     /**
+      * If {@code true}, meta data will be collected or all types. If you need to override this behaviour for
+      * some specific type, use {@link PortableTypeConfiguration#setMetaDataEnabled(Boolean)} method.
+      * <p>
+      * Default value if {@code true}.
+      *
+      * @return Whether meta data is collected.
+      */
+     public boolean isMetaDataEnabled() {
+         return metaDataEnabled;
+     }
+ 
+     /**
+      * @param metaDataEnabled Whether meta data is collected.
+      */
+     public void setMetaDataEnabled(boolean metaDataEnabled) {
+         this.metaDataEnabled = metaDataEnabled;
+     }
+ 
+     /**
+      * If {@code true}, {@link PortableObject} will cache deserialized instance after
+      * {@link PortableObject#deserialize()} is called. All consequent calls of this
+      * method on the same instance of {@link PortableObject} will return that cached
+      * value without actually deserializing portable object. If you need to override this
+      * behaviour for some specific type, use {@link PortableTypeConfiguration#setKeepDeserialized(Boolean)}
+      * method.
+      * <p>
+      * Default value if {@code true}.
+      *
+      * @return Whether deserialized value is kept.
+      */
+     public boolean isKeepDeserialized() {
+         return keepDeserialized;
+     }
+ 
+     /**
+      * @param keepDeserialized Whether deserialized value is kept.
+      */
+     public void setKeepDeserialized(boolean keepDeserialized) {
+         this.keepDeserialized = keepDeserialized;
+     }
+ 
+     /**
+      * Gets portable protocol version.
+      * <p>
+      * Defaults to {@link #DFLT_PORTABLE_PROTO_VER}.
+      *
+      * @return Portable protocol version.
+      */
+     public PortableProtocolVersion getProtocolVersion() {
+         return protoVer;
+     }
+ 
+     /**
+      * Sets portable protocol version.
+      * <p>
+      * Defaults to {@link #DFLT_PORTABLE_PROTO_VER}.
+      *
+      * @param protoVer Portable protocol version.
+      */
+     public void setProtocolVersion(PortableProtocolVersion protoVer) {
+         if (protoVer == null)
+             throw new IllegalArgumentException("Wrong portable protocol version: " + protoVer);
+ 
+         this.protoVer = protoVer;
+     }
+ 
+     /**
+      * Returns currently set {@link MarshallerContext}.
+      *
+      * @return Marshaller context.
+      */
+     public MarshallerContext getContext() {
+         return ctx;
+     }
+ 
+     /**
+      * Sets {@link PortableContext}.
+      * <p/>
+      * @param ctx Portable context.
+      */
+     private void setPortableContext(PortableContext ctx) {
+         ctx.configure(this);
+ 
+         impl = new GridPortableMarshaller(ctx);
+     }
+ 
+     /** {@inheritDoc} */
+     @Override public byte[] marshal(@Nullable Object obj) throws IgniteCheckedException {
+         return impl.marshal(obj, 0);
+     }
+ 
+     /** {@inheritDoc} */
+     @Override public void marshal(@Nullable Object obj, OutputStream out) throws IgniteCheckedException {
+         byte[] arr = marshal(obj);
+ 
+         try {
+             out.write(arr);
+         }
+         catch (IOException e) {
+             throw new PortableException("Failed to marshal the object: " + obj, e);
+         }
+     }
+ 
+     /** {@inheritDoc} */
+     @Override public <T> T unmarshal(byte[] bytes, @Nullable ClassLoader clsLdr) throws IgniteCheckedException {
+         return impl.deserialize(bytes, clsLdr);
+     }
+ 
+     /** {@inheritDoc} */
+     @Override public <T> T unmarshal(InputStream in, @Nullable ClassLoader clsLdr) throws IgniteCheckedException {
 -        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
++        ByteArrayOutputStream buf = new ByteArrayOutputStream();
+ 
+         byte[] arr = new byte[4096];
+         int cnt;
+ 
+         // we have to fully read the InputStream because GridPortableMarshaller requires support of a method that
+         // returns number of bytes remaining.
+         try {
+             while ((cnt = in.read(arr)) != -1)
 -                buffer.write(arr, 0, cnt);
++                buf.write(arr, 0, cnt);
+ 
 -            buffer.flush();
++            buf.flush();
+ 
 -            return impl.deserialize(buffer.toByteArray(), clsLdr);
++            return impl.deserialize(buf.toByteArray(), clsLdr);
+         }
+         catch (IOException e) {
+             throw new PortableException("Failed to unmarshal the object from InputStream", e);
+         }
+     }
+ }

http://git-wip-us.apache.org/repos/asf/ignite/blob/80c71a89/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
----------------------------------------------------------------------
diff --cc modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
index d89e397,2b448f8..134ee33
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
@@@ -129,8 -153,12 +129,13 @@@ public class IgniteCacheProcessProxy<K
      }
  
      /** {@inheritDoc} */
-     @Override public void loadCache(@Nullable IgniteBiPredicate<K, V> p, @Nullable Object... args)
+     @Override public <K1, V1> IgniteCache<K1, V1> withKeepPortable() {
+         throw new UnsupportedOperationException("Method should be supported.");
+     }
+ 
+     /** {@inheritDoc} */
 -    @Override public void loadCache(@Nullable IgniteBiPredicate<K, V> p, @Nullable Object... args) throws CacheException {
++    @Override public void loadCache(@Nullable IgniteBiPredicate<K, V> p, @Nullable Object... args) 
 +        throws CacheException {
          throw new UnsupportedOperationException("Method should be supported.");
      }
  

http://git-wip-us.apache.org/repos/asf/ignite/blob/80c71a89/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteProcessProxy.java
----------------------------------------------------------------------


[5/5] ignite git commit: IGNITE-950 - WIP fixing tests.

Posted by ag...@apache.org.
IGNITE-950 - WIP fixing tests.


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

Branch: refs/heads/ignite-950-new
Commit: 54e0b63a3b3d4c05b9fcb7e1ddbac2f548c70e1b
Parents: f812afd
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Thu Oct 22 13:30:42 2015 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Thu Oct 22 13:30:42 2015 +0300

----------------------------------------------------------------------
 .../ignite/codegen/MessageCodeGenerator.java    |  5 +-
 .../dht/atomic/GridNearAtomicUpdateRequest.java | 58 ++++++++++++--------
 .../distributed/near/GridNearGetFuture.java     |  7 +--
 .../near/GridNearTransactionalCache.java        |  4 +-
 .../local/atomic/GridLocalAtomicCache.java      | 36 ++++++++----
 .../cache/query/GridCacheQueryManager.java      | 13 +++--
 .../transactions/IgniteTxLocalAdapter.java      |  5 +-
 7 files changed, 81 insertions(+), 47 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/54e0b63a/modules/codegen/src/main/java/org/apache/ignite/codegen/MessageCodeGenerator.java
----------------------------------------------------------------------
diff --git a/modules/codegen/src/main/java/org/apache/ignite/codegen/MessageCodeGenerator.java b/modules/codegen/src/main/java/org/apache/ignite/codegen/MessageCodeGenerator.java
index 8d9a3f5..b8ccc03 100644
--- a/modules/codegen/src/main/java/org/apache/ignite/codegen/MessageCodeGenerator.java
+++ b/modules/codegen/src/main/java/org/apache/ignite/codegen/MessageCodeGenerator.java
@@ -43,6 +43,7 @@ import org.apache.ignite.internal.GridDirectCollection;
 import org.apache.ignite.internal.GridDirectMap;
 import org.apache.ignite.internal.GridDirectTransient;
 import org.apache.ignite.internal.IgniteCodeGeneratingFail;
+import org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridNearAtomicUpdateRequest;
 import org.apache.ignite.internal.util.typedef.internal.SB;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.lang.IgniteUuid;
@@ -165,7 +166,9 @@ public class MessageCodeGenerator {
 
         MessageCodeGenerator gen = new MessageCodeGenerator(srcDir);
 
-        gen.generateAll(true);
+//        gen.generateAll(true);
+
+        gen.generateAndWrite(GridNearAtomicUpdateRequest.class);
 
 //        gen.generateAndWrite(DataStreamerEntry.class);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/54e0b63a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java
index bbf3e3a..d3b6afc 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java
@@ -684,66 +684,72 @@ public class GridNearAtomicUpdateRequest extends GridCacheMessage implements Gri
                 writer.incrementState();
 
             case 14:
-                if (!writer.writeCollection("keys", keys, MessageCollectionItemType.MSG))
+                if (!writer.writeBoolean("keepBinary", keepBinary))
                     return false;
 
                 writer.incrementState();
 
             case 15:
-                if (!writer.writeByte("op", op != null ? (byte)op.ordinal() : -1))
+                if (!writer.writeCollection("keys", keys, MessageCollectionItemType.MSG))
                     return false;
 
                 writer.incrementState();
 
             case 16:
-                if (!writer.writeBoolean("retval", retval))
+                if (!writer.writeByte("op", op != null ? (byte)op.ordinal() : -1))
                     return false;
 
                 writer.incrementState();
 
             case 17:
-                if (!writer.writeBoolean("skipStore", skipStore))
+                if (!writer.writeBoolean("retval", retval))
                     return false;
 
                 writer.incrementState();
 
             case 18:
-                if (!writer.writeUuid("subjId", subjId))
+                if (!writer.writeBoolean("skipStore", skipStore))
                     return false;
 
                 writer.incrementState();
 
             case 19:
-                if (!writer.writeByte("syncMode", syncMode != null ? (byte)syncMode.ordinal() : -1))
+                if (!writer.writeUuid("subjId", subjId))
                     return false;
 
                 writer.incrementState();
 
             case 20:
-                if (!writer.writeInt("taskNameHash", taskNameHash))
+                if (!writer.writeByte("syncMode", syncMode != null ? (byte)syncMode.ordinal() : -1))
                     return false;
 
                 writer.incrementState();
 
             case 21:
-                if (!writer.writeBoolean("topLocked", topLocked))
+                if (!writer.writeInt("taskNameHash", taskNameHash))
                     return false;
 
                 writer.incrementState();
 
             case 22:
-                if (!writer.writeMessage("topVer", topVer))
+                if (!writer.writeBoolean("topLocked", topLocked))
                     return false;
 
                 writer.incrementState();
 
             case 23:
-                if (!writer.writeMessage("updateVer", updateVer))
+                if (!writer.writeMessage("topVer", topVer))
                     return false;
 
                 writer.incrementState();
 
             case 24:
+                if (!writer.writeMessage("updateVer", updateVer))
+                    return false;
+
+                writer.incrementState();
+
+            case 25:
                 if (!writer.writeCollection("vals", vals, MessageCollectionItemType.MSG))
                     return false;
 
@@ -854,7 +860,7 @@ public class GridNearAtomicUpdateRequest extends GridCacheMessage implements Gri
                 reader.incrementState();
 
             case 14:
-                keys = reader.readCollection("keys", MessageCollectionItemType.MSG);
+                keepBinary = reader.readBoolean("keepBinary");
 
                 if (!reader.isLastRead())
                     return false;
@@ -862,6 +868,14 @@ public class GridNearAtomicUpdateRequest extends GridCacheMessage implements Gri
                 reader.incrementState();
 
             case 15:
+                keys = reader.readCollection("keys", MessageCollectionItemType.MSG);
+
+                if (!reader.isLastRead())
+                    return false;
+
+                reader.incrementState();
+
+            case 16:
                 byte opOrd;
 
                 opOrd = reader.readByte("op");
@@ -873,7 +887,7 @@ public class GridNearAtomicUpdateRequest extends GridCacheMessage implements Gri
 
                 reader.incrementState();
 
-            case 16:
+            case 17:
                 retval = reader.readBoolean("retval");
 
                 if (!reader.isLastRead())
@@ -881,7 +895,7 @@ public class GridNearAtomicUpdateRequest extends GridCacheMessage implements Gri
 
                 reader.incrementState();
 
-            case 17:
+            case 18:
                 skipStore = reader.readBoolean("skipStore");
 
                 if (!reader.isLastRead())
@@ -889,7 +903,7 @@ public class GridNearAtomicUpdateRequest extends GridCacheMessage implements Gri
 
                 reader.incrementState();
 
-            case 18:
+            case 19:
                 subjId = reader.readUuid("subjId");
 
                 if (!reader.isLastRead())
@@ -897,7 +911,7 @@ public class GridNearAtomicUpdateRequest extends GridCacheMessage implements Gri
 
                 reader.incrementState();
 
-            case 19:
+            case 20:
                 byte syncModeOrd;
 
                 syncModeOrd = reader.readByte("syncMode");
@@ -909,7 +923,7 @@ public class GridNearAtomicUpdateRequest extends GridCacheMessage implements Gri
 
                 reader.incrementState();
 
-            case 20:
+            case 21:
                 taskNameHash = reader.readInt("taskNameHash");
 
                 if (!reader.isLastRead())
@@ -917,7 +931,7 @@ public class GridNearAtomicUpdateRequest extends GridCacheMessage implements Gri
 
                 reader.incrementState();
 
-            case 21:
+            case 22:
                 topLocked = reader.readBoolean("topLocked");
 
                 if (!reader.isLastRead())
@@ -925,7 +939,7 @@ public class GridNearAtomicUpdateRequest extends GridCacheMessage implements Gri
 
                 reader.incrementState();
 
-            case 22:
+            case 23:
                 topVer = reader.readMessage("topVer");
 
                 if (!reader.isLastRead())
@@ -933,7 +947,7 @@ public class GridNearAtomicUpdateRequest extends GridCacheMessage implements Gri
 
                 reader.incrementState();
 
-            case 23:
+            case 24:
                 updateVer = reader.readMessage("updateVer");
 
                 if (!reader.isLastRead())
@@ -941,7 +955,7 @@ public class GridNearAtomicUpdateRequest extends GridCacheMessage implements Gri
 
                 reader.incrementState();
 
-            case 24:
+            case 25:
                 vals = reader.readCollection("vals", MessageCollectionItemType.MSG);
 
                 if (!reader.isLastRead())
@@ -961,7 +975,7 @@ public class GridNearAtomicUpdateRequest extends GridCacheMessage implements Gri
 
     /** {@inheritDoc} */
     @Override public byte fieldsCount() {
-        return 25;
+        return 26;
     }
 
     /** {@inheritDoc} */
@@ -969,4 +983,4 @@ public class GridNearAtomicUpdateRequest extends GridCacheMessage implements Gri
         return S.toString(GridNearAtomicUpdateRequest.class, this, "filter", Arrays.toString(filter),
             "parent", super.toString());
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/54e0b63a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java
index d9763f8..3da08c7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java
@@ -534,11 +534,8 @@ public final class GridNearGetFuture<K, V> extends GridCompoundIdentityFuture<Ma
                 }
 
                 if (v != null && !reload) {
-                    K key0 = key.value(cctx.cacheObjectContext(), true);
-                    V val0 = v.value(cctx.cacheObjectContext(), true);
-
-                    val0 = (V)cctx.unwrapPortableIfNeeded(val0, !deserializePortable);
-                    key0 = (K)cctx.unwrapPortableIfNeeded(key0, !deserializePortable);
+                    K key0 = (K)cctx.unwrapPortableIfNeeded(key, !deserializePortable);
+                    V val0 = (V)cctx.unwrapPortableIfNeeded(v, !deserializePortable);
 
                     add(new GridFinishedFuture<>(Collections.singletonMap(key0, val0)));
                 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/54e0b63a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTransactionalCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTransactionalCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTransactionalCache.java
index 99c2b87..03486d6 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTransactionalCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTransactionalCache.java
@@ -138,8 +138,6 @@ public class GridNearTransactionalCache<K, V> extends GridNearCacheAdapter<K, V>
 
         final boolean skipStore = opCtx != null && opCtx.skipStore();
 
-        final boolean keepBinary = opCtx != null && opCtx.isKeepPortable();
-
         if (tx != null && !tx.implicit() && !skipTx) {
             return asyncOp(tx, new AsyncOp<Map<K, V>>(keys) {
                 @Override public IgniteInternalFuture<Map<K, V>> op(IgniteTxLocalAdapter tx) {
@@ -148,7 +146,7 @@ public class GridNearTransactionalCache<K, V> extends GridNearCacheAdapter<K, V>
                         entry,
                         deserializePortable,
                         skipVals,
-                        keepBinary,
+                        false,
                         skipStore);
                 }
             });

http://git-wip-us.apache.org/repos/asf/ignite/blob/54e0b63a/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 bf0bb00..39f9f61 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
@@ -144,6 +144,8 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
     @Override public V getAndPut(K key, V val, @Nullable CacheEntryPredicate[] filter) throws IgniteCheckedException {
         A.notNull(key, "key", val, "val");
 
+        CacheOperationContext opCtx = ctx.operationContextPerCall();
+
         return (V)updateAllInternal(UPDATE,
             Collections.singleton(key),
             Collections.singleton(val),
@@ -154,7 +156,7 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
             filter,
             ctx.writeThrough(),
             ctx.readThrough(),
-            ctx.operationContextPerCall().isKeepPortable());
+            opCtx != null && opCtx.isKeepPortable());
     }
 
     /** {@inheritDoc} */
@@ -328,6 +330,8 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
 
         long start = statsEnabled ? System.nanoTime() : 0L;
 
+        CacheOperationContext opCtx = ctx.operationContextPerCall();
+
         updateAllInternal(UPDATE,
             m.keySet(),
             m.values(),
@@ -338,7 +342,7 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
             CU.empty0(),
             ctx.writeThrough(),
             ctx.readThrough(),
-            ctx.operationContextPerCall().isKeepPortable());
+            opCtx != null && opCtx.isKeepPortable());
 
         if (statsEnabled)
             metrics0().addPutTimeNanos(System.nanoTime() - start);
@@ -357,6 +361,8 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
     /** {@inheritDoc} */
     @SuppressWarnings("unchecked")
     @Override public V getAndRemove(K key) throws IgniteCheckedException {
+        CacheOperationContext opCtx = ctx.operationContextPerCall();
+
         return (V)updateAllInternal(DELETE,
             Collections.singleton(key),
             null,
@@ -367,7 +373,7 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
             CU.empty0(),
             ctx.writeThrough(),
             ctx.readThrough(),
-            ctx.operationContextPerCall().isKeepPortable());
+            opCtx != null && opCtx.isKeepPortable());
     }
 
     /** {@inheritDoc} */
@@ -379,6 +385,8 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
     /** {@inheritDoc} */
     @SuppressWarnings("unchecked")
     @Override public void removeAll(Collection<? extends K> keys) throws IgniteCheckedException {
+        CacheOperationContext opCtx = ctx.operationContextPerCall();
+
         updateAllInternal(DELETE,
             keys,
             null,
@@ -389,7 +397,7 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
             CU.empty0(),
             ctx.writeThrough(),
             ctx.readThrough(),
-            ctx.operationContextPerCall().isKeepPortable());
+            opCtx != null && opCtx.isKeepPortable());
     }
 
     /** {@inheritDoc} */
@@ -438,6 +446,8 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
     @Override public boolean remove(K key, V val) throws IgniteCheckedException {
         A.notNull(key, "key", val, "val");
 
+        CacheOperationContext opCtx = ctx.operationContextPerCall();
+
         return (Boolean)updateAllInternal(DELETE,
             Collections.singleton(key),
             null,
@@ -448,7 +458,7 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
             ctx.equalsValArray(val),
             ctx.writeThrough(),
             ctx.readThrough(),
-            ctx.operationContextPerCall().isKeepPortable());
+            opCtx != null && opCtx.isKeepPortable());
     }
 
     /** {@inheritDoc} */
@@ -663,7 +673,9 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
             }
         });
 
-        final boolean keepPortable = ctx.operationContextPerCall().isKeepPortable();
+        CacheOperationContext opCtx = ctx.operationContextPerCall();
+
+        final boolean keepPortable = opCtx != null && opCtx.isKeepPortable();
 
         return (Map<K, EntryProcessorResult<T>>)updateAllInternal(TRANSFORM,
             invokeMap.keySet(),
@@ -749,7 +761,7 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
         if (keyCheck)
             validateCacheKeys(map.keySet());
 
-        final boolean keepPortable = ctx.operationContextPerCall().isKeepPortable();
+        CacheOperationContext opCtx = ctx.operationContextPerCall();
 
         return (Map<K, EntryProcessorResult<T>>)updateAllInternal(TRANSFORM,
             map.keySet(),
@@ -761,7 +773,7 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
             null,
             ctx.writeThrough(),
             ctx.readThrough(),
-            keepPortable);
+            opCtx != null && opCtx.isKeepPortable());
     }
 
     /** {@inheritDoc} */
@@ -812,9 +824,11 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
 
         final boolean readThrough = ctx.readThrough();
 
+        CacheOperationContext opCtx = ctx.operationContextPerCall();
+
         final ExpiryPolicy expiry = expiryPerCall();
 
-        final boolean keepPortable = ctx.operationContextPerCall().isKeepPortable();
+        final boolean keepPortable = opCtx != null && opCtx.isKeepPortable();
 
         IgniteInternalFuture fut = asyncOp(new Callable<Object>() {
             @Override public Object call() throws Exception {
@@ -863,7 +877,9 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
 
         final ExpiryPolicy expiryPlc = expiryPerCall();
 
-        final boolean keepPortable = ctx.operationContextPerCall().isKeepPortable();
+        CacheOperationContext opCtx = ctx.operationContextPerCall();
+
+        final boolean keepPortable = opCtx != null && opCtx.isKeepPortable();
 
         IgniteInternalFuture fut = asyncOp(new Callable<Object>() {
             @Override public Object call() throws Exception {

http://git-wip-us.apache.org/repos/asf/ignite/blob/54e0b63a/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 1c8107e..58a8424 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
@@ -907,7 +907,8 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
                             CacheObject cacheVal =
                                 entry != null ? entry.peek(true, false, false, topVer, expiryPlc) : null;
 
-                            val = cacheVal != null ? (V)cacheVal.value(cctx.cacheObjectContext(), false) : null;
+                            // TODO 950 nocopy
+                            val = (V)cctx.cacheObjectContext().unwrapPortableIfNeeded(cacheVal, qry.keepPortable());
                         }
                         catch (GridCacheEntryRemovedException e) {
                             val = null;
@@ -1093,7 +1094,7 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
                 next = null;
 
                 while (it.hasNext()) {
-                    final LazySwapEntry e = new LazySwapEntry(it.next());
+                    final LazySwapEntry e = new LazySwapEntry(it.next(), keepPortable);
 
                     if (filter != null) {
                         K key = (K)cctx.unwrapPortableIfNeeded(e.key(), keepPortable);
@@ -2510,11 +2511,15 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
         /** */
         private final Map.Entry<byte[], byte[]> e;
 
+        /** */
+        private boolean keepBinary;
+
         /**
          * @param e Entry with
          */
-        LazySwapEntry(Map.Entry<byte[], byte[]> e) {
+        LazySwapEntry(Map.Entry<byte[], byte[]> e, boolean keepBinary) {
             this.e = e;
+            this.keepBinary = keepBinary;
         }
 
         /** {@inheritDoc} */
@@ -2529,7 +2534,7 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
 
             CacheObject obj = cctx.cacheObjects().toCacheObject(cctx.cacheObjectContext(), t.get2(), t.get1());
 
-            return obj.value(cctx.cacheObjectContext(), false);
+            return (V)cctx.cacheObjectContext().unwrapPortableIfNeeded(obj, keepBinary);
         }
 
         /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/54e0b63a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
index c5def9a..930ed83 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
@@ -1781,8 +1781,9 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
 
                         // Load keys only after the locks have been acquired.
                         for (KeyCacheObject cacheKey : lockKeys) {
-                            K keyVal =
-                                (K)(keepCacheObjects ? cacheKey : cacheKey.value(cacheCtx.cacheObjectContext(), false));
+                            K keyVal = (K)
+                                (keepCacheObjects ? cacheKey :
+                                cacheCtx.cacheObjectContext().unwrapPortableIfNeeded(cacheKey, !deserializePortable));
 
                             if (retMap.containsKey(keyVal))
                                 // We already have a return value.


[3/5] ignite git commit: IGNITE-950 - WIP.

Posted by ag...@apache.org.
IGNITE-950 - WIP.


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

Branch: refs/heads/ignite-950-new
Commit: d5df41bd5afa532876c623149d918510dd8e584a
Parents: 80c71a8
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Wed Oct 21 19:19:25 2015 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Wed Oct 21 19:19:25 2015 +0300

----------------------------------------------------------------------
 .../apache/ignite/internal/IgniteKernal.java    |   6 -
 .../internal/portable/PortableObjectImpl.java   |  48 ++++---
 .../portable/PortableObjectOffheapImpl.java     |  30 +++--
 .../processors/cache/CacheInvokeEntry.java      |  11 +-
 .../processors/cache/CacheLazyEntry.java        |  23 ++--
 .../internal/processors/cache/CacheObject.java  |   9 ++
 .../cache/CacheObjectByteArrayImpl.java         |   5 +
 .../processors/cache/CacheObjectContext.java    | 121 ++++++++++++++++--
 .../processors/cache/CacheObjectImpl.java       |  13 +-
 .../processors/cache/GridCacheContext.java      |  10 +-
 .../processors/cache/GridCacheEntryEx.java      |   4 +
 .../processors/cache/GridCacheEventManager.java |   4 +-
 .../processors/cache/GridCacheMapEntry.java     |  34 ++---
 .../processors/cache/GridCacheUtils.java        |   3 +
 .../processors/cache/KeyCacheObjectImpl.java    |   5 +
 .../distributed/GridDistributedLockRequest.java |  12 ++
 .../GridDistributedTxRemoteAdapter.java         |  56 +++++++--
 .../dht/GridDhtTransactionalCacheAdapter.java   |   6 +-
 .../distributed/dht/GridDhtTxLocalAdapter.java  |   8 +-
 .../distributed/dht/GridDhtTxPrepareFuture.java |   4 +-
 .../cache/distributed/dht/GridDhtTxRemote.java  |  12 +-
 .../dht/atomic/GridDhtAtomicCache.java          |  21 ++--
 .../dht/atomic/GridDhtAtomicUpdateRequest.java  |  10 ++
 .../dht/atomic/GridNearAtomicUpdateFuture.java  |   7 ++
 .../dht/atomic/GridNearAtomicUpdateRequest.java |  12 ++
 .../distributed/near/GridNearAtomicCache.java   |   4 +
 .../near/GridNearTransactionalCache.java        |   7 +-
 .../distributed/near/GridNearTxRemote.java      |  12 +-
 .../local/atomic/GridLocalAtomicCache.java      |  73 +++++++----
 .../portable/CacheObjectPortableContext.java    | 125 -------------------
 .../transactions/IgniteTransactionsImpl.java    |  10 +-
 .../cache/transactions/IgniteTxAdapter.java     |   2 +-
 .../cache/transactions/IgniteTxEntry.java       |  54 +++++++-
 .../transactions/IgniteTxLocalAdapter.java      |  48 ++++---
 .../spi/discovery/tcp/TcpDiscoverySpi.java      |   2 +
 .../processors/cache/GridCacheTestEntryEx.java  |   4 +
 ...ridCachePortableObjectsAbstractSelfTest.java |   3 +
 .../h2/GridIndexingSpiAbstractSelfTest.java     |   5 +
 38 files changed, 536 insertions(+), 287 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/d5df41bd/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 02a7cae..cee5f5f 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
@@ -62,7 +62,6 @@ import org.apache.ignite.internal.managers.failover.GridFailoverManager;
 import org.apache.ignite.internal.managers.indexing.GridIndexingManager;
 import org.apache.ignite.internal.managers.loadbalancer.GridLoadBalancerManager;
 import org.apache.ignite.internal.managers.swapspace.GridSwapSpaceManager;
-import org.apache.ignite.internal.portable.api.IgnitePortables;
 import org.apache.ignite.internal.processors.GridProcessor;
 import org.apache.ignite.internal.processors.affinity.GridAffinityProcessor;
 import org.apache.ignite.internal.processors.cache.GridCacheAdapter;
@@ -126,7 +125,6 @@ import org.apache.ignite.lifecycle.LifecycleBean;
 import org.apache.ignite.lifecycle.LifecycleEventType;
 import org.apache.ignite.marshaller.MarshallerExclusions;
 import org.apache.ignite.marshaller.optimized.OptimizedMarshaller;
-import org.apache.ignite.marshaller.portable.PortableMarshaller;
 import org.apache.ignite.mxbean.ClusterLocalNodeMetricsMXBean;
 import org.apache.ignite.mxbean.IgniteMXBean;
 import org.apache.ignite.mxbean.ThreadPoolMXBean;
@@ -205,7 +203,6 @@ import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_MARSHALLER;
 import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_NODE_CONSISTENT_ID;
 import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_PEER_CLASSLOADING;
 import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_PHY_RAM;
-import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_PORTABLE_PROTO_VER;
 import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_PREFIX;
 import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_RESTART_ENABLED;
 import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_REST_PORT_RANGE;
@@ -1272,9 +1269,6 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
         add(ATTR_MARSHALLER, cfg.getMarshaller().getClass().getName());
         add(ATTR_USER_NAME, System.getProperty("user.name"));
         add(ATTR_GRID_NAME, gridName);
-        add(ATTR_PORTABLE_PROTO_VER, cfg.getMarshaller() instanceof PortableMarshaller ?
-            ((PortableMarshaller)cfg.getMarshaller()).getProtocolVersion().toString() :
-            PortableMarshaller.DFLT_PORTABLE_PROTO_VER.toString());
 
         add(ATTR_PEER_CLASSLOADING, cfg.isPeerClassLoadingEnabled());
         add(ATTR_DEPLOYMENT_MODE, cfg.getDeploymentMode());

http://git-wip-us.apache.org/repos/asf/ignite/blob/d5df41bd/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableObjectImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableObjectImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableObjectImpl.java
index 47ff1ab..1f6a426 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableObjectImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableObjectImpl.java
@@ -99,6 +99,11 @@ public final class PortableObjectImpl extends PortableObjectEx implements Extern
     }
 
     /** {@inheritDoc} */
+    @Override public boolean isPlatformType() {
+        return false;
+    }
+
+    /** {@inheritDoc} */
     @Override public boolean internal() {
         return false;
     }
@@ -106,7 +111,12 @@ public final class PortableObjectImpl extends PortableObjectEx implements Extern
     /** {@inheritDoc} */
     @SuppressWarnings("unchecked")
     @Nullable @Override public <T> T value(CacheObjectContext ctx, boolean cpy) {
-        return (T)this;
+        Object obj0 = obj;
+
+        if (obj0 == null || cpy)
+            obj0 = deserializeValue();
+
+        return (T)obj0;
     }
 
     /** {@inheritDoc} */
@@ -262,21 +272,11 @@ public final class PortableObjectImpl extends PortableObjectEx implements Extern
     @Nullable @Override public <T> T deserialize() throws PortableException {
         Object obj0 = obj;
 
-        if (obj0 == null) {
-            // TODO: IGNITE-1272 - Deserialize with proper class loader.
-            PortableReaderExImpl reader = new PortableReaderExImpl(ctx, arr, start, null);
-
-            obj0 = reader.deserialize();
-
-            PortableClassDescriptor desc = reader.descriptor();
-
-            assert desc != null;
-
-            if (desc.keepDeserialized())
-                obj = obj0;
-        }
+        if (obj0 == null)
+            obj0 = deserializeValue();
 
         return (T)obj0;
+
     }
 
     /** {@inheritDoc} */
@@ -388,4 +388,24 @@ public final class PortableObjectImpl extends PortableObjectEx implements Extern
     @Override public byte fieldsCount() {
         return 3;
     }
+
+    /**
+     * Runs value deserialization regardless of whether obj already has the deserialized value.
+     * Will set obj if descriptor is configured to keep deserialized values.
+     */
+    private Object deserializeValue() {
+        // TODO: IGNITE-1272 - Deserialize with proper class loader.
+        PortableReaderExImpl reader = new PortableReaderExImpl(ctx, arr, start, null);
+
+        Object obj0 = reader.deserialize();
+
+        PortableClassDescriptor desc = reader.descriptor();
+
+        assert desc != null;
+
+//        if (desc.keepDeserialized())
+//            obj = obj0;
+
+        return obj0;
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/d5df41bd/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableObjectOffheapImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableObjectOffheapImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableObjectOffheapImpl.java
index ba8ee83..0335920 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableObjectOffheapImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableObjectOffheapImpl.java
@@ -164,14 +164,7 @@ public class PortableObjectOffheapImpl extends PortableObjectEx implements Exter
     /** {@inheritDoc} */
     @SuppressWarnings("unchecked")
     @Nullable @Override public <T> T deserialize() throws PortableException {
-        // TODO: IGNITE-1272 - Deserialize with proper class loader.
-        PortableReaderExImpl reader = new PortableReaderExImpl(
-            ctx,
-            new PortableOffheapInputStream(ptr, size, false),
-            start,
-            null);
-
-        return (T)reader.deserialize();
+        return (T)deserializeValue();
     }
 
     /** {@inheritDoc} */
@@ -186,9 +179,14 @@ public class PortableObjectOffheapImpl extends PortableObjectEx implements Exter
     }
 
     /** {@inheritDoc} */
+    @Override public boolean isPlatformType() {
+        return false;
+    }
+
+    /** {@inheritDoc} */
     @SuppressWarnings("unchecked")
     @Nullable @Override public <T> T value(CacheObjectContext ctx, boolean cpy) {
-        return (T)this;
+        return (T)deserializeValue();
     }
 
     /** {@inheritDoc} */
@@ -240,4 +238,18 @@ public class PortableObjectOffheapImpl extends PortableObjectEx implements Exter
     @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
         throw new UnsupportedOperationException(); // To make sure it is not marshalled.
     }
+
+    /**
+     * @return Deserialized value.
+     */
+    private Object deserializeValue() {
+        // TODO: IGNITE-1272 - Deserialize with proper class loader.
+        PortableReaderExImpl reader = new PortableReaderExImpl(
+            ctx,
+            new PortableOffheapInputStream(ptr, size, false),
+            start,
+            null);
+
+        return reader.deserialize();
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/d5df41bd/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeEntry.java
index f87dadd..2de26fc 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeEntry.java
@@ -49,9 +49,10 @@ public class CacheInvokeEntry<K, V> extends CacheLazyEntry<K, V> implements Muta
     public CacheInvokeEntry(GridCacheContext cctx,
         KeyCacheObject keyObj,
         @Nullable CacheObject valObj,
-        GridCacheVersion ver
+        GridCacheVersion ver,
+        boolean keepPortable
     ) {
-        super(cctx, keyObj, valObj);
+        super(cctx, keyObj, valObj, keepPortable);
 
         this.hadVal = valObj != null;
         this.ver = ver;
@@ -70,8 +71,10 @@ public class CacheInvokeEntry<K, V> extends CacheLazyEntry<K, V> implements Muta
         @Nullable K key,
         @Nullable CacheObject valObj,
         @Nullable V val,
-        GridCacheVersion ver) {
-        super(ctx, keyObj, key, valObj, val);
+        GridCacheVersion ver,
+        boolean keepPortable
+    ) {
+        super(ctx, keyObj, key, valObj, val, keepPortable);
 
         this.hadVal = valObj != null || val != null;
         this.ver = ver;

http://git-wip-us.apache.org/repos/asf/ignite/blob/d5df41bd/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheLazyEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheLazyEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheLazyEntry.java
index 1301f1a..47ad30c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheLazyEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheLazyEntry.java
@@ -20,7 +20,6 @@ package org.apache.ignite.internal.processors.cache;
 import javax.cache.Cache;
 import org.apache.ignite.Ignite;
 import org.apache.ignite.internal.util.tostring.GridToStringInclude;
-import org.apache.ignite.internal.util.typedef.internal.CU;
 import org.apache.ignite.internal.util.typedef.internal.S;
 
 /**
@@ -44,15 +43,19 @@ public class CacheLazyEntry<K, V> implements Cache.Entry<K, V> {
     @GridToStringInclude
     protected V val;
 
+    /** Keep portable flag. */
+    private boolean keepPortable;
+
     /**
      * @param cctx Cache context.
      * @param keyObj Key cache object.
      * @param valObj Cache object value.
      */
-    public CacheLazyEntry(GridCacheContext cctx, KeyCacheObject keyObj, CacheObject valObj) {
+    public CacheLazyEntry(GridCacheContext cctx, KeyCacheObject keyObj, CacheObject valObj, boolean keepPortable) {
+        this.cctx = cctx;
         this.keyObj = keyObj;
         this.valObj = valObj;
-        this.cctx = cctx;
+        this.keepPortable = keepPortable;
     }
 
     /**
@@ -60,10 +63,11 @@ public class CacheLazyEntry<K, V> implements Cache.Entry<K, V> {
      * @param val Value.
      * @param cctx Cache context.
      */
-    public CacheLazyEntry(GridCacheContext cctx, KeyCacheObject keyObj, V val) {
+    public CacheLazyEntry(GridCacheContext cctx, KeyCacheObject keyObj, V val, boolean keepPortable) {
+        this.cctx = cctx;
         this.keyObj = keyObj;
         this.val = val;
-        this.cctx = cctx;
+        this.keepPortable = keepPortable;
     }
 
     /**
@@ -77,18 +81,21 @@ public class CacheLazyEntry<K, V> implements Cache.Entry<K, V> {
         KeyCacheObject keyObj,
         K key,
         CacheObject valObj,
-        V val) {
+        V val,
+        boolean keepPortable
+    ) {
         this.cctx = ctx;
         this.keyObj = keyObj;
         this.key = key;
         this.valObj = valObj;
         this.val = val;
+        this.keepPortable = keepPortable;
     }
 
     /** {@inheritDoc} */
     @Override public K getKey() {
         if (key == null)
-            key = CU.value(keyObj, cctx, true);
+            key = (K)cctx.unwrapPortableIfNeeded(keyObj, keepPortable);
 
         return key;
     }
@@ -96,7 +103,7 @@ public class CacheLazyEntry<K, V> implements Cache.Entry<K, V> {
     /** {@inheritDoc} */
     @Override public V getValue() {
         if (val == null)
-            val = CU.value(valObj, cctx, true);
+            val = (V)cctx.unwrapPortableIfNeeded(valObj, keepPortable);
 
         return val;
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/d5df41bd/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObject.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObject.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObject.java
index d870a6c..d889902 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObject.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObject.java
@@ -51,6 +51,15 @@ public interface CacheObject extends Message {
     public byte type();
 
     /**
+     * Gets flag indicating whether object value is a platform type. Platform types will be automatically
+     * deserialized on public API cache operations regardless whether
+     * {@link org.apache.ignite.IgniteCache#withKeepPortable()} is used or not.
+     *
+     * @return Platform type flag.
+     */
+    public boolean isPlatformType();
+
+    /**
      * Prepares cache object for cache (e.g. copies user-provided object if needed).
      *
      * @param ctx Cache context.

http://git-wip-us.apache.org/repos/asf/ignite/blob/d5df41bd/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectByteArrayImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectByteArrayImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectByteArrayImpl.java
index 32f5f88..b7c8a61 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectByteArrayImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectByteArrayImpl.java
@@ -80,6 +80,11 @@ public class CacheObjectByteArrayImpl implements CacheObject, Externalizable {
     }
 
     /** {@inheritDoc} */
+    @Override public boolean isPlatformType() {
+        return true;
+    }
+
+    /** {@inheritDoc} */
     @Override public CacheObject prepareForCache(CacheObjectContext ctx) {
         return this;
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/d5df41bd/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 7d7cbec..e7e081b 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
@@ -17,10 +17,17 @@
 
 package org.apache.ignite.internal.processors.cache;
 
+import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
 import org.apache.ignite.cache.affinity.AffinityKeyMapper;
 import org.apache.ignite.internal.GridKernalContext;
+import org.apache.ignite.internal.portable.PortableUtils;
 import org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProcessor;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.portable.PortableObject;
 
 /**
  *
@@ -105,25 +112,119 @@ public class CacheObjectContext {
         return proc;
     }
 
+    /** {@inheritDoc} */
+    public Object unwrapPortableIfNeeded(Object o, boolean keepPortable) {
+        if (o == null)
+            return null;
+
+        return unwrapPortable(o, keepPortable);
+    }
+
+    /** {@inheritDoc} */
+    public Collection<Object> unwrapPortablesIfNeeded(Collection<Object> col, boolean keepPortable) {
+        if (keepPortable)
+            return col;
+
+        if (col instanceof ArrayList)
+            return unwrapPortables((ArrayList<Object>)col, keepPortable);
+
+        if (col instanceof Set)
+            return unwrapPortables((Set<Object>)col, keepPortable);
+
+        Collection<Object> col0 = new ArrayList<>(col.size());
+
+        for (Object obj : col)
+            col0.add(unwrapPortable(obj, keepPortable));
+
+        return col0;
+    }
+
     /**
-     * Unwraps object.
+     * Unwraps map.
      *
-     * @param o Object to unwrap.
+     * @param map Map to unwrap.
      * @param keepPortable Keep portable flag.
-     * @return Unwrapped object.
+     * @return Unwrapped collection.
      */
-    public Object unwrapPortableIfNeeded(Object o, boolean keepPortable) {
-        return o;
+    public Map<Object, Object> unwrapPortablesIfNeeded(Map<Object, Object> map, boolean keepPortable) {
+        if (keepPortable)
+            return map;
+
+        Map<Object, Object> map0 = PortableUtils.newMap(map);
+
+        for (Map.Entry<Object, Object> e : map.entrySet())
+            map0.put(unwrapPortable(e.getKey(), keepPortable), unwrapPortable(e.getValue(), keepPortable));
+
+        return map0;
     }
 
     /**
-     * Unwraps collection.
+     * Unwraps array list.
      *
-     * @param col Collection to unwrap.
-     * @param keepPortable Keep portable flag.
-     * @return Unwrapped collection.
+     * @param col List to unwrap.
+     * @return Unwrapped list.
      */
-    public Collection<Object> unwrapPortablesIfNeeded(Collection<Object> col, boolean keepPortable) {
+    private Collection<Object> unwrapPortables(ArrayList<Object> col, boolean keepPortable) {
+        int size = col.size();
+
+        for (int i = 0; i < size; i++) {
+            Object o = col.get(i);
+
+            Object unwrapped = unwrapPortable(o, keepPortable);
+
+            if (o != unwrapped)
+                col.set(i, unwrapped);
+        }
+
         return col;
     }
+
+    /**
+     * Unwraps set with portables.
+     *
+     * @param set Set to unwrap.
+     * @return Unwrapped set.
+     */
+    private Set<Object> unwrapPortables(Set<Object> set, boolean keepPortable) {
+        Set<Object> set0 = PortableUtils.newSet(set);
+
+        Iterator<Object> iter = set.iterator();
+
+        while (iter.hasNext())
+            set0.add(unwrapPortable(iter.next(), keepPortable));
+
+        return set0;
+    }
+
+    /**
+     * @param o Object to unwrap.
+     * @return Unwrapped object.
+     */
+    private Object unwrapPortable(Object o, boolean keepPortable) {
+        if (o instanceof Map.Entry) {
+            Map.Entry entry = (Map.Entry)o;
+
+            Object key = entry.getKey();
+
+            Object uKey = unwrapPortable(key, keepPortable);
+
+            Object val = entry.getValue();
+
+            Object uVal = unwrapPortable(val, keepPortable);
+
+            return (key != uKey || val != uVal) ? F.t(key, val) : o;
+        }
+        else if (o instanceof Collection)
+            return unwrapPortablesIfNeeded((Collection<Object>)o, keepPortable);
+        else if (o instanceof Map)
+            return unwrapPortablesIfNeeded((Map<Object, Object>)o, keepPortable);
+        else if (o instanceof CacheObject) {
+            CacheObject co = (CacheObject)o;
+
+            if (!keepPortable || co.isPlatformType())
+                return unwrapPortable(co.value(this, false), keepPortable);
+        }
+
+        return o;
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/d5df41bd/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 83a80b3..d1f7920 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
@@ -47,6 +47,11 @@ public class CacheObjectImpl extends CacheObjectAdapter {
     }
 
     /** {@inheritDoc} */
+    @Override public boolean isPlatformType() {
+        return true; // TODO not true.
+    }
+
+    /** {@inheritDoc} */
     @SuppressWarnings("unchecked")
     @Nullable @Override public <T> T value(CacheObjectContext ctx, boolean cpy) {
         cpy = cpy && needCopy(ctx);
@@ -70,8 +75,8 @@ public class CacheObjectImpl extends CacheObjectAdapter {
 
             Object val = ctx.processor().unmarshal(ctx, valBytes, ctx.kernalContext().config().getClassLoader());
 
-            if (ctx.storeValue())
-                this.val = val;
+//            if (ctx.storeValue())
+//                this.val = val;
 
             return (T)val;
         }
@@ -100,8 +105,8 @@ public class CacheObjectImpl extends CacheObjectAdapter {
     @Override public void finishUnmarshal(CacheObjectContext ctx, ClassLoader ldr) throws IgniteCheckedException {
         assert val != null || valBytes != null;
 
-        if (val == null && ctx.storeValue())
-            val = ctx.processor().unmarshal(ctx, valBytes, ldr);
+//        if (val == null && ctx.storeValue())
+//            val = ctx.processor().unmarshal(ctx, valBytes, ldr);
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/d5df41bd/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 3a1cee6..1bb71f9 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
@@ -1851,15 +1851,9 @@ public class GridCacheContext<K, V> implements Externalizable {
         assert val != null || skipVals;
 
         if (!keepCacheObjects) {
-            Object key0 = key.value(cacheObjCtx, false);
-            Object val0 = skipVals ? true : val.value(cacheObjCtx, cpy);
+            Object key0 = unwrapPortableIfNeeded(key, !deserializePortable);
 
-            if (deserializePortable) {
-                key0 = unwrapPortableIfNeeded(key0, false);
-
-                if (!skipVals)
-                    val0 = unwrapPortableIfNeeded(val0, false);
-            }
+            Object val0 = skipVals ? true : unwrapPortableIfNeeded(val, !deserializePortable);
 
             assert key0 != null : key;
             assert val0 != null : val;

http://git-wip-us.apache.org/repos/asf/ignite/blob/d5df41bd/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java
index 430590a..1068342 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java
@@ -349,6 +349,7 @@ public interface GridCacheEntryEx {
         long ttl,
         boolean evt,
         boolean metrics,
+        boolean keepPortable,
         AffinityTopologyVersion topVer,
         CacheEntryPredicate[] filter,
         GridDrType drType,
@@ -385,6 +386,7 @@ public interface GridCacheEntryEx {
         boolean retval,
         boolean evt,
         boolean metrics,
+        boolean keepPortable,
         AffinityTopologyVersion topVer,
         CacheEntryPredicate[] filter,
         GridDrType drType,
@@ -436,6 +438,7 @@ public interface GridCacheEntryEx {
         boolean writeThrough,
         boolean readThrough,
         boolean retval,
+        boolean keepPortable,
         @Nullable IgniteCacheExpiryPolicy expiryPlc,
         boolean evt,
         boolean metrics,
@@ -482,6 +485,7 @@ public interface GridCacheEntryEx {
         boolean writeThrough,
         boolean readThrough,
         boolean retval,
+        boolean keepPortable,
         @Nullable ExpiryPolicy expiryPlc,
         boolean evt,
         boolean metrics,

http://git-wip-us.apache.org/repos/asf/ignite/blob/d5df41bd/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEventManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEventManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEventManager.java
index 751c316..138b33b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEventManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEventManager.java
@@ -265,9 +265,9 @@ public class GridCacheEventManager extends GridCacheManagerAdapter {
                 key == null ? null : key.value(cctx.cacheObjectContext(), false),
                 xid,
                 lockId,
-                CU.value(newVal, cctx, false),
+                newVal,
                 hasNewVal,
-                CU.value(oldVal, cctx, false),
+                oldVal,
                 hasOldVal,
                 subjId,
                 cloClsName,

http://git-wip-us.apache.org/repos/asf/ignite/blob/d5df41bd/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 4bf0aa1..c45fed8 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
@@ -1009,6 +1009,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
         long ttl,
         boolean evt,
         boolean metrics,
+        boolean keepPortable,
         AffinityTopologyVersion topVer,
         CacheEntryPredicate[] filter,
         GridDrType drType,
@@ -1054,9 +1055,9 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
             if (intercept) {
                 val0 = CU.value(val, cctx, false);
 
-                CacheLazyEntry e = new CacheLazyEntry(cctx, key, old);
+                CacheLazyEntry e = new CacheLazyEntry(cctx, key, old, keepPortable);
 
-                Object interceptorVal = cctx.config().getInterceptor().onBeforePut(new CacheLazyEntry(cctx, key, old),
+                Object interceptorVal = cctx.config().getInterceptor().onBeforePut(new CacheLazyEntry(cctx, key, old, keepPortable),
                     val0);
 
                 key0 = e.key();
@@ -1141,7 +1142,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
             cctx.store().put(tx, keyValue(false), CU.value(val, cctx, false), newVer);
 
         if (intercept)
-            cctx.config().getInterceptor().onAfterPut(new CacheLazyEntry(cctx, key, key0, val, val0));
+            cctx.config().getInterceptor().onAfterPut(new CacheLazyEntry(cctx, key, key0, val, val0, keepPortable));
 
         return valid ? new GridCacheUpdateTxResult(true, retval ? old : null) :
             new GridCacheUpdateTxResult(false, null);
@@ -1164,6 +1165,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
         boolean retval,
         boolean evt,
         boolean metrics,
+        boolean keepPortable,
         AffinityTopologyVersion topVer,
         CacheEntryPredicate[] filter,
         GridDrType drType,
@@ -1209,7 +1211,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
             old = (retval || intercept) ? rawGetOrUnmarshalUnlocked(!retval) : val;
 
             if (intercept) {
-                entry0 = new CacheLazyEntry(cctx, key, old);
+                entry0 = new CacheLazyEntry(cctx, key, old, keepPortable);
 
                 interceptRes = cctx.config().getInterceptor().onBeforeRemove(entry0);
 
@@ -1351,6 +1353,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
         boolean writeThrough,
         boolean readThrough,
         boolean retval,
+        boolean keepPortable,
         @Nullable ExpiryPolicy expiryPlc,
         boolean evt,
         boolean metrics,
@@ -1452,7 +1455,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
 
                 assert entryProcessor != null;
 
-                CacheInvokeEntry<Object, Object> entry = new CacheInvokeEntry<>(cctx, key, old, version());
+                CacheInvokeEntry<Object, Object> entry = new CacheInvokeEntry<>(cctx, key, old, version(), keepPortable);
 
                 try {
                     Object computed = entryProcessor.process(entry, invokeArgs);
@@ -1493,7 +1496,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
                 if (op == GridCacheOperation.UPDATE) {
                     updated0 = value(updated0, updated, false);
 
-                    e = new CacheLazyEntry(cctx, key, key0, old, old0);
+                    e = new CacheLazyEntry(cctx, key, key0, old, old0, keepPortable);
 
                     Object interceptorVal = cctx.config().getInterceptor().onBeforePut(e, updated0);
 
@@ -1506,7 +1509,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
                     }
                 }
                 else {
-                    e = new CacheLazyEntry(cctx, key, key0, old, old0);
+                    e = new CacheLazyEntry(cctx, key, key0, old, old0, keepPortable);
 
                     interceptorRes = cctx.config().getInterceptor().onBeforeRemove(e);
 
@@ -1633,9 +1636,9 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
 
             if (intercept) {
                 if (op == GridCacheOperation.UPDATE)
-                    cctx.config().getInterceptor().onAfterPut(new CacheLazyEntry(cctx, key, key0, updated, updated0));
+                    cctx.config().getInterceptor().onAfterPut(new CacheLazyEntry(cctx, key, key0, updated, updated0, keepPortable));
                 else
-                    cctx.config().getInterceptor().onAfterRemove(new CacheLazyEntry(cctx, key, key0, old, old0));
+                    cctx.config().getInterceptor().onAfterRemove(new CacheLazyEntry(cctx, key, key0, old, old0, keepPortable));
             }
         }
 
@@ -1656,6 +1659,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
         boolean writeThrough,
         boolean readThrough,
         boolean retval,
+        boolean keepPortable,
         @Nullable IgniteCacheExpiryPolicy expiryPlc,
         boolean evt,
         boolean metrics,
@@ -1723,7 +1727,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
 
                         oldVal = rawGetOrUnmarshalUnlocked(true);
 
-                        CacheInvokeEntry<Object, Object> entry = new CacheInvokeEntry(cctx, key, oldVal, version());
+                        CacheInvokeEntry<Object, Object> entry = new CacheInvokeEntry(cctx, key, oldVal, version(), keepPortable);
 
                         try {
                             Object computed = entryProcessor.process(entry, invokeArgs);
@@ -1948,7 +1952,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
 
                 EntryProcessor<Object, Object, ?> entryProcessor = (EntryProcessor<Object, Object, ?>)writeObj;
 
-                CacheInvokeEntry<Object, Object> entry = new CacheInvokeEntry(cctx, key, oldVal, version());
+                CacheInvokeEntry<Object, Object> entry = new CacheInvokeEntry(cctx, key, oldVal, version(), keepPortable);
 
                 try {
                     Object computed = entryProcessor.process(entry, invokeArgs);
@@ -2072,7 +2076,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
                     updated0 = value(updated0, updated, false);
 
                     Object interceptorVal = cctx.config().getInterceptor()
-                        .onBeforePut(new CacheLazyEntry(cctx, key, key0, oldVal, old0), updated0);
+                        .onBeforePut(new CacheLazyEntry(cctx, key, key0, oldVal, old0, keepPortable), updated0);
 
                     if (interceptorVal == null)
                         return new GridCacheUpdateAtomicResult(false,
@@ -2148,7 +2152,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
             else {
                 if (intercept) {
                     interceptRes = cctx.config().getInterceptor().onBeforeRemove(new CacheLazyEntry(cctx, key, key0,
-                        oldVal, old0));
+                        oldVal, old0, keepPortable));
 
                     if (cctx.cancelRemove(interceptRes))
                         return new GridCacheUpdateAtomicResult(false,
@@ -2247,9 +2251,9 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
 
             if (intercept) {
                 if (op == GridCacheOperation.UPDATE)
-                    cctx.config().getInterceptor().onAfterPut(new CacheLazyEntry(cctx, key, key0, updated, updated0));
+                    cctx.config().getInterceptor().onAfterPut(new CacheLazyEntry(cctx, key, key0, updated, updated0, keepPortable));
                 else
-                    cctx.config().getInterceptor().onAfterRemove(new CacheLazyEntry(cctx, key, key0, oldVal, old0));
+                    cctx.config().getInterceptor().onAfterRemove(new CacheLazyEntry(cctx, key, key0, oldVal, old0, keepPortable));
 
                 if (interceptRes != null)
                     oldVal = cctx.toCacheObject(cctx.unwrapTemporary(interceptRes.get2()));

http://git-wip-us.apache.org/repos/asf/ignite/blob/d5df41bd/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
index 7854c93..2a13242 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
@@ -147,6 +147,9 @@ public class GridCacheUtils {
     /** Skip store flag bit mask. */
     public static final int SKIP_STORE_FLAG_MASK = 0x1;
 
+    /** Keep serialized flag. */
+    public static final int KEEP_BINARY_FLAG_MASK = 0x2;
+
     /** Empty predicate array. */
     private static final IgnitePredicate[] EMPTY = new IgnitePredicate[0];
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/d5df41bd/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 6958c87..4db7ec1 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
@@ -61,6 +61,11 @@ public class KeyCacheObjectImpl extends CacheObjectAdapter implements KeyCacheOb
     }
 
     /** {@inheritDoc} */
+    @Override public boolean isPlatformType() {
+        return true;
+    }
+
+    /** {@inheritDoc} */
     @SuppressWarnings("unchecked")
     @Nullable @Override public <T> T value(CacheObjectContext ctx, boolean cpy) {
         assert val != null;

http://git-wip-us.apache.org/repos/asf/ignite/blob/d5df41bd/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 1963894..698c6ee 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
@@ -39,6 +39,7 @@ import org.apache.ignite.plugin.extensions.communication.MessageWriter;
 import org.apache.ignite.transactions.TransactionIsolation;
 import org.jetbrains.annotations.Nullable;
 
+import static org.apache.ignite.internal.processors.cache.GridCacheUtils.KEEP_BINARY_FLAG_MASK;
 import static org.apache.ignite.internal.processors.cache.GridCacheUtils.SKIP_STORE_FLAG_MASK;
 
 /**
@@ -240,6 +241,17 @@ public class GridDistributedLockRequest extends GridDistributedBaseMessage {
         return (flags & SKIP_STORE_FLAG_MASK) == 1;
     }
 
+    public void keepBinary(boolean keepBinary) {
+        flags = keepBinary ? (byte)(flags | KEEP_BINARY_FLAG_MASK) : (byte)(flags & ~KEEP_BINARY_FLAG_MASK);
+    }
+
+    /**
+     * @return Keep portable.
+     */
+    public boolean keepBinary() {
+        return (flags & KEEP_BINARY_FLAG_MASK) != 0;
+    }
+
     /**
      * @return Transaction isolation or <tt>null</tt> if not in transaction.
      */

http://git-wip-us.apache.org/repos/asf/ignite/blob/d5df41bd/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxRemoteAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxRemoteAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxRemoteAdapter.java
index f969737..057d072 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxRemoteAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedTxRemoteAdapter.java
@@ -572,15 +572,39 @@ public class GridDistributedTxRemoteAdapter extends IgniteTxAdapter
                                     if (op == CREATE || op == UPDATE) {
                                         // Invalidate only for near nodes (backups cannot be invalidated).
                                         if (isSystemInvalidate() || (isInvalidate() && cacheCtx.isNear()))
-                                            cached.innerRemove(this, eventNodeId(), nodeId, false, false, true, true,
-                                                topVer, null, replicate ? DR_BACKUP : DR_NONE,
-                                                near() ? null : explicitVer, CU.subjectId(this, cctx),
+                                            cached.innerRemove(
+                                                this,
+                                                eventNodeId(),
+                                                nodeId,
+                                                false,
+                                                false,
+                                                true,
+                                                true,
+                                                txEntry.keepBinary(),
+                                                topVer,
+                                                null,
+                                                replicate ? DR_BACKUP : DR_NONE,
+                                                near() ? null : explicitVer,
+                                                CU.subjectId(this, cctx),
                                                 resolveTaskName());
                                         else {
-                                            cached.innerSet(this, eventNodeId(), nodeId, val, false, false,
-                                                txEntry.ttl(), true, true, topVer, null,
-                                                replicate ? DR_BACKUP : DR_NONE, txEntry.conflictExpireTime(),
-                                                near() ? null : explicitVer, CU.subjectId(this, cctx),
+                                            cached.innerSet(
+                                                this,
+                                                eventNodeId(),
+                                                nodeId,
+                                                val,
+                                                false,
+                                                false,
+                                                txEntry.ttl(),
+                                                true,
+                                                true,
+                                                txEntry.keepBinary(),
+                                                topVer,
+                                                null,
+                                                replicate ? DR_BACKUP : DR_NONE,
+                                                txEntry.conflictExpireTime(),
+                                                near() ? null : explicitVer,
+                                                CU.subjectId(this, cctx),
                                                 resolveTaskName());
 
                                             // Keep near entry up to date.
@@ -597,9 +621,21 @@ public class GridDistributedTxRemoteAdapter extends IgniteTxAdapter
                                         }
                                     }
                                     else if (op == DELETE) {
-                                        cached.innerRemove(this, eventNodeId(), nodeId, false, false, true, true,
-                                            topVer, null, replicate ? DR_BACKUP : DR_NONE,
-                                            near() ? null : explicitVer, CU.subjectId(this, cctx), resolveTaskName());
+                                        cached.innerRemove(
+                                            this,
+                                            eventNodeId(),
+                                            nodeId,
+                                            false,
+                                            false,
+                                            true,
+                                            true,
+                                            txEntry.keepBinary(),
+                                            topVer,
+                                            null,
+                                            replicate ? DR_BACKUP : DR_NONE,
+                                            near() ? null : explicitVer,
+                                            CU.subjectId(this, cctx),
+                                            resolveTaskName());
 
                                         // Keep near entry up to date.
                                         if (nearCached != null)

http://git-wip-us.apache.org/repos/asf/ignite/blob/d5df41bd/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java
index 1a869e7..bec91f2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java
@@ -256,7 +256,8 @@ public abstract class GridDhtTransactionalCacheAdapter<K, V> extends GridDhtCach
                                 null,
                                 null,
                                 req.accessTtl(),
-                                req.skipStore());
+                                req.skipStore(),
+                                req.keepBinary());
                         }
 
                         entry = entryExx(key, req.topologyVersion());
@@ -915,7 +916,8 @@ public abstract class GridDhtTransactionalCacheAdapter<K, V> extends GridDhtCach
                     req.txRead(),
                     req.needReturnValue(),
                     req.accessTtl(),
-                    req.skipStore());
+                    req.skipStore(),
+                    req.keepBinary());
 
                 final GridDhtTxLocal t = tx;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/d5df41bd/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java
index 8c7d985..c07f854 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java
@@ -153,7 +153,7 @@ public abstract class GridDhtTxLocalAdapter extends IgniteTxLocalAdapter {
             invalidate,
             storeEnabled,
             onePhaseCommit,
-            txSize, 
+            txSize,
             subjId, 
             taskNameHash
         );
@@ -613,7 +613,8 @@ public abstract class GridDhtTxLocalAdapter extends IgniteTxLocalAdapter {
         final boolean read,
         final boolean needRetVal,
         long accessTtl,
-        boolean skipStore
+        boolean skipStore,
+        boolean keepBinary
     ) {
         try {
             checkValid();
@@ -681,7 +682,8 @@ public abstract class GridDhtTxLocalAdapter extends IgniteTxLocalAdapter {
                         -1L,
                         -1L,
                         null,
-                        skipStore);
+                        skipStore,
+                        keepBinary);
 
                     if (read)
                         txEntry.ttl(accessTtl);

http://git-wip-us.apache.org/repos/asf/ignite/blob/d5df41bd/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
index 761bbb0..3a33bf5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
@@ -377,8 +377,8 @@ public final class GridDhtTxPrepareFuture extends GridCompoundFuture<IgniteInter
 
                              for (T2<EntryProcessor<Object, Object, Object>, Object[]> t : txEntry.entryProcessors()) {
                                 try {
-                                    CacheInvokeEntry<Object, Object> invokeEntry =
-                                        new CacheInvokeEntry<>(txEntry.context(), key, val, txEntry.cached().version());
+                                    CacheInvokeEntry<Object, Object> invokeEntry = new CacheInvokeEntry<>(
+                                        txEntry.context(), key, val, txEntry.cached().version(), txEntry.keepBinary());
 
                                     EntryProcessor<Object, Object, Object> processor = t.get1();
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/d5df41bd/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxRemote.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxRemote.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxRemote.java
index f8be2a7..ad8a402 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxRemote.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxRemote.java
@@ -122,9 +122,9 @@ public class GridDhtTxRemote extends GridDistributedTxRemoteAdapter {
             concurrency, 
             isolation, 
             invalidate, 
-            timeout, 
+            timeout,
             txSize,
-            subjId, 
+            subjId,
             taskNameHash
         );
 
@@ -193,7 +193,7 @@ public class GridDhtTxRemote extends GridDistributedTxRemoteAdapter {
             concurrency, 
             isolation, 
             invalidate, 
-            timeout, 
+            timeout,
             txSize,
             subjId, 
             taskNameHash
@@ -335,7 +335,8 @@ public class GridDhtTxRemote extends GridDistributedTxRemoteAdapter {
         @Nullable CacheObject val,
         @Nullable Collection<T2<EntryProcessor<Object, Object, Object>, Object[]>> entryProcessors,
         long ttl,
-        boolean skipStore) {
+        boolean skipStore,
+        boolean keepBinary) {
         checkInternal(key);
 
         if (isSystemInvalidate())
@@ -351,7 +352,8 @@ public class GridDhtTxRemote extends GridDistributedTxRemoteAdapter {
             -1L,
             cached,
             null,
-            skipStore);
+            skipStore,
+            keepBinary);
 
         txEntry.entryProcessors(entryProcessors);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/d5df41bd/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
index 854a83d..b740d27 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
@@ -836,6 +836,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
             subjId,
             taskNameHash,
             opCtx != null && opCtx.skipStore(),
+            opCtx != null && opCtx.isKeepPortable(),
             opCtx != null && opCtx.noRetries() ? 1 : MAX_RETRIES,
             waitTopFut);
 
@@ -901,6 +902,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
             subjId,
             taskNameHash,
             opCtx != null && opCtx.skipStore(),
+            opCtx != null && opCtx.isKeepPortable(),
             opCtx != null && opCtx.noRetries() ? 1 : MAX_RETRIES,
             true);
 
@@ -1397,7 +1399,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
                     Object updatedVal = null;
 
                     CacheInvokeEntry<Object, Object> invokeEntry = new CacheInvokeEntry(ctx, entry.key(), old,
-                        entry.version());
+                        entry.version(), req.keepBinary());
 
                     CacheObject updated;
 
@@ -1426,7 +1428,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
 
                     if (updated == null) {
                         if (intercept) {
-                            CacheLazyEntry e = new CacheLazyEntry(ctx, entry.key(), invokeEntry.key(), old, oldVal);
+                            CacheLazyEntry e = new CacheLazyEntry(ctx, entry.key(), invokeEntry.key(), old, oldVal, req.keepBinary());
 
                             IgniteBiTuple<Boolean, ?> interceptorRes = ctx.config().getInterceptor().onBeforeRemove(e);
 
@@ -1472,7 +1474,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
                     }
                     else {
                         if (intercept) {
-                            CacheLazyEntry e = new CacheLazyEntry(ctx, entry.key(), invokeEntry.key(), old, oldVal);
+                            CacheLazyEntry e = new CacheLazyEntry(ctx, entry.key(), invokeEntry.key(), old, oldVal, req.keepBinary());
 
                             Object val = ctx.config().getInterceptor().onBeforePut(e, updatedVal);
 
@@ -1544,7 +1546,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
                             null);
 
                         Object val = ctx.config().getInterceptor().onBeforePut(new CacheLazyEntry(ctx, entry.key(),
-                            old),
+                            old, req.keepBinary()),
                             updated.value(ctx.cacheObjectContext(), false));
 
                         if (val == null)
@@ -1582,7 +1584,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
                             null);
 
                         IgniteBiTuple<Boolean, ?> interceptorRes = ctx.config().getInterceptor()
-                            .onBeforeRemove(new CacheLazyEntry(ctx, entry.key(), old));
+                            .onBeforeRemove(new CacheLazyEntry(ctx, entry.key(), old, req.keepBinary()));
 
                         if (ctx.cancelRemove(interceptorRes))
                             continue;
@@ -1768,6 +1770,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
                     primary && writeThrough() && !req.skipStore(),
                     !req.skipStore(),
                     req.returnValue(),
+                    req.keepBinary(),
                     expiry,
                     true,
                     true,
@@ -2037,6 +2040,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
                         /*write-through*/false,
                         /*read-through*/false,
                         /*retval*/false,
+                        req.keepBinary(),
                         expiry,
                         /*event*/true,
                         /*metrics*/true,
@@ -2061,14 +2065,15 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
                             ctx.config().getInterceptor().onAfterPut(new CacheLazyEntry(
                                 ctx,
                                 entry.key(),
-                                updRes.newValue()));
+                                updRes.newValue(),
+                                req.keepBinary()));
                         }
                         else {
                             assert op == DELETE : op;
 
                             // Old value should be already loaded for 'CacheInterceptor.onBeforeRemove'.
                             ctx.config().getInterceptor().onAfterRemove(new CacheLazyEntry(ctx, entry.key(),
-                                updRes.oldValue()));
+                                updRes.oldValue(), req.keepBinary()));
                         }
                     }
 
@@ -2368,6 +2373,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
             req.subjectId(),
             req.taskNameHash(),
             req.skipStore(),
+            req.keepBinary(),
             MAX_RETRIES,
             true);
 
@@ -2517,6 +2523,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
                             /*write-through*/false,
                             /*read-through*/false,
                             /*retval*/false,
+                            req.keepPortable(),
                             /*expiry policy*/null,
                             /*event*/true,
                             /*metrics*/true,

http://git-wip-us.apache.org/repos/asf/ignite/blob/d5df41bd/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java
index f5231ef..4c96c3c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java
@@ -139,6 +139,9 @@ public class GridDhtAtomicUpdateRequest extends GridCacheMessage implements Grid
     /** Task name hash. */
     private int taskNameHash;
 
+    /** Keep portable flag. */
+    private boolean keepPortable;
+
     /**
      * Empty constructor required by {@link Externalizable}.
      */
@@ -416,6 +419,13 @@ public class GridDhtAtomicUpdateRequest extends GridCacheMessage implements Grid
     }
 
     /**
+     * @return Keep portable flag.
+     */
+    public boolean keepPortable() {
+        return keepPortable;
+    }
+
+    /**
      * @param idx Key index.
      * @return Value.
      */

http://git-wip-us.apache.org/repos/asf/ignite/blob/d5df41bd/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java
index 97aa646..3b197bc 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java
@@ -138,6 +138,9 @@ public class GridNearAtomicUpdateFuture extends GridFutureAdapter<Object>
     /** Skip store flag. */
     private final boolean skipStore;
 
+    /** */
+    private final boolean keepBinary;
+
     /** Wait for topology future flag. */
     private final boolean waitTopFut;
 
@@ -184,6 +187,7 @@ public class GridNearAtomicUpdateFuture extends GridFutureAdapter<Object>
         UUID subjId,
         int taskNameHash,
         boolean skipStore,
+        boolean keepBinary,
         int remapCnt,
         boolean waitTopFut
     ) {
@@ -209,6 +213,7 @@ public class GridNearAtomicUpdateFuture extends GridFutureAdapter<Object>
         this.subjId = subjId;
         this.taskNameHash = taskNameHash;
         this.skipStore = skipStore;
+        this.keepBinary = keepBinary;
         this.waitTopFut = waitTopFut;
 
         if (log == null)
@@ -1048,6 +1053,7 @@ public class GridNearAtomicUpdateFuture extends GridFutureAdapter<Object>
                             subjId,
                             taskNameHash,
                             skipStore,
+                            keepBinary,
                             cctx.kernalContext().clientNode());
 
                         pendingMappings.put(nodeId, mapped);
@@ -1140,6 +1146,7 @@ public class GridNearAtomicUpdateFuture extends GridFutureAdapter<Object>
                 subjId,
                 taskNameHash,
                 skipStore,
+                keepBinary,
                 cctx.kernalContext().clientNode());
 
             req.addUpdateEntry(cacheKey,

http://git-wip-us.apache.org/repos/asf/ignite/blob/d5df41bd/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java
index ccb67d2..bbf3e3a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java
@@ -151,6 +151,9 @@ public class GridNearAtomicUpdateRequest extends GridCacheMessage implements Gri
     /** */
     private boolean clientReq;
 
+    /** Keep portable flag. */
+    private boolean keepBinary;
+
     /**
      * Empty constructor required by {@link Externalizable}.
      */
@@ -196,6 +199,7 @@ public class GridNearAtomicUpdateRequest extends GridCacheMessage implements Gri
         @Nullable UUID subjId,
         int taskNameHash,
         boolean skipStore,
+        boolean keepBinary,
         boolean clientReq
     ) {
         assert futVer != null;
@@ -217,6 +221,7 @@ public class GridNearAtomicUpdateRequest extends GridCacheMessage implements Gri
         this.subjId = subjId;
         this.taskNameHash = taskNameHash;
         this.skipStore = skipStore;
+        this.keepBinary = keepBinary;
         this.clientReq = clientReq;
 
         keys = new ArrayList<>();
@@ -333,6 +338,13 @@ public class GridNearAtomicUpdateRequest extends GridCacheMessage implements Gri
     }
 
     /**
+     * @return Keep portable flag.
+     */
+    public boolean keepBinary() {
+        return keepBinary;
+    }
+
+    /**
      * @param key Key to add.
      * @param val Optional update value.
      * @param conflictTtl Conflict TTL (optional).

http://git-wip-us.apache.org/repos/asf/ignite/blob/d5df41bd/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearAtomicCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearAtomicCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearAtomicCache.java
index 82054d9..3dfec9e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearAtomicCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearAtomicCache.java
@@ -195,6 +195,7 @@ public class GridNearAtomicCache<K, V> extends GridNearCacheAdapter<K, V> {
                     null,
                     ttl,
                     expireTime,
+                    req.keepBinary(),
                     req.nodeId(),
                     req.subjectId(),
                     taskName);
@@ -224,6 +225,7 @@ public class GridNearAtomicCache<K, V> extends GridNearCacheAdapter<K, V> {
         @Nullable byte[] valBytes,
         long ttl,
         long expireTime,
+        boolean keepPortable,
         UUID nodeId,
         UUID subjId,
         String taskName
@@ -249,6 +251,7 @@ public class GridNearAtomicCache<K, V> extends GridNearCacheAdapter<K, V> {
                         /*write-through*/false,
                         /*read-through*/false,
                         /*retval*/false,
+                        keepPortable,
                         /**expiry policy*/null,
                         /*event*/true,
                         /*metrics*/true,
@@ -347,6 +350,7 @@ public class GridNearAtomicCache<K, V> extends GridNearCacheAdapter<K, V> {
                             /*write-through*/false,
                             /*read-through*/false,
                             /*retval*/false,
+                            req.keepPortable(),
                             null,
                             /*event*/true,
                             /*metrics*/true,

http://git-wip-us.apache.org/repos/asf/ignite/blob/d5df41bd/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTransactionalCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTransactionalCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTransactionalCache.java
index e70c864..99c2b87 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTransactionalCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTransactionalCache.java
@@ -138,6 +138,8 @@ public class GridNearTransactionalCache<K, V> extends GridNearCacheAdapter<K, V>
 
         final boolean skipStore = opCtx != null && opCtx.skipStore();
 
+        final boolean keepBinary = opCtx != null && opCtx.isKeepPortable();
+
         if (tx != null && !tx.implicit() && !skipTx) {
             return asyncOp(tx, new AsyncOp<Map<K, V>>(keys) {
                 @Override public IgniteInternalFuture<Map<K, V>> op(IgniteTxLocalAdapter tx) {
@@ -146,7 +148,7 @@ public class GridNearTransactionalCache<K, V> extends GridNearCacheAdapter<K, V>
                         entry,
                         deserializePortable,
                         skipVals,
-                        false,
+                        keepBinary,
                         skipStore);
                 }
             });
@@ -340,7 +342,8 @@ public class GridNearTransactionalCache<K, V> extends GridNearCacheAdapter<K, V>
                                     GridCacheOperation.NOOP,
                                     null /*Value.*/,
                                     null /*dr version*/,
-                                    req.skipStore());
+                                    req.skipStore(),
+                                    req.keepBinary());
                             }
 
                             // Add remote candidate before reordering.

http://git-wip-us.apache.org/repos/asf/ignite/blob/d5df41bd/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxRemote.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxRemote.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxRemote.java
index 87c68b2..58ee0c6 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxRemote.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxRemote.java
@@ -117,7 +117,7 @@ public class GridNearTxRemote extends GridDistributedTxRemoteAdapter {
             concurrency, 
             isolation, 
             invalidate, 
-            timeout, 
+            timeout,
             txSize,
             subjId, 
             taskNameHash
@@ -187,9 +187,9 @@ public class GridNearTxRemote extends GridDistributedTxRemoteAdapter {
             concurrency, 
             isolation, 
             invalidate, 
-            timeout, 
+            timeout,
             txSize,
-            subjId, 
+            subjId,
             taskNameHash
         );
 
@@ -356,7 +356,8 @@ public class GridNearTxRemote extends GridDistributedTxRemoteAdapter {
         GridCacheOperation op,
         CacheObject val,
         @Nullable GridCacheVersion drVer,
-        boolean skipStore
+        boolean skipStore,
+        boolean keepBinary
     ) throws IgniteCheckedException {
         checkInternal(key);
 
@@ -389,7 +390,8 @@ public class GridNearTxRemote extends GridDistributedTxRemoteAdapter {
                         -1L,
                         cached,
                         drVer,
-                        skipStore);
+                        skipStore,
+                        keepBinary);
 
                     writeMap.put(key, txEntry);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/d5df41bd/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 0bf6ea2..ebeb3ef 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
@@ -153,7 +153,8 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
             false,
             filter,
             ctx.writeThrough(),
-            ctx.readThrough());
+            ctx.readThrough(),
+            ctx.operationContextPerCall().isKeepPortable());
     }
 
     /** {@inheritDoc} */
@@ -173,7 +174,8 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
             false,
             filter,
             ctx.writeThrough(),
-            ctx.readThrough());
+            ctx.readThrough(),
+            ctx.operationContextPerCall().isKeepPortable());
 
         if (statsEnabled)
             metrics0().addPutTimeNanos(System.nanoTime() - start);
@@ -275,7 +277,8 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
             true,
             ctx.equalsValArray(oldVal),
             ctx.writeThrough(),
-            ctx.readThrough());
+            ctx.readThrough(),
+            ctx.operationContextPerCall().isKeepPortable());
     }
 
     /** {@inheritDoc} */
@@ -292,7 +295,8 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
             true,
             ctx.equalsValArray(val),
             ctx.writeThrough(),
-            ctx.readThrough());
+            ctx.readThrough(),
+            ctx.operationContextPerCall().isKeepPortable());
     }
 
     /** {@inheritDoc} */
@@ -331,7 +335,8 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
             false,
             CU.empty0(),
             ctx.writeThrough(),
-            ctx.readThrough());
+            ctx.readThrough(),
+            ctx.operationContextPerCall().isKeepPortable());
 
         if (statsEnabled)
             metrics0().addPutTimeNanos(System.nanoTime() - start);
@@ -359,7 +364,8 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
             false,
             CU.empty0(),
             ctx.writeThrough(),
-            ctx.readThrough());
+            ctx.readThrough(),
+            ctx.operationContextPerCall().isKeepPortable());
     }
 
     /** {@inheritDoc} */
@@ -380,7 +386,8 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
             false,
             CU.empty0(),
             ctx.writeThrough(),
-            ctx.readThrough());
+            ctx.readThrough(),
+            ctx.operationContextPerCall().isKeepPortable());
     }
 
     /** {@inheritDoc} */
@@ -406,7 +413,8 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
             false,
             CU.empty0(),
             ctx.writeThrough(),
-            ctx.readThrough());
+            ctx.readThrough(),
+            ctx.operationContextPerCall().isKeepPortable());
 
         if (statsEnabled && rmv)
             metrics0().addRemoveTimeNanos(System.nanoTime() - start);
@@ -435,7 +443,8 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
             false,
             ctx.equalsValArray(val),
             ctx.writeThrough(),
-            ctx.readThrough());
+            ctx.readThrough(),
+            ctx.operationContextPerCall().isKeepPortable());
     }
 
     /** {@inheritDoc} */
@@ -650,6 +659,8 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
             }
         });
 
+        final boolean keepPortable = ctx.operationContextPerCall().isKeepPortable();
+
         return (Map<K, EntryProcessorResult<T>>)updateAllInternal(TRANSFORM,
             invokeMap.keySet(),
             invokeMap.values(),
@@ -659,7 +670,8 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
             false,
             null,
             ctx.writeThrough(),
-            ctx.readThrough());
+            ctx.readThrough(),
+            keepPortable);
     }
 
     /** {@inheritDoc} */
@@ -733,6 +745,8 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
         if (keyCheck)
             validateCacheKeys(map.keySet());
 
+        final boolean keepPortable = ctx.operationContextPerCall().isKeepPortable();
+
         return (Map<K, EntryProcessorResult<T>>)updateAllInternal(TRANSFORM,
             map.keySet(),
             map.values(),
@@ -742,7 +756,8 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
             false,
             null,
             ctx.writeThrough(),
-            ctx.readThrough());
+            ctx.readThrough(),
+            keepPortable);
     }
 
     /** {@inheritDoc} */
@@ -795,6 +810,8 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
 
         final ExpiryPolicy expiry = expiryPerCall();
 
+        final boolean keepPortable = ctx.operationContextPerCall().isKeepPortable();
+
         IgniteInternalFuture fut = asyncOp(new Callable<Object>() {
             @Override public Object call() throws Exception {
                 return updateAllInternal(op,
@@ -806,7 +823,8 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
                     rawRetval,
                     filter,
                     writeThrough,
-                    readThrough);
+                    readThrough,
+                    keepPortable);
             }
         });
 
@@ -841,6 +859,8 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
 
         final ExpiryPolicy expiryPlc = expiryPerCall();
 
+        final boolean keepPortable = ctx.operationContextPerCall().isKeepPortable();
+
         IgniteInternalFuture fut = asyncOp(new Callable<Object>() {
             @Override public Object call() throws Exception {
                 return updateAllInternal(DELETE,
@@ -852,7 +872,8 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
                     rawRetval,
                     filter,
                     writeThrough,
-                    readThrough);
+                    readThrough,
+                    keepPortable);
             }
         });
 
@@ -888,7 +909,9 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
         boolean rawRetval,
         CacheEntryPredicate[] filter,
         boolean writeThrough,
-        boolean readThrough) throws IgniteCheckedException {
+        boolean readThrough,
+        boolean keepPortable
+    ) throws IgniteCheckedException {
         if (keyCheck)
             validateCacheKeys(keys);
 
@@ -911,6 +934,7 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
                 expiryPlc,
                 ver,
                 filter,
+                keepPortable,
                 subjId,
                 taskName);
         }
@@ -951,6 +975,7 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
                         writeThrough,
                         readThrough,
                         retval,
+                        keepPortable,
                         expiryPlc,
                         true,
                         true,
@@ -1038,6 +1063,7 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
         @Nullable ExpiryPolicy expiryPlc,
         GridCacheVersion ver,
         @Nullable CacheEntryPredicate[] filter,
+        boolean keepPortable,
         UUID subjId,
         String taskName
     ) throws IgniteCheckedException {
@@ -1110,7 +1136,7 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
                         Object oldVal = null;
 
                         CacheInvokeEntry<Object, Object> invokeEntry = new CacheInvokeEntry<>(ctx, entry.key(), old,
-                            entry.version());
+                            entry.version(), keepPortable);
 
                         CacheObject updated;
                         Object updatedVal = null;
@@ -1139,7 +1165,7 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
                             if (intercept) {
                                 IgniteBiTuple<Boolean, ?> interceptorRes = ctx.config().getInterceptor()
                                     .onBeforeRemove(new CacheLazyEntry(ctx, entry.key(), invokeEntry.key(),
-                                        old, oldVal));
+                                        old, oldVal, keepPortable));
 
                                 if (ctx.cancelRemove(interceptorRes))
                                     continue;
@@ -1154,6 +1180,7 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
                                     putMap,
                                     null,
                                     expiryPlc,
+                                    keepPortable,
                                     err,
                                     subjId,
                                     taskName);
@@ -1174,7 +1201,7 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
                             if (intercept) {
                                 Object interceptorVal = ctx.config().getInterceptor()
                                     .onBeforePut(new CacheLazyEntry(ctx, entry.key(), invokeEntry.getKey(),
-                                        old, oldVal), updatedVal);
+                                        old, oldVal, keepPortable), updatedVal);
 
                                 if (interceptorVal == null)
                                     continue;
@@ -1191,6 +1218,7 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
                                     null,
                                     rmvKeys,
                                     expiryPlc,
+                                    keepPortable,
                                     err,
                                     subjId,
                                     taskName);
@@ -1227,7 +1255,7 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
                                 null);
 
                             Object interceptorVal = ctx.config().getInterceptor().onBeforePut(new CacheLazyEntry(
-                                ctx, entry.key(), old), val);
+                                ctx, entry.key(), old, keepPortable), val);
 
                             if (interceptorVal == null)
                                 continue;
@@ -1261,7 +1289,7 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
                                 null);
 
                             IgniteBiTuple<Boolean, ?> interceptorRes = ctx.config().getInterceptor()
-                                .onBeforeRemove(new CacheLazyEntry(ctx, entry.key(), old));
+                                .onBeforeRemove(new CacheLazyEntry(ctx, entry.key(), old, keepPortable));
 
                             if (ctx.cancelRemove(interceptorRes))
                                 continue;
@@ -1298,6 +1326,7 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
                     putMap,
                     rmvKeys,
                     expiryPlc,
+                    keepPortable,
                     err,
                     subjId,
                     taskName);
@@ -1335,6 +1364,7 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
         @Nullable Map<Object, Object> putMap,
         @Nullable Collection<Object> rmvKeys,
         @Nullable ExpiryPolicy expiryPlc,
+        boolean keepPortable,
         @Nullable CachePartialUpdateCheckedException err,
         UUID subjId,
         String taskName
@@ -1404,6 +1434,7 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
                     false,
                     false,
                     false,
+                    keepPortable,
                     expiryPlc,
                     true,
                     true,
@@ -1414,9 +1445,9 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
 
                 if (intercept) {
                     if (op == UPDATE)
-                        ctx.config().getInterceptor().onAfterPut(new CacheLazyEntry(ctx, entry.key(), writeVal));
+                        ctx.config().getInterceptor().onAfterPut(new CacheLazyEntry(ctx, entry.key(), writeVal, keepPortable));
                     else
-                        ctx.config().getInterceptor().onAfterRemove(new CacheLazyEntry(ctx, entry.key(), t.get2()));
+                        ctx.config().getInterceptor().onAfterRemove(new CacheLazyEntry(ctx, entry.key(), t.get2(), keepPortable));
                 }
             }
             catch (GridCacheEntryRemovedException ignore) {


[2/5] ignite git commit: IGNITE-950 - WIP.

Posted by ag...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/d5df41bd/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectPortableContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectPortableContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectPortableContext.java
index 2e0d37d..b22774b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectPortableContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectPortableContext.java
@@ -58,129 +58,4 @@ public class CacheObjectPortableContext extends CacheObjectContext {
     public boolean portableEnabled() {
         return portableEnabled;
     }
-
-    /** {@inheritDoc} */
-    @Override public Object unwrapPortableIfNeeded(Object o, boolean keepPortable) {
-        if (o == null)
-            return null;
-
-        if (keepPortable || !portableEnabled() || !PortableUtils.isPortableOrCollectionType(o.getClass()))
-            return o;
-
-        return unwrapPortable(o);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Collection<Object> unwrapPortablesIfNeeded(Collection<Object> col, boolean keepPortable) {
-        if (keepPortable || !portableEnabled())
-            return col;
-
-        if (col instanceof ArrayList)
-            return unwrapPortables((ArrayList<Object>)col);
-
-        if (col instanceof Set)
-            return unwrapPortables((Set<Object>)col);
-
-        Collection<Object> col0 = new ArrayList<>(col.size());
-
-        for (Object obj : col)
-            col0.add(unwrapPortable(obj));
-
-        return col0;
-    }
-
-    /**
-     * Unwraps map.
-     *
-     * @param map Map to unwrap.
-     * @param keepPortable Keep portable flag.
-     * @return Unwrapped collection.
-     */
-    public Map<Object, Object> unwrapPortablesIfNeeded(Map<Object, Object> map, boolean keepPortable) {
-        if (keepPortable || !portableEnabled())
-            return map;
-
-        Map<Object, Object> map0 = PortableUtils.newMap(map);
-
-        for (Map.Entry<Object, Object> e : map.entrySet())
-            map0.put(unwrapPortable(e.getKey()), unwrapPortable(e.getValue()));
-
-        return map0;
-    }
-
-    /**
-     * Unwraps array list.
-     *
-     * @param col List to unwrap.
-     * @return Unwrapped list.
-     */
-    private Collection<Object> unwrapPortables(ArrayList<Object> col) {
-        int size = col.size();
-
-        for (int i = 0; i < size; i++) {
-            Object o = col.get(i);
-
-            Object unwrapped = unwrapPortable(o);
-
-            if (o != unwrapped)
-                col.set(i, unwrapped);
-        }
-
-        return col;
-    }
-
-    /**
-     * Unwraps set with portables.
-     *
-     * @param set Set to unwrap.
-     * @return Unwrapped set.
-     */
-    private Set<Object> unwrapPortables(Set<Object> set) {
-        Set<Object> set0 = PortableUtils.newSet(set);
-
-        Iterator<Object> iter = set.iterator();
-
-        while (iter.hasNext())
-            set0.add(unwrapPortable(iter.next()));
-
-        return set0;
-    }
-
-    /**
-     * @param o Object to unwrap.
-     * @return Unwrapped object.
-     */
-    private Object unwrapPortable(Object o) {
-        if (o instanceof Map.Entry) {
-            Map.Entry entry = (Map.Entry)o;
-
-            Object key = entry.getKey();
-
-            boolean unwrapped = false;
-
-            if (key instanceof PortableObject) {
-                key = ((PortableObject)key).deserialize();
-
-                unwrapped = true;
-            }
-
-            Object val = entry.getValue();
-
-            if (val instanceof PortableObject) {
-                val = ((PortableObject)val).deserialize();
-
-                unwrapped = true;
-            }
-
-            return unwrapped ? F.t(key, val) : o;
-        }
-        else if (o instanceof Collection)
-            return unwrapPortablesIfNeeded((Collection<Object>)o, false);
-        else if (o instanceof Map)
-            return unwrapPortablesIfNeeded((Map<Object, Object>)o, false);
-        else if (o instanceof PortableObject)
-            return ((PortableObject)o).deserialize();
-
-        return o;
-    }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/d5df41bd/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTransactionsImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTransactionsImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTransactionsImpl.java
index c0c2284..80bd693 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTransactionsImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTransactionsImpl.java
@@ -142,8 +142,13 @@ public class IgniteTransactionsImpl<K, V> implements IgniteTransactionsEx {
      * @return Transaction.
      */
     @SuppressWarnings("unchecked")
-    private IgniteInternalTx txStart0(TransactionConcurrency concurrency, TransactionIsolation isolation,
-        long timeout, int txSize, @Nullable GridCacheContext sysCacheCtx) {
+    private IgniteInternalTx txStart0(
+        TransactionConcurrency concurrency,
+        TransactionIsolation isolation,
+        long timeout,
+        int txSize,
+        @Nullable GridCacheContext sysCacheCtx
+    ) {
         cctx.kernalContext().gateway().readLock();
 
         try {
@@ -158,7 +163,6 @@ public class IgniteTransactionsImpl<K, V> implements IgniteTransactionsEx {
             if (tx != null)
                 throw new IllegalStateException("Failed to start new transaction " +
                     "(current thread already has a transaction): " + tx);
-
             tx = cctx.tm().newTx(
                 false,
                 false,

http://git-wip-us.apache.org/repos/asf/ignite/blob/d5df41bd/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java
index 88752a2..cd9d09d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java
@@ -1306,7 +1306,7 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter
 
                 for (T2<EntryProcessor<Object, Object, Object>, Object[]> t : txEntry.entryProcessors()) {
                     CacheInvokeEntry<Object, Object> invokeEntry = new CacheInvokeEntry(txEntry.context(),
-                        txEntry.key(), key, cacheVal, val, ver);
+                        txEntry.key(), key, cacheVal, val, ver, txEntry.keepBinary());
 
                     try {
                         EntryProcessor<Object, Object, Object> processor = t.get1();

http://git-wip-us.apache.org/repos/asf/ignite/blob/d5df41bd/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java
index 3c33d19..5ff6ada 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java
@@ -54,6 +54,7 @@ import org.jetbrains.annotations.Nullable;
 
 import static org.apache.ignite.internal.processors.cache.GridCacheOperation.READ;
 import static org.apache.ignite.internal.processors.cache.GridCacheOperation.TRANSFORM;
+import static org.apache.ignite.internal.processors.cache.GridCacheUtils.KEEP_BINARY_FLAG_MASK;
 import static org.apache.ignite.internal.processors.cache.GridCacheUtils.SKIP_STORE_FLAG_MASK;
 
 /**
@@ -172,6 +173,7 @@ public class IgniteTxEntry implements GridPeerDeployAware, Message {
     /**
      * Additional flags.
      * GridCacheUtils.SKIP_STORE_FLAG_MASK - for skipStore flag value.
+     * GridCacheUtils.KEEP_BINARY_FLAG_MASK - for withKeepBinary flag.
      */
     private byte flags;
 
@@ -203,7 +205,9 @@ public class IgniteTxEntry implements GridPeerDeployAware, Message {
         long conflictExpireTime,
         GridCacheEntryEx entry,
         @Nullable GridCacheVersion conflictVer,
-        boolean skipStore) {
+        boolean skipStore,
+        boolean keepBinary
+    ) {
         assert ctx != null;
         assert tx != null;
         assert op != null;
@@ -218,6 +222,7 @@ public class IgniteTxEntry implements GridPeerDeployAware, Message {
         this.conflictVer = conflictVer;
 
         skipStore(skipStore);
+        keepBinary(keepBinary);
 
         key = entry.key();
 
@@ -249,7 +254,9 @@ public class IgniteTxEntry implements GridPeerDeployAware, Message {
         GridCacheEntryEx entry,
         CacheEntryPredicate[] filters,
         GridCacheVersion conflictVer,
-        boolean skipStore) {
+        boolean skipStore,
+        boolean keepBinary
+    ) {
         assert ctx != null;
         assert tx != null;
         assert op != null;
@@ -264,6 +271,7 @@ public class IgniteTxEntry implements GridPeerDeployAware, Message {
         this.conflictVer = conflictVer;
 
         skipStore(skipStore);
+        keepBinary(keepBinary);
 
         if (entryProcessor != null)
             addEntryProcessor(entryProcessor, invokeArgs);
@@ -426,14 +434,50 @@ public class IgniteTxEntry implements GridPeerDeployAware, Message {
      * @param skipStore Skip store flag.
      */
     public void skipStore(boolean skipStore){
-        flags = skipStore ? (byte)(flags | SKIP_STORE_FLAG_MASK) : (byte)(flags & ~SKIP_STORE_FLAG_MASK);
+        setFlag(skipStore, SKIP_STORE_FLAG_MASK);
     }
 
     /**
      * @return Skip store flag.
      */
     public boolean skipStore() {
-        return (flags & SKIP_STORE_FLAG_MASK) == 1;
+        return isFlag(SKIP_STORE_FLAG_MASK);
+    }
+
+    /**
+     * Sets keep binary flag value.
+     *
+     * @param keepBinary Keep binary flag value.
+     */
+    public void keepBinary(boolean keepBinary) {
+        setFlag(keepBinary, KEEP_BINARY_FLAG_MASK);
+    }
+
+    /**
+     * @return Keep binary flag value.
+     */
+    public boolean keepBinary() {
+        return isFlag(KEEP_BINARY_FLAG_MASK);
+    }
+
+    /**
+     * Sets flag mask.
+     *
+     * @param flag Set or clear.
+     * @param mask Mask.
+     */
+    private void setFlag(boolean flag, int mask) {
+        flags = flag ? (byte)(flags | mask) : (byte)(flags & ~mask);
+    }
+
+    /**
+     * Reads flag mask.
+     *
+     * @param mask Mask to read.
+     * @return Flag value.
+     */
+    private boolean isFlag(int mask) {
+        return (flags & mask) != 0;
     }
 
     /**
@@ -606,7 +650,7 @@ public class IgniteTxEntry implements GridPeerDeployAware, Message {
         for (T2<EntryProcessor<Object, Object, Object>, Object[]> t : entryProcessors()) {
             try {
                 CacheInvokeEntry<Object, Object> invokeEntry = new CacheInvokeEntry(ctx, key, keyVal, cacheVal, val,
-                    ver);
+                    ver, keepBinary());
 
                 EntryProcessor processor = t.get1();
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/d5df41bd/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
index aa0ffe8..c5def9a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
@@ -214,8 +214,8 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
             timeout,
             invalidate,
             storeEnabled, 
-            onePhaseCommit, 
-            txSize, 
+            onePhaseCommit,
+            txSize,
             subjId, 
             taskNameHash
         );
@@ -634,8 +634,8 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
 
                             if (intercept) {
                                 Object interceptorVal = cacheCtx.config().getInterceptor()
-                                    .onBeforePut(new CacheLazyEntry(cacheCtx, key, e.cached().rawGetOrUnmarshal(true)),
-                                        CU.value(val, cacheCtx, false));
+                                    .onBeforePut(new CacheLazyEntry(cacheCtx, key, e.cached().rawGetOrUnmarshal(true),
+                                        e.keepBinary()), CU.value(val, cacheCtx, false));
 
                                 if (interceptorVal == null)
                                     continue;
@@ -679,7 +679,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
 
                             if (intercept) {
                                 IgniteBiTuple<Boolean, Object> t = cacheCtx.config().getInterceptor().onBeforeRemove(
-                                    new CacheLazyEntry(cacheCtx, key, e.cached().rawGetOrUnmarshal(true)));
+                                    new CacheLazyEntry(cacheCtx, key, e.cached().rawGetOrUnmarshal(true), e.keepBinary()));
 
                                 if (cacheCtx.cancelRemove(t))
                                     continue;
@@ -924,6 +924,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
                                             txEntry.ttl(),
                                             evt,
                                             metrics,
+                                            txEntry.keepBinary(),
                                             topVer,
                                             null,
                                             cached.detached() ? DR_NONE : drType,
@@ -943,6 +944,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
                                                 txEntry.ttl(),
                                                 false,
                                                 metrics,
+                                                txEntry.keepBinary(),
                                                 topVer,
                                                 CU.empty0(),
                                                 DR_NONE,
@@ -960,6 +962,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
                                             false,
                                             evt,
                                             metrics,
+                                            txEntry.keepBinary(),
                                             topVer,
                                             null,
                                             cached.detached()  ? DR_NONE : drType,
@@ -976,6 +979,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
                                                 false,
                                                 false,
                                                 metrics,
+                                                txEntry.keepBinary(),
                                                 topVer,
                                                 CU.empty0(),
                                                 DR_NONE,
@@ -1412,7 +1416,8 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
                                 -1L,
                                 -1L,
                                 null,
-                                skipStore);
+                                skipStore,
+                                keepCacheObjects);
 
                             // As optimization, mark as checked immediately
                             // for non-pessimistic if value is not null.
@@ -1445,7 +1450,8 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
                                 -1L,
                                 -1L,
                                 null,
-                                skipStore);
+                                skipStore,
+                                keepCacheObjects);
 
                             // Mark as checked immediately for non-pessimistic.
                             if (val != null && !pessimistic())
@@ -2112,7 +2118,8 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
         Collection<KeyCacheObject> enlisted,
         @Nullable Map<KeyCacheObject, GridCacheDrInfo> drPutMap,
         @Nullable Map<KeyCacheObject, GridCacheVersion> drRmvMap,
-        boolean skipStore
+        boolean skipStore,
+        boolean keepBinary
     ) {
         assert cached == null || keys.size() == 1;
         assert cached == null || F.first(keys).equals(cached.key());
@@ -2261,7 +2268,8 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
                                         -1L,
                                         -1L,
                                         null,
-                                        skipStore);
+                                        skipStore,
+                                        keepBinary);
 
                                     txEntry.markValid();
                                 }
@@ -2286,7 +2294,8 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
                                 drTtl,
                                 drExpireTime,
                                 drVer,
-                                skipStore);
+                                skipStore,
+                                keepBinary);
 
                             if (!implicit() && readCommitted() && !cacheCtx.offheapTiered())
                                 cacheCtx.evicts().touch(entry, topologyVersion());
@@ -2392,7 +2401,8 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
                             drTtl,
                             drExpireTime,
                             drVer,
-                            skipStore);
+                            skipStore,
+                            keepBinary);
 
                         enlisted.add(cacheKey);
 
@@ -2675,7 +2685,8 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
 
             for (T2<EntryProcessor<Object, Object, Object>, Object[]> t : txEntry.entryProcessors()) {
                 CacheInvokeEntry<Object, Object> invokeEntry =
-                    new CacheInvokeEntry(txEntry.context(), txEntry.key(), key0, cacheVal, val0, ver);
+                    new CacheInvokeEntry(txEntry.context(), txEntry.key(), key0, cacheVal, val0, ver,
+                        txEntry.keepBinary());
 
                 EntryProcessor<Object, Object, ?> entryProcessor = t.get1();
 
@@ -2819,7 +2830,8 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
                 enlisted,
                 drMap,
                 null,
-                opCtx != null && opCtx.skipStore());
+                opCtx != null && opCtx.skipStore(),
+                opCtx != null && opCtx.isKeepPortable());
 
             if (pessimistic()) {
                 // Loose all skipped.
@@ -3048,7 +3060,8 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
                 enlisted,
                 null,
                 drMap,
-                opCtx != null && opCtx.skipStore()
+                opCtx != null && opCtx.skipStore(),
+                opCtx != null && opCtx.isKeepPortable()
             );
 
             if (log.isDebugEnabled())
@@ -3296,7 +3309,9 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
         long drTtl,
         long drExpireTime,
         @Nullable GridCacheVersion drVer,
-        boolean skipStore) {
+        boolean skipStore,
+        boolean keepBinary
+    ) {
         assert invokeArgs == null || op == TRANSFORM;
 
         IgniteTxKey key = entry.txKey();
@@ -3366,7 +3381,8 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
                 entry,
                 filter,
                 drVer,
-                skipStore);
+                skipStore,
+                keepBinary);
 
             txEntry.conflictExpireTime(drExpireTime);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/d5df41bd/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
index 6254605..e3a02cb 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
@@ -44,6 +44,7 @@ import javax.net.ssl.SSLServerSocketFactory;
 import javax.net.ssl.SSLSocketFactory;
 import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteAuthenticationException;
+import org.apache.ignite.IgniteCache;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteException;
 import org.apache.ignite.IgniteLogger;
@@ -59,6 +60,7 @@ import org.apache.ignite.internal.util.typedef.internal.LT;
 import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.lang.IgniteBiTuple;
+import org.apache.ignite.lang.IgniteCallable;
 import org.apache.ignite.lang.IgniteInClosure;
 import org.apache.ignite.lang.IgniteProductVersion;
 import org.apache.ignite.lang.IgniteUuid;

http://git-wip-us.apache.org/repos/asf/ignite/blob/d5df41bd/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 1fef4d5..db02f9d 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
@@ -455,6 +455,7 @@ public class GridCacheTestEntryEx extends GridMetadataAwareAdapter implements Gr
         long ttl,
         boolean evt,
         boolean metrics,
+        boolean keepPortable,
         AffinityTopologyVersion topVer,
         CacheEntryPredicate[] filter, GridDrType drType,
         long drExpireTime, @Nullable GridCacheVersion drVer, UUID subjId, String taskName) throws IgniteCheckedException,
@@ -471,6 +472,7 @@ public class GridCacheTestEntryEx extends GridMetadataAwareAdapter implements Gr
         boolean writeThrough,
         boolean readThrough,
         boolean retval,
+        boolean keepPortable,
         @Nullable ExpiryPolicy expiryPlc,
         boolean evt,
         boolean metrics,
@@ -493,6 +495,7 @@ public class GridCacheTestEntryEx extends GridMetadataAwareAdapter implements Gr
         boolean writeThrough,
         boolean readThrough,
         boolean retval,
+        boolean keepPortable,
         @Nullable IgniteCacheExpiryPolicy expiryPlc,
         boolean evt,
         boolean metrics,
@@ -523,6 +526,7 @@ public class GridCacheTestEntryEx extends GridMetadataAwareAdapter implements Gr
         boolean retval,
         boolean evt,
         boolean metrics,
+        boolean keepPortable,
         AffinityTopologyVersion topVer,
         CacheEntryPredicate[] filter,
         GridDrType drType,

http://git-wip-us.apache.org/repos/asf/ignite/blob/d5df41bd/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCachePortableObjectsAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCachePortableObjectsAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCachePortableObjectsAbstractSelfTest.java
index 7ac8712..5213d21 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCachePortableObjectsAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/GridCachePortableObjectsAbstractSelfTest.java
@@ -381,8 +381,11 @@ public abstract class GridCachePortableObjectsAbstractSelfTest extends GridCommo
 
         for (int i = 0; i < ENTRY_CNT; i++) {
             cacheAsync.get(i);
+
             TestObject obj = cacheAsync.<TestObject>future().get();
 
+            assertNotNull(obj);
+
             assertEquals(i, obj.val);
         }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/d5df41bd/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridIndexingSpiAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridIndexingSpiAbstractSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridIndexingSpiAbstractSelfTest.java
index acfe3b6..8c5e713 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridIndexingSpiAbstractSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridIndexingSpiAbstractSelfTest.java
@@ -570,6 +570,11 @@ public abstract class GridIndexingSpiAbstractSelfTest extends GridCommonAbstract
         }
 
         /** {@inheritDoc} */
+        @Override public boolean isPlatformType() {
+            throw new UnsupportedOperationException();
+        }
+
+        /** {@inheritDoc} */
         @Override public CacheObject prepareForCache(CacheObjectContext ctx) {
             throw new UnsupportedOperationException();
         }


[4/5] ignite git commit: IGNITE-950 - WIP fixing tests.

Posted by ag...@apache.org.
IGNITE-950 - WIP fixing tests.


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

Branch: refs/heads/ignite-950-new
Commit: f812afd1ed0d38771213686744ff9d3926d3ab51
Parents: d5df41b
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Thu Oct 22 10:20:26 2015 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Thu Oct 22 10:20:26 2015 +0300

----------------------------------------------------------------------
 .../internal/processors/cache/CacheObjectContext.java |  2 +-
 .../internal/processors/cache/GridCacheAdapter.java   |  4 +---
 .../internal/processors/cache/GridCacheMapEntry.java  | 14 ++++++++++----
 .../cache/local/atomic/GridLocalAtomicCache.java      |  8 ++++++--
 4 files changed, 18 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/f812afd1/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 e7e081b..a69ee70 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
@@ -222,7 +222,7 @@ public class CacheObjectContext {
             CacheObject co = (CacheObject)o;
 
             if (!keepPortable || co.isPlatformType())
-                return unwrapPortable(co.value(this, false), keepPortable);
+                return unwrapPortable(co.value(this, true), keepPortable);
         }
 
         return o;

http://git-wip-us.apache.org/repos/asf/ignite/blob/f812afd1/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 ae987b7..11bc9a7 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
@@ -811,9 +811,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
             else
                 cacheVal = localCachePeek0(cacheKey, modes.heap, modes.offheap, modes.swap, plc);
 
-            Object val = CU.value(cacheVal, ctx, true);
-
-            val = ctx.unwrapPortableIfNeeded(val, ctx.keepPortable());
+            Object val = ctx.unwrapPortableIfNeeded(cacheVal, ctx.keepPortable());
 
             return (V)val;
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/f812afd1/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 c45fed8..6546d76 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
@@ -3620,7 +3620,9 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
 
     /** {@inheritDoc} */
     @Override public <K, V> Cache.Entry<K, V> wrapLazyValue() {
-        return new LazyValueEntry<>(key);
+        CacheOperationContext opCtx = cctx.operationContextPerCall();
+
+        return new LazyValueEntry<>(key, opCtx != null && opCtx.isKeepPortable());
     }
 
     /** {@inheritDoc} */
@@ -4089,22 +4091,26 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
         /** */
         private final KeyCacheObject key;
 
+        /** */
+        private boolean keepBinary;
+
         /**
          * @param key Key.
          */
-        private LazyValueEntry(KeyCacheObject key) {
+        private LazyValueEntry(KeyCacheObject key, boolean keepBinary) {
             this.key = key;
+            this.keepBinary = keepBinary;
         }
 
         /** {@inheritDoc} */
         @Override public K getKey() {
-            return key.value(cctx.cacheObjectContext(), false);
+            return (K)cctx.cacheObjectContext().unwrapPortableIfNeeded(key, keepBinary);
         }
 
         /** {@inheritDoc} */
         @SuppressWarnings("unchecked")
         @Override public V getValue() {
-            return CU.value(peekVisibleValue(), cctx, true);
+            return (V)cctx.cacheObjectContext().unwrapPortableIfNeeded(peekVisibleValue(), keepBinary);
         }
 
         /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/f812afd1/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 ebeb3ef..bf0bb00 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
@@ -165,6 +165,8 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
 
         long start = statsEnabled ? System.nanoTime() : 0L;
 
+        CacheOperationContext opCtx = ctx.operationContextPerCall();
+
         boolean res = (Boolean)updateAllInternal(UPDATE,
             Collections.singleton(key),
             Collections.singleton(val),
@@ -175,7 +177,7 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
             filter,
             ctx.writeThrough(),
             ctx.readThrough(),
-            ctx.operationContextPerCall().isKeepPortable());
+            opCtx != null && opCtx.isKeepPortable());
 
         if (statsEnabled)
             metrics0().addPutTimeNanos(System.nanoTime() - start);
@@ -404,6 +406,8 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
 
         A.notNull(key, "key");
 
+        CacheOperationContext opCtx = ctx.operationContextPerCall();
+
         Boolean rmv = (Boolean)updateAllInternal(DELETE,
             Collections.singleton(key),
             null,
@@ -414,7 +418,7 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
             CU.empty0(),
             ctx.writeThrough(),
             ctx.readThrough(),
-            ctx.operationContextPerCall().isKeepPortable());
+            opCtx != null && opCtx.isKeepPortable());
 
         if (statsEnabled && rmv)
             metrics0().addRemoveTimeNanos(System.nanoTime() - start);