ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vkuliche...@apache.org
Subject [37/52] [abbrv] incubator-ignite git commit: Merge branch 'sprint-1' of https://git-wip-us.apache.org/repos/asf/incubator-ignite into ignite-61
Date Mon, 02 Feb 2015 03:28:29 GMT
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3dbb6acc/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetResponse.java
----------------------------------------------------------------------
diff --cc modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetResponse.java
index 0000000,9833165..77dd8f6
mode 000000,100644..100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetResponse.java
@@@ -1,0 -1,423 +1,413 @@@
+ /*
+  * Licensed to the Apache Software Foundation (ASF) under one or more
+  * contributor license agreements.  See the NOTICE file distributed with
+  * this work for additional information regarding copyright ownership.
+  * The ASF licenses this file to You under the Apache License, Version 2.0
+  * (the "License"); you may not use this file except in compliance with
+  * the License.  You may obtain a copy of the License at
+  *
+  *      http://www.apache.org/licenses/LICENSE-2.0
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+ 
+ package org.apache.ignite.internal.processors.cache.distributed.near;
+ 
+ import org.apache.ignite.*;
+ import org.apache.ignite.internal.*;
+ import org.apache.ignite.internal.processors.cache.*;
+ import org.apache.ignite.internal.processors.cache.version.*;
+ import org.apache.ignite.internal.util.*;
+ import org.apache.ignite.lang.*;
+ import org.apache.ignite.internal.util.direct.*;
+ import org.apache.ignite.internal.util.tostring.*;
+ import org.apache.ignite.internal.util.typedef.internal.*;
+ 
+ import java.io.*;
+ import java.nio.*;
+ import java.util.*;
+ 
+ /**
+  * Get response.
+  */
+ public class GridNearGetResponse<K, V> extends GridCacheMessage<K, V> implements GridCacheDeployable,
+     GridCacheVersionable {
+     /** */
+     private static final long serialVersionUID = 0L;
+ 
+     /** Future ID. */
+     private IgniteUuid futId;
+ 
+     /** Sub ID. */
+     private IgniteUuid miniId;
+ 
+     /** Version. */
+     private GridCacheVersion ver;
+ 
+     /** Result. */
+     @GridToStringInclude
+     @GridDirectTransient
+     private Collection<GridCacheEntryInfo<K, V>> entries;
+ 
+     /** */
+     private byte[] entriesBytes;
+ 
+     /** Keys to retry due to ownership shift. */
+     @GridToStringInclude
+     @GridDirectCollection(int.class)
+     private Collection<Integer> invalidParts = new GridLeanSet<>();
+ 
+     /** Topology version if invalid partitions is not empty. */
+     private long topVer;
+ 
+     /** Error. */
+     @GridDirectTransient
+     private Throwable err;
+ 
+     /** Serialized error. */
+     private byte[] errBytes;
+ 
+     /**
+      * Empty constructor required for {@link Externalizable}.
+      */
+     public GridNearGetResponse() {
+         // No-op.
+     }
+ 
+     /**
+      * @param cacheId Cache ID.
+      * @param futId Future ID.
+      * @param miniId Sub ID.
+      * @param ver Version.
+      */
+     public GridNearGetResponse(
+         int cacheId,
+         IgniteUuid futId,
+         IgniteUuid miniId,
+         GridCacheVersion ver
+     ) {
+         assert futId != null;
+         assert miniId != null;
+         assert ver != null;
+ 
+         this.cacheId = cacheId;
+         this.futId = futId;
+         this.miniId = miniId;
+         this.ver = ver;
+     }
+ 
+     /**
+      * @return Future ID.
+      */
+     public IgniteUuid futureId() {
+         return futId;
+     }
+ 
+     /**
+      * @return Sub ID.
+      */
+     public IgniteUuid miniId() {
+         return miniId;
+     }
+ 
+     /** {@inheritDoc} */
+     @Override public GridCacheVersion version() {
+         return ver;
+     }
+ 
+     /**
+      * @return Entries.
+      */
+     public Collection<GridCacheEntryInfo<K, V>> entries() {
+         return entries;
+     }
+ 
+     /**
+      * @param entries Entries.
+      */
+     public void entries(Collection<GridCacheEntryInfo<K, V>> entries) {
+         this.entries = entries;
+     }
+ 
+     /**
+      * @return Failed filter set.
+      */
+     public Collection<Integer> invalidPartitions() {
+         return invalidParts;
+     }
+ 
+     /**
+      * @param invalidParts Partitions to retry due to ownership shift.
+      * @param topVer Topology version.
+      */
+     public void invalidPartitions(Collection<Integer> invalidParts, long topVer) {
+         this.invalidParts = invalidParts;
+         this.topVer = topVer;
+     }
+ 
+     /**
+      * @return Topology version if this response has invalid partitions.
+      */
+     @Override public long topologyVersion() {
+         return topVer;
+     }
+ 
+     /**
+      * @return Error.
+      */
+     public Throwable error() {
+         return err;
+     }
+ 
+     /**
+      * @param err Error.
+      */
+     public void error(Throwable err) {
+         this.err = err;
+     }
+ 
+     /** {@inheritDoc}
+      * @param ctx*/
+     @Override public void prepareMarshal(GridCacheSharedContext<K, V> ctx) throws IgniteCheckedException {
+         super.prepareMarshal(ctx);
+ 
+         if (entries != null) {
+             marshalInfos(entries, ctx);
+ 
+             entriesBytes = ctx.marshaller().marshal(entries);
+         }
+ 
+         if (err != null)
+             errBytes = ctx.marshaller().marshal(err);
+     }
+ 
+     /** {@inheritDoc} */
+     @Override public void finishUnmarshal(GridCacheSharedContext<K, V> ctx, ClassLoader ldr) throws IgniteCheckedException {
+         super.finishUnmarshal(ctx, ldr);
+ 
+         if (entriesBytes != null) {
+             entries = ctx.marshaller().unmarshal(entriesBytes, ldr);
+ 
+             unmarshalInfos(entries, ctx.cacheContext(cacheId()), ldr);
+         }
+ 
+         if (errBytes != null)
+             err = ctx.marshaller().unmarshal(errBytes, ldr);
+     }
+ 
+     /** {@inheritDoc} */
+     @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"})
+     @Override public GridTcpCommunicationMessageAdapter clone() {
+         GridNearGetResponse _clone = new GridNearGetResponse();
+ 
+         clone0(_clone);
+ 
+         return _clone;
+     }
+ 
+     /** {@inheritDoc} */
+     @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) {
+         super.clone0(_msg);
+ 
+         GridNearGetResponse _clone = (GridNearGetResponse)_msg;
+ 
+         _clone.futId = futId;
+         _clone.miniId = miniId;
+         _clone.ver = ver;
+         _clone.entries = entries;
+         _clone.entriesBytes = entriesBytes;
+         _clone.invalidParts = invalidParts;
+         _clone.topVer = topVer;
+         _clone.err = err;
+         _clone.errBytes = errBytes;
+     }
+ 
+     /** {@inheritDoc} */
+     @SuppressWarnings("all")
+     @Override public boolean writeTo(ByteBuffer buf) {
+         commState.setBuffer(buf);
+ 
+         if (!super.writeTo(buf))
+             return false;
+ 
+         if (!commState.typeWritten) {
 -            if (!commState.putByte(directType()))
++            if (!commState.putByte(null, directType()))
+                 return false;
+ 
+             commState.typeWritten = true;
+         }
+ 
+         switch (commState.idx) {
+             case 3:
 -                if (!commState.putByteArray(entriesBytes))
++                if (!commState.putByteArray("entriesBytes", entriesBytes))
+                     return false;
+ 
+                 commState.idx++;
+ 
+             case 4:
 -                if (!commState.putByteArray(errBytes))
++                if (!commState.putByteArray("errBytes", errBytes))
+                     return false;
+ 
+                 commState.idx++;
+ 
+             case 5:
 -                if (!commState.putGridUuid(futId))
++                if (!commState.putGridUuid("futId", futId))
+                     return false;
+ 
+                 commState.idx++;
+ 
+             case 6:
+                 if (invalidParts != null) {
+                     if (commState.it == null) {
 -                        if (!commState.putInt(invalidParts.size()))
++                        if (!commState.putInt(null, invalidParts.size()))
+                             return false;
+ 
+                         commState.it = invalidParts.iterator();
+                     }
+ 
+                     while (commState.it.hasNext() || commState.cur != NULL) {
+                         if (commState.cur == NULL)
+                             commState.cur = commState.it.next();
+ 
 -                        if (!commState.putInt((int)commState.cur))
++                        if (!commState.putInt(null, (int)commState.cur))
+                             return false;
+ 
+                         commState.cur = NULL;
+                     }
+ 
+                     commState.it = null;
+                 } else {
 -                    if (!commState.putInt(-1))
++                    if (!commState.putInt(null, -1))
+                         return false;
+                 }
+ 
+                 commState.idx++;
+ 
+             case 7:
 -                if (!commState.putGridUuid(miniId))
++                if (!commState.putGridUuid("miniId", miniId))
+                     return false;
+ 
+                 commState.idx++;
+ 
+             case 8:
 -                if (!commState.putLong(topVer))
++                if (!commState.putLong("topVer", topVer))
+                     return false;
+ 
+                 commState.idx++;
+ 
+             case 9:
 -                if (!commState.putCacheVersion(ver))
++                if (!commState.putCacheVersion("ver", ver))
+                     return false;
+ 
+                 commState.idx++;
+ 
+         }
+ 
+         return true;
+     }
+ 
+     /** {@inheritDoc} */
+     @SuppressWarnings("all")
+     @Override public boolean readFrom(ByteBuffer buf) {
+         commState.setBuffer(buf);
+ 
+         if (!super.readFrom(buf))
+             return false;
+ 
+         switch (commState.idx) {
+             case 3:
 -                byte[] entriesBytes0 = commState.getByteArray();
++                entriesBytes = commState.getByteArray("entriesBytes");
+ 
 -                if (entriesBytes0 == BYTE_ARR_NOT_READ)
++                if (!commState.lastRead())
+                     return false;
+ 
 -                entriesBytes = entriesBytes0;
 -
+                 commState.idx++;
+ 
+             case 4:
 -                byte[] errBytes0 = commState.getByteArray();
++                errBytes = commState.getByteArray("errBytes");
+ 
 -                if (errBytes0 == BYTE_ARR_NOT_READ)
++                if (!commState.lastRead())
+                     return false;
+ 
 -                errBytes = errBytes0;
 -
+                 commState.idx++;
+ 
+             case 5:
 -                IgniteUuid futId0 = commState.getGridUuid();
++                futId = commState.getGridUuid("futId");
+ 
 -                if (futId0 == GRID_UUID_NOT_READ)
++                if (!commState.lastRead())
+                     return false;
+ 
 -                futId = futId0;
 -
+                 commState.idx++;
+ 
+             case 6:
+                 if (commState.readSize == -1) {
 -                    if (buf.remaining() < 4)
 -                        return false;
++                    commState.readSize = commState.getInt(null);
+ 
 -                    commState.readSize = commState.getInt();
++                    if (!commState.lastRead())
++                        return false;
+                 }
+ 
+                 if (commState.readSize >= 0) {
+                     if (invalidParts == null)
+                         invalidParts = new ArrayList<>(commState.readSize);
+ 
+                     for (int i = commState.readItems; i < commState.readSize; i++) {
 -                        if (buf.remaining() < 4)
 -                            return false;
++                        int _val = commState.getInt(null);
+ 
 -                        int _val = commState.getInt();
++                        if (!commState.lastRead())
++                            return false;
+ 
+                         invalidParts.add((Integer)_val);
+ 
+                         commState.readItems++;
+                     }
+                 }
+ 
+                 commState.readSize = -1;
+                 commState.readItems = 0;
+ 
+                 commState.idx++;
+ 
+             case 7:
 -                IgniteUuid miniId0 = commState.getGridUuid();
++                miniId = commState.getGridUuid("miniId");
+ 
 -                if (miniId0 == GRID_UUID_NOT_READ)
++                if (!commState.lastRead())
+                     return false;
+ 
 -                miniId = miniId0;
 -
+                 commState.idx++;
+ 
+             case 8:
 -                if (buf.remaining() < 8)
 -                    return false;
++                topVer = commState.getLong("topVer");
+ 
 -                topVer = commState.getLong();
++                if (!commState.lastRead())
++                    return false;
+ 
+                 commState.idx++;
+ 
+             case 9:
 -                GridCacheVersion ver0 = commState.getCacheVersion();
++                ver = commState.getCacheVersion("ver");
+ 
 -                if (ver0 == CACHE_VER_NOT_READ)
++                if (!commState.lastRead())
+                     return false;
+ 
 -                ver = ver0;
 -
+                 commState.idx++;
+ 
+         }
+ 
+         return true;
+     }
+ 
+     /** {@inheritDoc} */
+     @Override public byte directType() {
+         return 49;
+     }
+ 
+     /** {@inheritDoc} */
+     @Override public String toString() {
+         return S.toString(GridNearGetResponse.class, this);
+     }
+ }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3dbb6acc/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockRequest.java
----------------------------------------------------------------------
diff --cc modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockRequest.java
index 0000000,601bd82..2d8e08f
mode 000000,100644..100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockRequest.java
@@@ -1,0 -1,667 +1,666 @@@
+ /*
+  * Licensed to the Apache Software Foundation (ASF) under one or more
+  * contributor license agreements.  See the NOTICE file distributed with
+  * this work for additional information regarding copyright ownership.
+  * The ASF licenses this file to You under the Apache License, Version 2.0
+  * (the "License"); you may not use this file except in compliance with
+  * the License.  You may obtain a copy of the License at
+  *
+  *      http://www.apache.org/licenses/LICENSE-2.0
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+ 
+ package org.apache.ignite.internal.processors.cache.distributed.near;
+ 
+ import org.apache.ignite.*;
+ import org.apache.ignite.cache.*;
+ import org.apache.ignite.internal.*;
+ import org.apache.ignite.internal.processors.cache.*;
+ import org.apache.ignite.internal.processors.cache.distributed.*;
+ import org.apache.ignite.internal.processors.cache.version.*;
+ import org.apache.ignite.lang.*;
+ import org.apache.ignite.transactions.*;
+ import org.apache.ignite.internal.processors.cache.transactions.*;
+ import org.apache.ignite.internal.util.direct.*;
+ import org.apache.ignite.internal.util.tostring.*;
+ import org.apache.ignite.internal.util.typedef.internal.*;
+ import org.jetbrains.annotations.*;
+ 
+ import java.io.*;
+ import java.nio.*;
+ import java.util.*;
+ 
+ /**
+  * Near cache lock request.
+  */
+ public class GridNearLockRequest<K, V> extends GridDistributedLockRequest<K, V> {
+     /** */
+     private static final long serialVersionUID = 0L;
+ 
+     /** Topology version. */
+     private long topVer;
+ 
+     /** Mini future ID. */
+     private IgniteUuid miniId;
+ 
+     /** Filter. */
+     private byte[][] filterBytes;
+ 
+     /** Filter. */
+     @GridDirectTransient
+     private IgnitePredicate<CacheEntry<K, V>>[] filter;
+ 
+     /** Implicit flag. */
+     private boolean implicitTx;
+ 
+     /** Implicit transaction with one key flag. */
+     private boolean implicitSingleTx;
+ 
+     /** One phase commit flag. */
+     private boolean onePhaseCommit;
+ 
+     /** Array of mapped DHT versions for this entry. */
+     @GridToStringInclude
+     private GridCacheVersion[] dhtVers;
+ 
+     /** Subject ID. */
+     @GridDirectVersion(1)
+     private UUID subjId;
+ 
+     /** Task name hash. */
+     @GridDirectVersion(2)
+     private int taskNameHash;
+ 
+     /** Has transforms flag. */
+     @GridDirectVersion(3)
+     private boolean hasTransforms;
+ 
+     /** Sync commit flag. */
+     private boolean syncCommit;
+ 
+     /** TTL for read operation. */
+     private long accessTtl;
+ 
+     /**
+      * Empty constructor required for {@link Externalizable}.
+      */
+     public GridNearLockRequest() {
+         // No-op.
+     }
+ 
+     /**
+      * @param cacheId Cache ID.
+      * @param topVer Topology version.
+      * @param nodeId Node ID.
+      * @param threadId Thread ID.
+      * @param futId Future ID.
+      * @param lockVer Cache version.
+      * @param isInTx {@code True} if implicit transaction lock.
+      * @param implicitTx Flag to indicate that transaction is implicit.
+      * @param implicitSingleTx Implicit-transaction-with-one-key flag.
+      * @param isRead Indicates whether implicit lock is for read or write operation.
+      * @param isolation Transaction isolation.
+      * @param isInvalidate Invalidation flag.
+      * @param timeout Lock timeout.
+      * @param keyCnt Number of keys.
+      * @param txSize Expected transaction size.
+      * @param syncCommit Synchronous commit flag.
+      * @param grpLockKey Group lock key if this is a group-lock transaction.
+      * @param partLock If partition is locked.
+      * @param subjId Subject ID.
+      * @param taskNameHash Task name hash code.
+      * @param accessTtl TTL for read operation.
+      */
+     public GridNearLockRequest(
+         int cacheId,
+         long topVer,
+         UUID nodeId,
+         long threadId,
+         IgniteUuid futId,
+         GridCacheVersion lockVer,
+         boolean isInTx,
+         boolean implicitTx,
+         boolean implicitSingleTx,
+         boolean isRead,
+         IgniteTxIsolation isolation,
+         boolean isInvalidate,
+         long timeout,
+         int keyCnt,
+         int txSize,
+         boolean syncCommit,
+         @Nullable IgniteTxKey grpLockKey,
+         boolean partLock,
+         @Nullable UUID subjId,
+         int taskNameHash,
+         long accessTtl
+     ) {
+         super(
+             cacheId,
+             nodeId,
+             lockVer,
+             threadId,
+             futId,
+             lockVer,
+             isInTx,
+             isRead,
+             isolation,
+             isInvalidate,
+             timeout,
+             keyCnt,
+             txSize,
+             grpLockKey,
+             partLock);
+ 
+         assert topVer > 0;
+ 
+         this.topVer = topVer;
+         this.implicitTx = implicitTx;
+         this.implicitSingleTx = implicitSingleTx;
+         this.syncCommit = syncCommit;
+         this.subjId = subjId;
+         this.taskNameHash = taskNameHash;
+         this.accessTtl = accessTtl;
+ 
+         dhtVers = new GridCacheVersion[keyCnt];
+     }
+ 
+     /**
+      * @return Topology version.
+      */
+     @Override public long topologyVersion() {
+         return topVer;
+     }
+ 
+     /**
+      * @return Subject ID.
+      */
+     public UUID subjectId() {
+         return subjId;
+     }
+ 
+     /**
+      * @return Task name hash.q
+      */
+     public int taskNameHash() {
+         return taskNameHash;
+     }
+ 
+     /**
+      * @return Implicit transaction flag.
+      */
+     public boolean implicitTx() {
+         return implicitTx;
+     }
+ 
+     /**
+      * @return Implicit-transaction-with-one-key flag.
+      */
+     public boolean implicitSingleTx() {
+         return implicitSingleTx;
+     }
+ 
+     /**
+      * @return One phase commit flag.
+      */
+     public boolean onePhaseCommit() {
+         return onePhaseCommit;
+     }
+ 
+     /**
+      * @param onePhaseCommit One phase commit flag.
+      */
+     public void onePhaseCommit(boolean onePhaseCommit) {
+         this.onePhaseCommit = onePhaseCommit;
+     }
+ 
+     /**
+      * @return Sync commit flag.
+      */
+     public boolean syncCommit() {
+         return syncCommit;
+     }
+ 
+     /**
+      * @return Filter.
+      */
+     public IgnitePredicate<CacheEntry<K, V>>[] filter() {
+         return filter;
+     }
+ 
+     /**
+      * @param filter Filter.
+      * @param ctx Context.
+      * @throws IgniteCheckedException If failed.
+      */
+     public void filter(IgnitePredicate<CacheEntry<K, V>>[] filter, GridCacheContext<K, V> ctx)
+         throws IgniteCheckedException {
+         this.filter = filter;
+     }
+ 
+     /**
+      * @return Mini future ID.
+      */
+     public IgniteUuid miniId() {
+         return miniId;
+     }
+ 
+     /**
+      * @param miniId Mini future Id.
+      */
+     public void miniId(IgniteUuid miniId) {
+         this.miniId = miniId;
+     }
+ 
+     /**
+      * @param hasTransforms {@code True} if originating transaction has transform entries.
+      */
+     public void hasTransforms(boolean hasTransforms) {
+         this.hasTransforms = hasTransforms;
+     }
+ 
+     /**
+      * @return {@code True} if originating transaction has transform entries.
+      */
+     public boolean hasTransforms() {
+         return hasTransforms;
+     }
+ 
+     /**
+      * Adds a key.
+      *
+      * @param key Key.
+      * @param retVal Flag indicating whether value should be returned.
+      * @param keyBytes Key bytes.
+      * @param dhtVer DHT version.
+      * @param writeEntry Write entry if implicit transaction mapped on one node.
+      * @param drVer DR version.
+      * @param ctx Context.
+      * @throws IgniteCheckedException If failed.
+      */
+     public void addKeyBytes(
+         K key,
+         byte[] keyBytes,
+         boolean retVal,
+         @Nullable GridCacheVersion dhtVer,
+         @Nullable IgniteTxEntry<K, V> writeEntry,
+         @Nullable GridCacheVersion drVer,
+         GridCacheContext<K, V> ctx
+     ) throws IgniteCheckedException {
+         dhtVers[idx] = dhtVer;
+ 
+         // Delegate to super.
+         addKeyBytes(key, keyBytes, writeEntry, retVal, null, drVer, ctx);
+     }
+ 
+     /**
+      * @param idx Index of the key.
+      * @return DHT version for key at given index.
+      */
+     public GridCacheVersion dhtVersion(int idx) {
+         return dhtVers[idx];
+     }
+ 
+     /** {@inheritDoc} */
+     @Override protected boolean transferExpiryPolicy() {
+         return true;
+     }
+ 
+     /**
+      * @return TTL for read operation.
+      */
+     public long accessTtl() {
+         return accessTtl;
+     }
+ 
+     /** {@inheritDoc} */
+     @Override public void prepareMarshal(GridCacheSharedContext<K, V> ctx) throws IgniteCheckedException {
+         super.prepareMarshal(ctx);
+ 
+         if (filterBytes == null)
+             filterBytes = marshalFilter(filter, ctx);
+     }
+ 
+     /** {@inheritDoc} */
+     @Override public void finishUnmarshal(GridCacheSharedContext<K, V> ctx, ClassLoader ldr) throws IgniteCheckedException {
+         super.finishUnmarshal(ctx, ldr);
+ 
+         if (filter == null && filterBytes != null)
+             filter = unmarshalFilter(filterBytes, ctx, ldr);
+     }
+ 
+     /** {@inheritDoc} */
+     @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"})
+     @Override public GridTcpCommunicationMessageAdapter clone() {
+         GridNearLockRequest _clone = new GridNearLockRequest();
+ 
+         clone0(_clone);
+ 
+         return _clone;
+     }
+ 
+     /** {@inheritDoc} */
+     @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) {
+         super.clone0(_msg);
+ 
+         GridNearLockRequest _clone = (GridNearLockRequest)_msg;
+ 
+         _clone.topVer = topVer;
+         _clone.miniId = miniId;
+         _clone.filterBytes = filterBytes;
+         _clone.filter = filter;
+         _clone.implicitTx = implicitTx;
+         _clone.implicitSingleTx = implicitSingleTx;
+         _clone.onePhaseCommit = onePhaseCommit;
+         _clone.dhtVers = dhtVers;
+         _clone.subjId = subjId;
+         _clone.taskNameHash = taskNameHash;
+         _clone.hasTransforms = hasTransforms;
+         _clone.syncCommit = syncCommit;
+         _clone.accessTtl = accessTtl;
+     }
+ 
+     /** {@inheritDoc} */
+     @SuppressWarnings("all")
+     @Override public boolean writeTo(ByteBuffer buf) {
+         commState.setBuffer(buf);
+ 
+         if (!super.writeTo(buf))
+             return false;
+ 
+         if (!commState.typeWritten) {
 -            if (!commState.putByte(directType()))
++            if (!commState.putByte(null, directType()))
+                 return false;
+ 
+             commState.typeWritten = true;
+         }
+ 
+         switch (commState.idx) {
+             case 24:
+                 if (dhtVers != null) {
+                     if (commState.it == null) {
 -                        if (!commState.putInt(dhtVers.length))
++                        if (!commState.putInt(null, dhtVers.length))
+                             return false;
+ 
+                         commState.it = arrayIterator(dhtVers);
+                     }
+ 
+                     while (commState.it.hasNext() || commState.cur != NULL) {
+                         if (commState.cur == NULL)
+                             commState.cur = commState.it.next();
+ 
 -                        if (!commState.putCacheVersion((GridCacheVersion)commState.cur))
++                        if (!commState.putCacheVersion(null, (GridCacheVersion)commState.cur))
+                             return false;
+ 
+                         commState.cur = NULL;
+                     }
+ 
+                     commState.it = null;
+                 } else {
 -                    if (!commState.putInt(-1))
++                    if (!commState.putInt(null, -1))
+                         return false;
+                 }
+ 
+                 commState.idx++;
+ 
+             case 25:
+                 if (filterBytes != null) {
+                     if (commState.it == null) {
 -                        if (!commState.putInt(filterBytes.length))
++                        if (!commState.putInt(null, filterBytes.length))
+                             return false;
+ 
+                         commState.it = arrayIterator(filterBytes);
+                     }
+ 
+                     while (commState.it.hasNext() || commState.cur != NULL) {
+                         if (commState.cur == NULL)
+                             commState.cur = commState.it.next();
+ 
 -                        if (!commState.putByteArray((byte[])commState.cur))
++                        if (!commState.putByteArray(null, (byte[])commState.cur))
+                             return false;
+ 
+                         commState.cur = NULL;
+                     }
+ 
+                     commState.it = null;
+                 } else {
 -                    if (!commState.putInt(-1))
++                    if (!commState.putInt(null, -1))
+                         return false;
+                 }
+ 
+                 commState.idx++;
+ 
+             case 26:
 -                if (!commState.putBoolean(implicitSingleTx))
++                if (!commState.putBoolean("implicitSingleTx", implicitSingleTx))
+                     return false;
+ 
+                 commState.idx++;
+ 
+             case 27:
 -                if (!commState.putBoolean(implicitTx))
++                if (!commState.putBoolean("implicitTx", implicitTx))
+                     return false;
+ 
+                 commState.idx++;
+ 
+             case 28:
 -                if (!commState.putGridUuid(miniId))
++                if (!commState.putGridUuid("miniId", miniId))
+                     return false;
+ 
+                 commState.idx++;
+ 
+             case 29:
 -                if (!commState.putBoolean(onePhaseCommit))
++                if (!commState.putBoolean("onePhaseCommit", onePhaseCommit))
+                     return false;
+ 
+                 commState.idx++;
+ 
+             case 30:
 -                if (!commState.putLong(topVer))
++                if (!commState.putBoolean("syncCommit", syncCommit))
+                     return false;
+ 
+                 commState.idx++;
+ 
+             case 31:
 -                if (!commState.putUuid(subjId))
++                if (!commState.putLong("topVer", topVer))
+                     return false;
+ 
+                 commState.idx++;
+ 
+             case 32:
 -                if (!commState.putInt(taskNameHash))
++                if (!commState.putUuid("subjId", subjId))
+                     return false;
+ 
+                 commState.idx++;
+ 
+             case 33:
 -                if (!commState.putBoolean(hasTransforms))
++                if (!commState.putInt("taskNameHash", taskNameHash))
+                     return false;
+ 
+                 commState.idx++;
+ 
+             case 34:
 -                if (!commState.putBoolean(syncCommit))
++                if (!commState.putBoolean("hasTransforms", hasTransforms))
+                     return false;
+ 
+                 commState.idx++;
+ 
+             case 35:
 -                if (!commState.putLong(accessTtl))
++                if (!commState.putLong("accessTtl", accessTtl))
+                     return false;
+ 
+                 commState.idx++;
+ 
+         }
+ 
+         return true;
+     }
+ 
+     /** {@inheritDoc} */
+     @SuppressWarnings("all")
+     @Override public boolean readFrom(ByteBuffer buf) {
+         commState.setBuffer(buf);
+ 
+         if (!super.readFrom(buf))
+             return false;
+ 
+         switch (commState.idx) {
+             case 24:
+                 if (commState.readSize == -1) {
 -                    if (buf.remaining() < 4)
 -                        return false;
++                    commState.readSize = commState.getInt(null);
+ 
 -                    commState.readSize = commState.getInt();
++                    if (!commState.lastRead())
++                        return false;
+                 }
+ 
+                 if (commState.readSize >= 0) {
+                     if (dhtVers == null)
+                         dhtVers = new GridCacheVersion[commState.readSize];
+ 
+                     for (int i = commState.readItems; i < commState.readSize; i++) {
 -                        GridCacheVersion _val = commState.getCacheVersion();
++                        GridCacheVersion _val = commState.getCacheVersion(null);
+ 
 -                        if (_val == CACHE_VER_NOT_READ)
++                        if (!commState.lastRead())
+                             return false;
+ 
+                         dhtVers[i] = (GridCacheVersion)_val;
+ 
+                         commState.readItems++;
+                     }
+                 }
+ 
+                 commState.readSize = -1;
+                 commState.readItems = 0;
+ 
+                 commState.idx++;
+ 
+             case 25:
+                 if (commState.readSize == -1) {
 -                    if (buf.remaining() < 4)
 -                        return false;
++                    commState.readSize = commState.getInt(null);
+ 
 -                    commState.readSize = commState.getInt();
++                    if (!commState.lastRead())
++                        return false;
+                 }
+ 
+                 if (commState.readSize >= 0) {
+                     if (filterBytes == null)
+                         filterBytes = new byte[commState.readSize][];
+ 
+                     for (int i = commState.readItems; i < commState.readSize; i++) {
 -                        byte[] _val = commState.getByteArray();
++                        byte[] _val = commState.getByteArray(null);
+ 
 -                        if (_val == BYTE_ARR_NOT_READ)
++                        if (!commState.lastRead())
+                             return false;
+ 
+                         filterBytes[i] = (byte[])_val;
+ 
+                         commState.readItems++;
+                     }
+                 }
+ 
+                 commState.readSize = -1;
+                 commState.readItems = 0;
+ 
+                 commState.idx++;
+ 
+             case 26:
 -                if (buf.remaining() < 1)
 -                    return false;
++                implicitSingleTx = commState.getBoolean("implicitSingleTx");
+ 
 -                implicitSingleTx = commState.getBoolean();
++                if (!commState.lastRead())
++                    return false;
+ 
+                 commState.idx++;
+ 
+             case 27:
 -                if (buf.remaining() < 1)
 -                    return false;
++                implicitTx = commState.getBoolean("implicitTx");
+ 
 -                implicitTx = commState.getBoolean();
++                if (!commState.lastRead())
++                    return false;
+ 
+                 commState.idx++;
+ 
+             case 28:
 -                IgniteUuid miniId0 = commState.getGridUuid();
++                miniId = commState.getGridUuid("miniId");
+ 
 -                if (miniId0 == GRID_UUID_NOT_READ)
++                if (!commState.lastRead())
+                     return false;
+ 
 -                miniId = miniId0;
 -
+                 commState.idx++;
+ 
+             case 29:
 -                if (buf.remaining() < 1)
 -                    return false;
++                onePhaseCommit = commState.getBoolean("onePhaseCommit");
+ 
 -                onePhaseCommit = commState.getBoolean();
++                if (!commState.lastRead())
++                    return false;
+ 
+                 commState.idx++;
+ 
+             case 30:
 -                if (buf.remaining() < 8)
 -                    return false;
++                syncCommit = commState.getBoolean("syncCommit");
+ 
 -                topVer = commState.getLong();
++                if (!commState.lastRead())
++                    return false;
+ 
+                 commState.idx++;
+ 
+             case 31:
 -                UUID subjId0 = commState.getUuid();
++                topVer = commState.getLong("topVer");
+ 
 -                if (subjId0 == UUID_NOT_READ)
++                if (!commState.lastRead())
+                     return false;
+ 
 -                subjId = subjId0;
 -
+                 commState.idx++;
+ 
+             case 32:
 -                if (buf.remaining() < 4)
 -                    return false;
++                subjId = commState.getUuid("subjId");
+ 
 -                taskNameHash = commState.getInt();
++                if (!commState.lastRead())
++                    return false;
+ 
+                 commState.idx++;
+ 
+             case 33:
 -                if (buf.remaining() < 1)
 -                    return false;
++                taskNameHash = commState.getInt("taskNameHash");
+ 
 -                hasTransforms = commState.getBoolean();
++                if (!commState.lastRead())
++                    return false;
+ 
+                 commState.idx++;
+ 
+             case 34:
 -                if (buf.remaining() < 1)
++                hasTransforms = commState.getBoolean("hasTransforms");
++
++                if (!commState.lastRead())
+                     return false;
+ 
 -                syncCommit = commState.getBoolean();
++                syncCommit = commState.getBoolean(null);
+ 
+                 commState.idx++;
+ 
+             case 35:
+                 if (buf.remaining() < 8)
+                     return false;
+ 
 -                accessTtl = commState.getLong();
++                accessTtl = commState.getLong(null);
+ 
+                 commState.idx++;
++
+         }
+ 
+         return true;
+     }
+ 
+     /** {@inheritDoc} */
+     @Override public byte directType() {
+         return 50;
+     }
+ 
+     /** {@inheritDoc} */
+     @Override public String toString() {
+         return S.toString(GridNearLockRequest.class, this, "filter", Arrays.toString(filter),
+             "super", super.toString());
+     }
+ }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3dbb6acc/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockResponse.java
----------------------------------------------------------------------
diff --cc modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockResponse.java
index 0000000,392b19c..98cbe8e
mode 000000,100644..100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockResponse.java
@@@ -1,0 -1,450 +1,446 @@@
+ /*
+  * Licensed to the Apache Software Foundation (ASF) under one or more
+  * contributor license agreements.  See the NOTICE file distributed with
+  * this work for additional information regarding copyright ownership.
+  * The ASF licenses this file to You under the Apache License, Version 2.0
+  * (the "License"); you may not use this file except in compliance with
+  * the License.  You may obtain a copy of the License at
+  *
+  *      http://www.apache.org/licenses/LICENSE-2.0
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+ 
+ package org.apache.ignite.internal.processors.cache.distributed.near;
+ 
+ import org.apache.ignite.*;
+ import org.apache.ignite.internal.*;
+ import org.apache.ignite.internal.processors.cache.*;
+ import org.apache.ignite.internal.processors.cache.distributed.*;
+ import org.apache.ignite.internal.processors.cache.version.*;
+ import org.apache.ignite.lang.*;
+ import org.apache.ignite.internal.util.direct.*;
+ import org.apache.ignite.internal.util.tostring.*;
+ import org.apache.ignite.internal.util.typedef.internal.*;
+ import org.jetbrains.annotations.*;
+ 
+ import java.io.*;
+ import java.nio.*;
+ import java.util.*;
+ 
+ /**
+  * Near cache lock response.
+  */
+ public class GridNearLockResponse<K, V> extends GridDistributedLockResponse<K, V> {
+     /** */
+     private static final long serialVersionUID = 0L;
+ 
+     /** Collection of versions that are pending and less than lock version. */
+     @GridToStringInclude
+     @GridDirectCollection(GridCacheVersion.class)
+     private Collection<GridCacheVersion> pending;
+ 
+     /** */
+     private IgniteUuid miniId;
+ 
+     /** DHT versions. */
+     @GridToStringInclude
+     private GridCacheVersion[] dhtVers;
+ 
+     /** DHT candidate versions. */
+     @GridToStringInclude
+     private GridCacheVersion[] mappedVers;
+ 
+     /** Filter evaluation results for fast-commit transactions. */
+     private boolean[] filterRes;
+ 
+     /**
+      * Empty constructor (required by {@link Externalizable}).
+      */
+     public GridNearLockResponse() {
+         // No-op.
+     }
+ 
+     /**
+      * @param cacheId Cache ID.
+      * @param lockVer Lock ID.
+      * @param futId Future ID.
+      * @param miniId Mini future ID.
+      * @param filterRes {@code True} if need to allocate array for filter evaluation results.
+      * @param cnt Count.
+      * @param err Error.
+      */
+     public GridNearLockResponse(
+         int cacheId,
+         GridCacheVersion lockVer,
+         IgniteUuid futId,
+         IgniteUuid miniId,
+         boolean filterRes,
+         int cnt,
+         Throwable err
+     ) {
+         super(cacheId, lockVer, futId, cnt, err);
+ 
+         assert miniId != null;
+ 
+         this.miniId = miniId;
+ 
+         dhtVers = new GridCacheVersion[cnt];
+         mappedVers = new GridCacheVersion[cnt];
+ 
+         if (filterRes)
+             this.filterRes = new boolean[cnt];
+     }
+ 
+     /**
+      * Gets pending versions that are less than {@link #version()}.
+      *
+      * @return Pending versions.
+      */
+     public Collection<GridCacheVersion> pending() {
+         return pending;
+     }
+ 
+     /**
+      * Sets pending versions that are less than {@link #version()}.
+      *
+      * @param pending Pending versions.
+      */
+     public void pending(Collection<GridCacheVersion> pending) {
+         this.pending = pending;
+     }
+ 
+     /**
+      * @return Mini future ID.
+      */
+     public IgniteUuid miniId() {
+         return miniId;
+     }
+ 
+     /**
+      * @param idx Index.
+      * @return DHT version.
+      */
+     public GridCacheVersion dhtVersion(int idx) {
+         return dhtVers == null ? null : dhtVers[idx];
+     }
+ 
+     /**
+      * Returns DHT candidate version for acquired near lock on DHT node.
+      *
+      * @param idx Key index.
+      * @return DHT version.
+      */
+     public GridCacheVersion mappedVersion(int idx) {
+         return mappedVers == null ? null : mappedVers[idx];
+     }
+ 
+     /**
+      * Gets filter evaluation result for fast-commit transaction.
+      *
+      * @param idx Result index.
+      * @return {@code True} if filter passed on primary node, {@code false} otherwise.
+      */
+     public boolean filterResult(int idx) {
+         assert filterRes != null : "Should not call filterResult for non-fast-commit transactions.";
+ 
+         return filterRes[idx];
+     }
+ 
+     /**
+      * @param val Value.
+      * @param valBytes Value bytes (possibly {@code null}).
+      * @param filterPassed Boolean flag indicating whether filter passed for fast-commit transaction.
+      * @param dhtVer DHT version.
+      * @param mappedVer Mapped version.
+      * @param ctx Context.
+      * @throws IgniteCheckedException If failed.
+      */
+     public void addValueBytes(
+         @Nullable V val,
+         @Nullable byte[] valBytes,
+         boolean filterPassed,
+         @Nullable GridCacheVersion dhtVer,
+         @Nullable GridCacheVersion mappedVer,
+         GridCacheContext<K, V> ctx
+     ) throws IgniteCheckedException {
+         int idx = valuesSize();
+ 
+         dhtVers[idx] = dhtVer;
+         mappedVers[idx] = mappedVer;
+ 
+         if (filterRes != null)
+             filterRes[idx] = filterPassed;
+ 
+         // Delegate to super.
+         addValueBytes(val, valBytes, ctx);
+     }
+ 
+     /** {@inheritDoc} */
+     @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"})
+     @Override public GridTcpCommunicationMessageAdapter clone() {
+         GridNearLockResponse _clone = new GridNearLockResponse();
+ 
+         clone0(_clone);
+ 
+         return _clone;
+     }
+ 
+     /** {@inheritDoc} */
+     @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) {
+         super.clone0(_msg);
+ 
+         GridNearLockResponse _clone = (GridNearLockResponse)_msg;
+ 
+         _clone.pending = pending;
+         _clone.miniId = miniId;
+         _clone.dhtVers = dhtVers;
+         _clone.mappedVers = mappedVers;
+         _clone.filterRes = filterRes;
+     }
+ 
+     /** {@inheritDoc} */
+     @SuppressWarnings("all")
+     @Override public boolean writeTo(ByteBuffer buf) {
+         commState.setBuffer(buf);
+ 
+         if (!super.writeTo(buf))
+             return false;
+ 
+         if (!commState.typeWritten) {
 -            if (!commState.putByte(directType()))
++            if (!commState.putByte(null, directType()))
+                 return false;
+ 
+             commState.typeWritten = true;
+         }
+ 
+         switch (commState.idx) {
+             case 11:
+                 if (dhtVers != null) {
+                     if (commState.it == null) {
 -                        if (!commState.putInt(dhtVers.length))
++                        if (!commState.putInt(null, dhtVers.length))
+                             return false;
+ 
+                         commState.it = arrayIterator(dhtVers);
+                     }
+ 
+                     while (commState.it.hasNext() || commState.cur != NULL) {
+                         if (commState.cur == NULL)
+                             commState.cur = commState.it.next();
+ 
 -                        if (!commState.putCacheVersion((GridCacheVersion)commState.cur))
++                        if (!commState.putCacheVersion(null, (GridCacheVersion)commState.cur))
+                             return false;
+ 
+                         commState.cur = NULL;
+                     }
+ 
+                     commState.it = null;
+                 } else {
 -                    if (!commState.putInt(-1))
++                    if (!commState.putInt(null, -1))
+                         return false;
+                 }
+ 
+                 commState.idx++;
+ 
+             case 12:
 -                if (!commState.putBooleanArray(filterRes))
++                if (!commState.putBooleanArray("filterRes", filterRes))
+                     return false;
+ 
+                 commState.idx++;
+ 
+             case 13:
+                 if (mappedVers != null) {
+                     if (commState.it == null) {
 -                        if (!commState.putInt(mappedVers.length))
++                        if (!commState.putInt(null, mappedVers.length))
+                             return false;
+ 
+                         commState.it = arrayIterator(mappedVers);
+                     }
+ 
+                     while (commState.it.hasNext() || commState.cur != NULL) {
+                         if (commState.cur == NULL)
+                             commState.cur = commState.it.next();
+ 
 -                        if (!commState.putCacheVersion((GridCacheVersion)commState.cur))
++                        if (!commState.putCacheVersion(null, (GridCacheVersion)commState.cur))
+                             return false;
+ 
+                         commState.cur = NULL;
+                     }
+ 
+                     commState.it = null;
+                 } else {
 -                    if (!commState.putInt(-1))
++                    if (!commState.putInt(null, -1))
+                         return false;
+                 }
+ 
+                 commState.idx++;
+ 
+             case 14:
 -                if (!commState.putGridUuid(miniId))
++                if (!commState.putGridUuid("miniId", miniId))
+                     return false;
+ 
+                 commState.idx++;
+ 
+             case 15:
+                 if (pending != null) {
+                     if (commState.it == null) {
 -                        if (!commState.putInt(pending.size()))
++                        if (!commState.putInt(null, pending.size()))
+                             return false;
+ 
+                         commState.it = pending.iterator();
+                     }
+ 
+                     while (commState.it.hasNext() || commState.cur != NULL) {
+                         if (commState.cur == NULL)
+                             commState.cur = commState.it.next();
+ 
 -                        if (!commState.putCacheVersion((GridCacheVersion)commState.cur))
++                        if (!commState.putCacheVersion(null, (GridCacheVersion)commState.cur))
+                             return false;
+ 
+                         commState.cur = NULL;
+                     }
+ 
+                     commState.it = null;
+                 } else {
 -                    if (!commState.putInt(-1))
++                    if (!commState.putInt(null, -1))
+                         return false;
+                 }
+ 
+                 commState.idx++;
+ 
+         }
+ 
+         return true;
+     }
+ 
+     /** {@inheritDoc} */
+     @SuppressWarnings("all")
+     @Override public boolean readFrom(ByteBuffer buf) {
+         commState.setBuffer(buf);
+ 
+         if (!super.readFrom(buf))
+             return false;
+ 
+         switch (commState.idx) {
+             case 11:
+                 if (commState.readSize == -1) {
 -                    if (buf.remaining() < 4)
 -                        return false;
++                    commState.readSize = commState.getInt(null);
+ 
 -                    commState.readSize = commState.getInt();
++                    if (!commState.lastRead())
++                        return false;
+                 }
+ 
+                 if (commState.readSize >= 0) {
+                     if (dhtVers == null)
+                         dhtVers = new GridCacheVersion[commState.readSize];
+ 
+                     for (int i = commState.readItems; i < commState.readSize; i++) {
 -                        GridCacheVersion _val = commState.getCacheVersion();
++                        GridCacheVersion _val = commState.getCacheVersion(null);
+ 
 -                        if (_val == CACHE_VER_NOT_READ)
++                        if (!commState.lastRead())
+                             return false;
+ 
+                         dhtVers[i] = (GridCacheVersion)_val;
+ 
+                         commState.readItems++;
+                     }
+                 }
+ 
+                 commState.readSize = -1;
+                 commState.readItems = 0;
+ 
+                 commState.idx++;
+ 
+             case 12:
 -                boolean[] filterRes0 = commState.getBooleanArray();
++                filterRes = commState.getBooleanArray("filterRes");
+ 
 -                if (filterRes0 == BOOLEAN_ARR_NOT_READ)
++                if (!commState.lastRead())
+                     return false;
+ 
 -                filterRes = filterRes0;
 -
+                 commState.idx++;
+ 
+             case 13:
+                 if (commState.readSize == -1) {
 -                    if (buf.remaining() < 4)
 -                        return false;
++                    commState.readSize = commState.getInt(null);
+ 
 -                    commState.readSize = commState.getInt();
++                    if (!commState.lastRead())
++                        return false;
+                 }
+ 
+                 if (commState.readSize >= 0) {
+                     if (mappedVers == null)
+                         mappedVers = new GridCacheVersion[commState.readSize];
+ 
+                     for (int i = commState.readItems; i < commState.readSize; i++) {
 -                        GridCacheVersion _val = commState.getCacheVersion();
++                        GridCacheVersion _val = commState.getCacheVersion(null);
+ 
 -                        if (_val == CACHE_VER_NOT_READ)
++                        if (!commState.lastRead())
+                             return false;
+ 
+                         mappedVers[i] = (GridCacheVersion)_val;
+ 
+                         commState.readItems++;
+                     }
+                 }
+ 
+                 commState.readSize = -1;
+                 commState.readItems = 0;
+ 
+                 commState.idx++;
+ 
+             case 14:
 -                IgniteUuid miniId0 = commState.getGridUuid();
++                miniId = commState.getGridUuid("miniId");
+ 
 -                if (miniId0 == GRID_UUID_NOT_READ)
++                if (!commState.lastRead())
+                     return false;
+ 
 -                miniId = miniId0;
 -
+                 commState.idx++;
+ 
+             case 15:
+                 if (commState.readSize == -1) {
 -                    if (buf.remaining() < 4)
 -                        return false;
++                    commState.readSize = commState.getInt(null);
+ 
 -                    commState.readSize = commState.getInt();
++                    if (!commState.lastRead())
++                        return false;
+                 }
+ 
+                 if (commState.readSize >= 0) {
+                     if (pending == null)
+                         pending = new ArrayList<>(commState.readSize);
+ 
+                     for (int i = commState.readItems; i < commState.readSize; i++) {
 -                        GridCacheVersion _val = commState.getCacheVersion();
++                        GridCacheVersion _val = commState.getCacheVersion(null);
+ 
 -                        if (_val == CACHE_VER_NOT_READ)
++                        if (!commState.lastRead())
+                             return false;
+ 
+                         pending.add((GridCacheVersion)_val);
+ 
+                         commState.readItems++;
+                     }
+                 }
+ 
+                 commState.readSize = -1;
+                 commState.readItems = 0;
+ 
+                 commState.idx++;
+ 
+         }
+ 
+         return true;
+     }
+ 
+     /** {@inheritDoc} */
+     @Override public byte directType() {
+         return 51;
+     }
+ 
+     /** {@inheritDoc} */
+     @Override public String toString() {
+         return S.toString(GridNearLockResponse.class, this, super.toString());
+     }
+ }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3dbb6acc/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishRequest.java
----------------------------------------------------------------------
diff --cc modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishRequest.java
index 0000000,2e63a8c..f4cb518
mode 000000,100644..100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishRequest.java
@@@ -1,0 -1,317 +1,315 @@@
+ /*
+  * Licensed to the Apache Software Foundation (ASF) under one or more
+  * contributor license agreements.  See the NOTICE file distributed with
+  * this work for additional information regarding copyright ownership.
+  * The ASF licenses this file to You under the Apache License, Version 2.0
+  * (the "License"); you may not use this file except in compliance with
+  * the License.  You may obtain a copy of the License at
+  *
+  *      http://www.apache.org/licenses/LICENSE-2.0
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+ 
+ package org.apache.ignite.internal.processors.cache.distributed.near;
+ 
+ import org.apache.ignite.internal.*;
+ import org.apache.ignite.internal.processors.cache.distributed.*;
+ import org.apache.ignite.internal.processors.cache.version.*;
+ import org.apache.ignite.lang.*;
+ import org.apache.ignite.internal.processors.cache.transactions.*;
+ import org.apache.ignite.internal.util.direct.*;
+ import org.apache.ignite.internal.util.tostring.*;
+ import org.jetbrains.annotations.*;
+ 
+ import java.io.*;
+ import java.nio.*;
+ import java.util.*;
+ 
+ /**
+  * Near transaction finish request.
+  */
+ public class GridNearTxFinishRequest<K, V> extends GridDistributedTxFinishRequest<K, V> {
+     /** */
+     private static final long serialVersionUID = 0L;
+ 
+     /** Mini future ID. */
+     private IgniteUuid miniId;
+ 
+     /** Explicit lock flag. */
+     private boolean explicitLock;
+ 
+     /** Store enabled flag. */
+     private boolean storeEnabled;
+ 
+     /** Topology version. */
+     private long topVer;
+ 
+     /** Subject ID. */
+     @GridDirectVersion(1)
+     private UUID subjId;
+ 
+     /** Task name hash. */
+     @GridDirectVersion(2)
+     private int taskNameHash;
+ 
+     /**
+      * Empty constructor required for {@link Externalizable}.
+      */
+     public GridNearTxFinishRequest() {
+         // No-op.
+     }
+ 
+     /**
+      * @param futId Future ID.
+      * @param xidVer Transaction ID.
+      * @param threadId Thread ID.
+      * @param commit Commit flag.
+      * @param invalidate Invalidate flag.
+      * @param sys System flag.
+      * @param explicitLock Explicit lock flag.
+      * @param storeEnabled Store enabled flag.
+      * @param topVer Topology version.
+      * @param baseVer Base version.
+      * @param committedVers Committed versions.
+      * @param rolledbackVers Rolled back versions.
+      * @param txSize Expected transaction size.
+      * @param writeEntries Write entries.
+      * @param recoverEntries Recover entries.
+      */
+     public GridNearTxFinishRequest(
+         IgniteUuid futId,
+         GridCacheVersion xidVer,
+         long threadId,
+         boolean commit,
+         boolean invalidate,
+         boolean sys,
+         boolean syncCommit,
+         boolean syncRollback,
+         boolean explicitLock,
+         boolean storeEnabled,
+         long topVer,
+         GridCacheVersion baseVer,
+         Collection<GridCacheVersion> committedVers,
+         Collection<GridCacheVersion> rolledbackVers,
+         int txSize,
+         Collection<IgniteTxEntry<K, V>> writeEntries,
+         Collection<IgniteTxEntry<K, V>> recoverEntries,
+         @Nullable UUID subjId,
+         int taskNameHash) {
+         super(xidVer, futId, null, threadId, commit, invalidate, sys, syncCommit, syncRollback, baseVer, committedVers,
+             rolledbackVers, txSize, writeEntries, recoverEntries, null);
+ 
+         this.explicitLock = explicitLock;
+         this.storeEnabled = storeEnabled;
+         this.topVer = topVer;
+         this.subjId = subjId;
+         this.taskNameHash = taskNameHash;
+     }
+ 
+     /**
+      * @return Explicit lock flag.
+      */
+     public boolean explicitLock() {
+         return explicitLock;
+     }
+ 
+     /**
+      * @return Store enabled flag.
+      */
+     public boolean storeEnabled() {
+         return storeEnabled;
+     }
+ 
+     /**
+      * @return Mini future ID.
+      */
+     public IgniteUuid miniId() {
+         return miniId;
+     }
+ 
+     /**
+      * @param miniId Mini future ID.
+      */
+     public void miniId(IgniteUuid miniId) {
+         this.miniId = miniId;
+     }
+ 
+     /**
+      * @return Subject ID.
+      */
+     @Nullable public UUID subjectId() {
+         return subjId;
+     }
+ 
+     /**
+      * @return Task name hash.
+      */
+     public int taskNameHash() {
+         return taskNameHash;
+     }
+ 
+     /**
+      * @return Topology version.
+      */
+     @Override public long topologyVersion() {
+         return topVer;
+     }
+ 
+     /** {@inheritDoc} */
+     @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"})
+     @Override public GridTcpCommunicationMessageAdapter clone() {
+         GridNearTxFinishRequest _clone = new GridNearTxFinishRequest();
+ 
+         clone0(_clone);
+ 
+         return _clone;
+     }
+ 
+     /** {@inheritDoc} */
+     @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) {
+         super.clone0(_msg);
+ 
+         GridNearTxFinishRequest _clone = (GridNearTxFinishRequest)_msg;
+ 
+         _clone.miniId = miniId;
+         _clone.explicitLock = explicitLock;
+         _clone.storeEnabled = storeEnabled;
+         _clone.topVer = topVer;
+         _clone.subjId = subjId;
+         _clone.taskNameHash = taskNameHash;
+     }
+ 
+     /** {@inheritDoc} */
+     @SuppressWarnings("all")
+     @Override public boolean writeTo(ByteBuffer buf) {
+         commState.setBuffer(buf);
+ 
+         if (!super.writeTo(buf))
+             return false;
+ 
+         if (!commState.typeWritten) {
 -            if (!commState.putByte(directType()))
++            if (!commState.putByte(null, directType()))
+                 return false;
+ 
+             commState.typeWritten = true;
+         }
+ 
+         switch (commState.idx) {
+             case 21:
 -                if (!commState.putBoolean(explicitLock))
++                if (!commState.putBoolean("explicitLock", explicitLock))
+                     return false;
+ 
+                 commState.idx++;
+ 
+             case 22:
 -                if (!commState.putGridUuid(miniId))
++                if (!commState.putGridUuid("miniId", miniId))
+                     return false;
+ 
+                 commState.idx++;
+ 
+             case 23:
 -                if (!commState.putLong(topVer))
++                if (!commState.putBoolean("storeEnabled", storeEnabled))
+                     return false;
+ 
+                 commState.idx++;
+ 
+             case 24:
 -                if (!commState.putUuid(subjId))
++                if (!commState.putLong("topVer", topVer))
+                     return false;
+ 
+                 commState.idx++;
+ 
+             case 25:
 -                if (!commState.putInt(taskNameHash))
++                if (!commState.putUuid("subjId", subjId))
+                     return false;
+ 
+                 commState.idx++;
+ 
+             case 26:
 -                if (!commState.putBoolean(storeEnabled))
++                if (!commState.putInt("taskNameHash", taskNameHash))
+                     return false;
+ 
+                 commState.idx++;
++
+         }
+ 
+         return true;
+     }
+ 
+     /** {@inheritDoc} */
+     @SuppressWarnings("all")
+     @Override public boolean readFrom(ByteBuffer buf) {
+         commState.setBuffer(buf);
+ 
+         if (!super.readFrom(buf))
+             return false;
+ 
+         switch (commState.idx) {
+             case 21:
 -                if (buf.remaining() < 1)
 -                    return false;
++                explicitLock = commState.getBoolean("explicitLock");
+ 
 -                explicitLock = commState.getBoolean();
++                if (!commState.lastRead())
++                    return false;
+ 
+                 commState.idx++;
+ 
+             case 22:
 -                IgniteUuid miniId0 = commState.getGridUuid();
++                miniId = commState.getGridUuid("miniId");
+ 
 -                if (miniId0 == GRID_UUID_NOT_READ)
++                if (!commState.lastRead())
+                     return false;
+ 
 -                miniId = miniId0;
 -
+                 commState.idx++;
+ 
+             case 23:
 -                if (buf.remaining() < 8)
 -                    return false;
++                storeEnabled = commState.getBoolean("storeEnabled");
+ 
 -                topVer = commState.getLong();
++                if (!commState.lastRead())
++                    return false;
+ 
+                 commState.idx++;
+ 
+             case 24:
 -                UUID subjId0 = commState.getUuid();
++                topVer = commState.getLong("topVer");
+ 
 -                if (subjId0 == UUID_NOT_READ)
++                if (!commState.lastRead())
+                     return false;
+ 
 -                subjId = subjId0;
 -
+                 commState.idx++;
+ 
+             case 25:
 -                if (buf.remaining() < 4)
 -                    return false;
++                subjId = commState.getUuid("subjId");
+ 
 -                taskNameHash = commState.getInt();
++                if (!commState.lastRead())
++                    return false;
+ 
+                 commState.idx++;
+ 
+             case 26:
 -                if (buf.remaining() < 1)
 -                    return false;
++                taskNameHash = commState.getInt("taskNameHash");
+ 
 -                storeEnabled = commState.getBoolean();
++                if (!commState.lastRead())
++                    return false;
+ 
+                 commState.idx++;
++
+         }
+ 
+         return true;
+     }
+ 
+     /** {@inheritDoc} */
+     @Override public byte directType() {
+         return 52;
+     }
+ 
+     /** {@inheritDoc} */
+     @Override public String toString() {
+         return GridToStringBuilder.toString(GridNearTxFinishRequest.class, this, "super", super.toString());
+     }
+ }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3dbb6acc/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishResponse.java
----------------------------------------------------------------------
diff --cc modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishResponse.java
index 0000000,b61f2ef..22c68e9
mode 000000,100644..100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxFinishResponse.java
@@@ -1,0 -1,228 +1,224 @@@
+ /*
+  * Licensed to the Apache Software Foundation (ASF) under one or more
+  * contributor license agreements.  See the NOTICE file distributed with
+  * this work for additional information regarding copyright ownership.
+  * The ASF licenses this file to You under the Apache License, Version 2.0
+  * (the "License"); you may not use this file except in compliance with
+  * the License.  You may obtain a copy of the License at
+  *
+  *      http://www.apache.org/licenses/LICENSE-2.0
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+ 
+ package org.apache.ignite.internal.processors.cache.distributed.near;
+ 
+ import org.apache.ignite.*;
+ import org.apache.ignite.internal.*;
+ import org.apache.ignite.internal.processors.cache.*;
+ import org.apache.ignite.internal.processors.cache.distributed.*;
+ import org.apache.ignite.internal.processors.cache.version.*;
+ import org.apache.ignite.lang.*;
+ import org.apache.ignite.internal.util.direct.*;
+ import org.apache.ignite.internal.util.typedef.internal.*;
+ import org.jetbrains.annotations.*;
+ 
+ import java.io.*;
+ import java.nio.*;
+ 
+ /**
+  * Reply for synchronous phase 2.
+  */
+ public class GridNearTxFinishResponse<K, V> extends GridDistributedTxFinishResponse<K, V> {
+     /** */
+     private static final long serialVersionUID = 0L;
+ 
+     /** Heuristic error. */
+     @GridDirectTransient
+     private Throwable err;
+ 
+     /** Serialized error. */
+     private byte[] errBytes;
+ 
+     /** Mini future ID. */
+     private IgniteUuid miniId;
+ 
+     /** Near tx thread ID. */
+     private long nearThreadId;
+ 
+     /**
+      * Empty constructor required by {@link Externalizable}.
+      */
+     public GridNearTxFinishResponse() {
+         // No-op.
+     }
+ 
+     /**
+      * @param xid Xid version.
+      * @param nearThreadId Near tx thread ID.
+      * @param futId Future ID.
+      * @param miniId Mini future Id.
+      * @param err Error.
+      */
+     public GridNearTxFinishResponse(GridCacheVersion xid, long nearThreadId, IgniteUuid futId, IgniteUuid miniId,
+         @Nullable Throwable err) {
+         super(xid, futId);
+ 
+         assert miniId != null;
+ 
+         this.nearThreadId = nearThreadId;
+         this.miniId = miniId;
+         this.err = err;
+     }
+ 
+     /**
+      * @return Error.
+      */
+     @Nullable public Throwable error() {
+         return err;
+     }
+ 
+     /**
+      * @return Mini future ID.
+      */
+     public IgniteUuid miniId() {
+         return miniId;
+     }
+ 
+     /**
+      * @return Near thread ID.
+      */
+     public long threadId() {
+         return nearThreadId;
+     }
+ 
+     /** {@inheritDoc}
+      * @param ctx*/
+     @Override public void prepareMarshal(GridCacheSharedContext<K, V> ctx) throws IgniteCheckedException {
+         super.prepareMarshal(ctx);
+ 
+         if (err != null)
+             errBytes = ctx.marshaller().marshal(err);
+     }
+ 
+     /** {@inheritDoc} */
+     @Override public void finishUnmarshal(GridCacheSharedContext<K, V> ctx, ClassLoader ldr) throws IgniteCheckedException {
+         super.finishUnmarshal(ctx, ldr);
+ 
+         if (errBytes != null)
+             err = ctx.marshaller().unmarshal(errBytes, ldr);
+     }
+ 
+     /** {@inheritDoc} */
+     @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"})
+     @Override public GridTcpCommunicationMessageAdapter clone() {
+         GridNearTxFinishResponse _clone = new GridNearTxFinishResponse();
+ 
+         clone0(_clone);
+ 
+         return _clone;
+     }
+ 
+     /** {@inheritDoc} */
+     @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) {
+         super.clone0(_msg);
+ 
+         GridNearTxFinishResponse _clone = (GridNearTxFinishResponse)_msg;
+ 
+         _clone.err = err;
+         _clone.errBytes = errBytes;
+         _clone.miniId = miniId;
+         _clone.nearThreadId = nearThreadId;
+     }
+ 
+     /** {@inheritDoc} */
+     @SuppressWarnings("all")
+     @Override public boolean writeTo(ByteBuffer buf) {
+         commState.setBuffer(buf);
+ 
+         if (!super.writeTo(buf))
+             return false;
+ 
+         if (!commState.typeWritten) {
 -            if (!commState.putByte(directType()))
++            if (!commState.putByte(null, directType()))
+                 return false;
+ 
+             commState.typeWritten = true;
+         }
+ 
+         switch (commState.idx) {
+             case 5:
 -                if (!commState.putByteArray(errBytes))
++                if (!commState.putByteArray("errBytes", errBytes))
+                     return false;
+ 
+                 commState.idx++;
+ 
+             case 6:
 -                if (!commState.putGridUuid(miniId))
++                if (!commState.putGridUuid("miniId", miniId))
+                     return false;
+ 
+                 commState.idx++;
+ 
+             case 7:
 -                if (!commState.putLong(nearThreadId))
++                if (!commState.putLong("nearThreadId", nearThreadId))
+                     return false;
+ 
+                 commState.idx++;
+ 
+         }
+ 
+         return true;
+     }
+ 
+     /** {@inheritDoc} */
+     @SuppressWarnings("all")
+     @Override public boolean readFrom(ByteBuffer buf) {
+         commState.setBuffer(buf);
+ 
+         if (!super.readFrom(buf))
+             return false;
+ 
+         switch (commState.idx) {
+             case 5:
 -                byte[] errBytes0 = commState.getByteArray();
++                errBytes = commState.getByteArray("errBytes");
+ 
 -                if (errBytes0 == BYTE_ARR_NOT_READ)
++                if (!commState.lastRead())
+                     return false;
+ 
 -                errBytes = errBytes0;
 -
+                 commState.idx++;
+ 
+             case 6:
 -                IgniteUuid miniId0 = commState.getGridUuid();
++                miniId = commState.getGridUuid("miniId");
+ 
 -                if (miniId0 == GRID_UUID_NOT_READ)
++                if (!commState.lastRead())
+                     return false;
+ 
 -                miniId = miniId0;
 -
+                 commState.idx++;
+ 
+             case 7:
 -                if (buf.remaining() < 8)
 -                    return false;
++                nearThreadId = commState.getLong("nearThreadId");
+ 
 -                nearThreadId = commState.getLong();
++                if (!commState.lastRead())
++                    return false;
+ 
+                 commState.idx++;
+ 
+         }
+ 
+         return true;
+     }
+ 
+     /** {@inheritDoc} */
+     @Override public byte directType() {
+         return 53;
+     }
+ 
+     /** {@inheritDoc} */
+     @Override public String toString() {
+         return S.toString(GridNearTxFinishResponse.class, this, "super", super.toString());
+     }
+ }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3dbb6acc/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareRequest.java
----------------------------------------------------------------------
diff --cc modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareRequest.java
index 0000000,8aecfe0..e0bc216
mode 000000,100644..100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxPrepareRequest.java
@@@ -1,0 -1,449 +1,444 @@@
+ /*
+  * Licensed to the Apache Software Foundation (ASF) under one or more
+  * contributor license agreements.  See the NOTICE file distributed with
+  * this work for additional information regarding copyright ownership.
+  * The ASF licenses this file to You under the Apache License, Version 2.0
+  * (the "License"); you may not use this file except in compliance with
+  * the License.  You may obtain a copy of the License at
+  *
+  *      http://www.apache.org/licenses/LICENSE-2.0
+  *
+  * Unless required by applicable law or agreed to in writing, software
+  * distributed under the License is distributed on an "AS IS" BASIS,
+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  * See the License for the specific language governing permissions and
+  * limitations under the License.
+  */
+ 
+ package org.apache.ignite.internal.processors.cache.distributed.near;
+ 
+ import org.apache.ignite.internal.*;
+ import org.apache.ignite.internal.processors.cache.*;
+ import org.apache.ignite.internal.processors.cache.distributed.*;
+ import org.apache.ignite.lang.*;
+ import org.apache.ignite.internal.processors.cache.transactions.*;
+ import org.apache.ignite.internal.util.direct.*;
+ import org.apache.ignite.internal.util.typedef.*;
+ import org.apache.ignite.internal.util.typedef.internal.*;
+ import org.jetbrains.annotations.*;
+ 
+ import java.io.*;
+ import java.nio.*;
+ import java.util.*;
+ 
+ /**
+  * Near transaction prepare request.
+  */
+ public class GridNearTxPrepareRequest<K, V> extends GridDistributedTxPrepareRequest<K, V> {
+     /** */
+     private static final long serialVersionUID = 0L;
+ 
+     /** Future ID. */
+     private IgniteUuid futId;
+ 
+     /** Mini future ID. */
+     private IgniteUuid miniId;
+ 
+     /** Near mapping flag. */
+     private boolean near;
+ 
+     /** Topology version. */
+     private long topVer;
+ 
+     /** {@code True} if this last prepare request for node. */
+     private boolean last;
+ 
+     /** IDs of backup nodes receiving last prepare request during this prepare. */
+     @GridDirectCollection(UUID.class)
+     private Collection<UUID> lastBackups;
+ 
+     /** Subject ID. */
+     @GridDirectVersion(1)
+     private UUID subjId;
+ 
+     /** Task name hash. */
+     @GridDirectVersion(2)
+     private int taskNameHash;
+ 
+     /**
+      * Empty constructor required for {@link Externalizable}.
+      */
+     public GridNearTxPrepareRequest() {
+         // No-op.
+     }
+ 
+     /**
+      * @param futId Future ID.
+      * @param topVer Topology version.
+      * @param tx Transaction.
+      * @param reads Read entries.
+      * @param writes Write entries.
+      * @param grpLockKey Group lock key if preparing group-lock transaction.
+      * @param partLock {@code True} if preparing group-lock transaction with partition lock.
+      * @param near {@code True} if mapping is for near caches.
+      * @param txNodes Transaction nodes mapping.
+      * @param last {@code True} if this last prepare request for node.
+      * @param lastBackups IDs of backup nodes receiving last prepare request during this prepare.
+      * @param subjId Subject ID.
+      * @param taskNameHash Task name hash.
+      */
+     public GridNearTxPrepareRequest(
+         IgniteUuid futId,
+         long topVer,
+         IgniteTxEx<K, V> tx,
+         Collection<IgniteTxEntry<K, V>> reads,
+         Collection<IgniteTxEntry<K, V>> writes,
+         IgniteTxKey grpLockKey,
+         boolean partLock,
+         boolean near,
+         Map<UUID, Collection<UUID>> txNodes,
+         boolean last,
+         Collection<UUID> lastBackups,
+         @Nullable UUID subjId,
+         int taskNameHash
+     ) {
+         super(tx, reads, writes, grpLockKey, partLock, txNodes);
+ 
+         assert futId != null;
+ 
+         this.futId = futId;
+         this.topVer = topVer;
+         this.near = near;
+         this.last = last;
+         this.lastBackups = lastBackups;
+         this.subjId = subjId;
+         this.taskNameHash = taskNameHash;
+     }
+ 
+     /**
+      * @return IDs of backup nodes receiving last prepare request during this prepare.
+      */
+     public Collection<UUID> lastBackups() {
+         return lastBackups;
+     }
+ 
+     /**
+      * @return {@code True} if this last prepare request for node.
+      */
+     public boolean last() {
+         return last;
+     }
+ 
+     /**
+      * @return {@code True} if mapping is for near-enabled caches.
+      */
+     public boolean near() {
+         return near;
+     }
+ 
+     /**
+      * @return Future ID.
+      */
+     public IgniteUuid futureId() {
+         return futId;
+     }
+ 
+     /**
+      * @return Mini future ID.
+      */
+     public IgniteUuid miniId() {
+         return miniId;
+     }
+ 
+     /**
+      * @param miniId Mini future ID.
+      */
+     public void miniId(IgniteUuid miniId) {
+         this.miniId = miniId;
+     }
+ 
+     /**
+      * @return Subject ID.
+      */
+     @Nullable public UUID subjectId() {
+         return subjId;
+     }
+ 
+     /**
+      * @return Task name hash.
+      */
+     public int taskNameHash() {
+         return taskNameHash;
+     }
+ 
+     /**
+      * @return Topology version.
+      */
+     @Override public long topologyVersion() {
+         return topVer;
+     }
+ 
+     /**
+      *
+      */
+     public void cloneEntries() {
+         reads(cloneEntries(reads()));
+         writes(cloneEntries(writes()));
+     }
+ 
+     /**
+      * Clones entries so that tx entries with initialized near entries are not passed to DHT transaction.
+      * Used only when local part of prepare is invoked.
+      *
+      * @param c Collection of entries to clone.
+      * @return Cloned collection.
+      */
+     private Collection<IgniteTxEntry<K, V>> cloneEntries(Collection<IgniteTxEntry<K, V>> c) {
+         if (F.isEmpty(c))
+             return c;
+ 
+         Collection<IgniteTxEntry<K, V>> cp = new ArrayList<>(c.size());
+ 
+         for (IgniteTxEntry<K, V> e : c) {
+             GridCacheContext<K, V> cacheCtx = e.context();
+ 
+             // Clone only if it is a near cache.
+             if (cacheCtx.isNear())
+                 cp.add(e.cleanCopy(cacheCtx.nearTx().dht().context()));
+             else
+                 cp.add(e);
+         }
+ 
+         return cp;
+     }
+ 
+     /** {@inheritDoc} */
+     @Override protected boolean transferExpiryPolicy() {
+         return true;
+     }
+ 
+     /** {@inheritDoc} */
+     @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"})
+     @Override public GridTcpCommunicationMessageAdapter clone() {
+         GridNearTxPrepareRequest _clone = new GridNearTxPrepareRequest();
+ 
+         clone0(_clone);
+ 
+         return _clone;
+     }
+ 
+     /** {@inheritDoc} */
+     @Override protected void clone0(GridTcpCommunicationMessageAdapter _msg) {
+         super.clone0(_msg);
+ 
+         GridNearTxPrepareRequest _clone = (GridNearTxPrepareRequest)_msg;
+ 
+         _clone.futId = futId;
+         _clone.miniId = miniId;
++        _clone.near = near;
+         _clone.topVer = topVer;
+         _clone.last = last;
+         _clone.lastBackups = lastBackups;
+         _clone.subjId = subjId;
+         _clone.taskNameHash = taskNameHash;
+     }
+ 
+     /** {@inheritDoc} */
+     @SuppressWarnings("all")
+     @Override public boolean writeTo(ByteBuffer buf) {
+         commState.setBuffer(buf);
+ 
+         if (!super.writeTo(buf))
+             return false;
+ 
+         if (!commState.typeWritten) {
 -            if (!commState.putByte(directType()))
++            if (!commState.putByte(null, directType()))
+                 return false;
+ 
+             commState.typeWritten = true;
+         }
+ 
+         switch (commState.idx) {
+             case 22:
 -                if (!commState.putGridUuid(futId))
++                if (!commState.putGridUuid("futId", futId))
+                     return false;
+ 
+                 commState.idx++;
+ 
+             case 23:
 -                if (!commState.putBoolean(last))
++                if (!commState.putBoolean("last", last))
+                     return false;
+ 
+                 commState.idx++;
+ 
+             case 24:
+                 if (lastBackups != null) {
+                     if (commState.it == null) {
 -                        if (!commState.putInt(lastBackups.size()))
++                        if (!commState.putInt(null, lastBackups.size()))
+                             return false;
+ 
+                         commState.it = lastBackups.iterator();
+                     }
+ 
+                     while (commState.it.hasNext() || commState.cur != NULL) {
+                         if (commState.cur == NULL)
+                             commState.cur = commState.it.next();
+ 
 -                        if (!commState.putUuid((UUID)commState.cur))
++                        if (!commState.putUuid(null, (UUID)commState.cur))
+                             return false;
+ 
+                         commState.cur = NULL;
+                     }
+ 
+                     commState.it = null;
+                 } else {
 -                    if (!commState.putInt(-1))
++                    if (!commState.putInt(null, -1))
+                         return false;
+                 }
+ 
+                 commState.idx++;
+ 
+             case 25:
 -                if (!commState.putGridUuid(miniId))
++                if (!commState.putGridUuid("miniId", miniId))
+                     return false;
+ 
+                 commState.idx++;
+ 
+             case 26:
 -                if (!commState.putBoolean(near))
++                if (!commState.putBoolean("near", near))
+                     return false;
+ 
+                 commState.idx++;
+ 
+             case 27:
 -                if (!commState.putLong(topVer))
++                if (!commState.putLong("topVer", topVer))
+                     return false;
+ 
+                 commState.idx++;
+ 
+             case 28:
 -                if (!commState.putUuid(subjId))
++                if (!commState.putUuid("subjId", subjId))
+                     return false;
+ 
+                 commState.idx++;
+ 
+             case 29:
 -                if (!commState.putInt(taskNameHash))
++                if (!commState.putInt("taskNameHash", taskNameHash))
+                     return false;
+ 
+                 commState.idx++;
+ 
+         }
+ 
+         return true;
+     }
+ 
+     /** {@inheritDoc} */
+     @SuppressWarnings("all")
+     @Override public boolean readFrom(ByteBuffer buf) {
+         commState.setBuffer(buf);
+ 
+         if (!super.readFrom(buf))
+             return false;
+ 
+         switch (commState.idx) {
+             case 22:
 -                IgniteUuid futId0 = commState.getGridUuid();
++                futId = commState.getGridUuid("futId");
+ 
 -                if (futId0 == GRID_UUID_NOT_READ)
++                if (!commState.lastRead())
+                     return false;
+ 
 -                futId = futId0;
 -
+                 commState.idx++;
+ 
+             case 23:
 -                if (buf.remaining() < 1)
 -                    return false;
++                last = commState.getBoolean("last");
+ 
 -                last = commState.getBoolean();
++                if (!commState.lastRead())
++                    return false;
+ 
+                 commState.idx++;
+ 
+             case 24:
+                 if (commState.readSize == -1) {
 -                    if (buf.remaining() < 4)
 -                        return false;
++                    commState.readSize = commState.getInt(null);
+ 
 -                    commState.readSize = commState.getInt();
++                    if (!commState.lastRead())
++                        return false;
+                 }
+ 
+                 if (commState.readSize >= 0) {
+                     if (lastBackups == null)
+                         lastBackups = new ArrayList<>(commState.readSize);
+ 
+                     for (int i = commState.readItems; i < commState.readSize; i++) {
 -                        UUID _val = commState.getUuid();
++                        UUID _val = commState.getUuid(null);
+ 
 -                        if (_val == UUID_NOT_READ)
++                        if (!commState.lastRead())
+                             return false;
+ 
+                         lastBackups.add((UUID)_val);
+ 
+                         commState.readItems++;
+                     }
+                 }
+ 
+                 commState.readSize = -1;
+                 commState.readItems = 0;
+ 
+                 commState.idx++;
+ 
+             case 25:
 -                IgniteUuid miniId0 = commState.getGridUuid();
++                miniId = commState.getGridUuid("miniId");
+ 
 -                if (miniId0 == GRID_UUID_NOT_READ)
++                if (!commState.lastRead())
+                     return false;
+ 
 -                miniId = miniId0;
 -
+                 commState.idx++;
+ 
+             case 26:
 -                if (buf.remaining() < 1)
 -                    return false;
++                near = commState.getBoolean("near");
+ 
 -                near = commState.getBoolean();
++                if (!commState.lastRead())
++                    return false;
+ 
+                 commState.idx++;
+ 
+             case 27:
 -                if (buf.remaining() < 8)
 -                    return false;
++                topVer = commState.getLong("topVer");
+ 
 -                topVer = commState.getLong();
++                if (!commState.lastRead())
++                    return false;
+ 
+                 commState.idx++;
+ 
+             case 28:
 -                UUID subjId0 = commState.getUuid();
++                subjId = commState.getUuid("subjId");
+ 
 -                if (subjId0 == UUID_NOT_READ)
++                if (!commState.lastRead())
+                     return false;
+ 
 -                subjId = subjId0;
 -
+                 commState.idx++;
+ 
+             case 29:
 -                if (buf.remaining() < 4)
 -                    return false;
++                taskNameHash = commState.getInt("taskNameHash");
+ 
 -                taskNameHash = commState.getInt();
++                if (!commState.lastRead())
++                    return false;
+ 
+                 commState.idx++;
+ 
+         }
+ 
+         return true;
+     }
+ 
+     /** {@inheritDoc} */
+     @Override public byte directType() {
+         return 54;
+     }
+ 
+     /** {@inheritDoc} */
+     @Override public String toString() {
+         return S.toString(GridNearTxPrepareRequest.class, this, super.toString());
+     }
+ }


Mime
View raw message