ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [08/13] incubator-ignite git commit: ignite-471: revert 8a6dd007d79e6bd62fb288f1c38310860949ca45
Date Mon, 18 May 2015 09:14:22 GMT
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9433882d/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 82d68b3..eb8825e 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
@@ -179,9 +179,6 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter
     /** */
     protected int txSize;
 
-    /** Group lock key, if any. */
-    protected IgniteTxKey grpLockKey;
-
     /** */
     @GridToStringExclude
     private AtomicReference<GridFutureAdapter<IgniteInternalTx>> finFut = new AtomicReference<>();
@@ -233,7 +230,6 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter
      * @param isolation Isolation.
      * @param timeout Timeout.
      * @param txSize Transaction size.
-     * @param grpLockKey Group lock key if this is group-lock transaction.
      */
     protected IgniteTxAdapter(
         GridCacheSharedContext<?, ?> cctx,
@@ -249,7 +245,6 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter
         boolean invalidate,
         boolean storeEnabled,
         int txSize,
-        @Nullable IgniteTxKey grpLockKey,
         @Nullable UUID subjId,
         int taskNameHash
     ) {
@@ -269,7 +264,6 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter
         this.invalidate = invalidate;
         this.storeEnabled = storeEnabled;
         this.txSize = txSize;
-        this.grpLockKey = grpLockKey;
         this.subjId = subjId;
         this.taskNameHash = taskNameHash;
 
@@ -294,7 +288,6 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter
      * @param isolation Isolation.
      * @param timeout Timeout.
      * @param txSize Transaction size.
-     * @param grpLockKey Group lock key if this is group-lock transaction.
      */
     protected IgniteTxAdapter(
         GridCacheSharedContext<?, ?> cctx,
@@ -308,7 +301,6 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter
         TransactionIsolation isolation,
         long timeout,
         int txSize,
-        @Nullable IgniteTxKey grpLockKey,
         @Nullable UUID subjId,
         int taskNameHash
     ) {
@@ -323,7 +315,6 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter
         this.isolation = isolation;
         this.timeout = timeout;
         this.txSize = txSize;
-        this.grpLockKey = grpLockKey;
         this.subjId = subjId;
         this.taskNameHash = taskNameHash;
 
@@ -387,30 +378,7 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter
 
     /** {@inheritDoc} */
     @Override public Collection<IgniteTxEntry> optimisticLockEntries() {
-        if (!groupLock())
-            return writeEntries();
-        else {
-            if (!F.isEmpty(invalidParts)) {
-                assert invalidParts.size() == 1 : "Only one partition expected for group lock transaction " +
-                    "[tx=" + this + ", invalidParts=" + invalidParts + ']';
-                assert groupLockEntry() == null : "Group lock key should be rejected " +
-                    "[tx=" + this + ", groupLockEntry=" + groupLockEntry() + ']';
-                assert F.isEmpty(writeMap()) : "All entries should be rejected for group lock transaction " +
-                    "[tx=" + this + ", writes=" + writeMap() + ']';
-
-                return Collections.emptyList();
-            }
-
-            IgniteTxEntry grpLockEntry = groupLockEntry();
-
-            assert grpLockEntry != null || (near() && !local()):
-                "Group lock entry was not enlisted into transaction [tx=" + this +
-                ", grpLockKey=" + groupLockKey() + ']';
-
-            return grpLockEntry == null ?
-                Collections.<IgniteTxEntry>emptyList() :
-                Collections.singletonList(grpLockEntry);
-        }
+        return writeEntries();
     }
 
     /** {@inheritDoc} */
@@ -482,16 +450,6 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter
         cctx.tm().uncommitTx(this);
     }
 
-    /**
-     * This method uses unchecked assignment to cast group lock key entry to transaction generic signature.
-     *
-     * @return Group lock tx entry.
-     */
-    @SuppressWarnings("unchecked")
-    public IgniteTxEntry groupLockEntry() {
-        return this.entry(groupLockKey());
-    }
-
     /** {@inheritDoc} */
     @Override public UUID otherNodeId() {
         return null;
@@ -603,16 +561,6 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter
     public abstract boolean isStarted();
 
     /** {@inheritDoc} */
-    @Override public boolean groupLock() {
-        return grpLockKey != null;
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteTxKey groupLockKey() {
-        return grpLockKey;
-    }
-
-    /** {@inheritDoc} */
     @Override public int size() {
         return txSize;
     }
@@ -798,9 +746,6 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter
 
         GridCacheVersion explicit = txEntry == null ? null : txEntry.explicitVersion();
 
-        assert !txEntry.groupLockEntry() || groupLock() : "Can not have group-locked tx entries in " +
-            "non-group-lock transactions [txEntry=" + txEntry + ", tx=" + this + ']';
-
         return local() && !cacheCtx.isDht() ?
             entry.lockedByThread(threadId()) || (explicit != null && entry.lockedBy(explicit)) :
             // If candidate is not there, then lock was explicit.
@@ -817,9 +762,6 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter
 
         GridCacheVersion explicit = txEntry == null ? null : txEntry.explicitVersion();
 
-        assert !txEntry.groupLockEntry() || groupLock() : "Can not have group-locked tx entries in " +
-            "non-group-lock transactions [txEntry=" + txEntry + ", tx=" + this + ']';
-
         return local() && !cacheCtx.isDht() ?
             entry.lockedByThreadUnsafe(threadId()) || (explicit != null && entry.lockedByUnsafe(explicit)) :
             // If candidate is not there, then lock was explicit.
@@ -1008,7 +950,7 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter
     }
 
     /** {@inheritDoc} */
-    @Nullable @Override public IgniteInternalFuture<IgniteInternalTx> currentPrepareFuture() {
+    @Nullable @Override public IgniteInternalFuture<?> currentPrepareFuture() {
         return null;
     }
 
@@ -1554,7 +1496,7 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter
     /** {@inheritDoc} */
     @Override public String toString() {
         return GridToStringBuilder.toString(IgniteTxAdapter.class, this,
-            "duration", (U.currentTimeMillis() - startTime) + "ms", "grpLock", groupLock(),
+            "duration", (U.currentTimeMillis() - startTime) + "ms",
             "onePhaseCommit", onePhaseCommit);
     }
 
@@ -1779,16 +1721,6 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter
         }
 
         /** {@inheritDoc} */
-        @Override public boolean groupLock() {
-            return false;
-        }
-
-        /** {@inheritDoc} */
-        @Nullable @Override public IgniteTxKey groupLockKey() {
-            throw new IllegalStateException("Deserialized transaction can only be used as read-only.");
-        }
-
-        /** {@inheritDoc} */
         @Override public boolean markPreparing() {
             throw new IllegalStateException("Deserialized transaction can only be used as read-only.");
         }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9433882d/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 6d4fed6..aff2f40 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
@@ -137,9 +137,6 @@ public class IgniteTxEntry implements GridPeerDeployAware, Message {
     @GridDirectTransient
     private boolean locMapped;
 
-    /** Group lock entry flag. */
-    private boolean grpLock;
-
     /** Expiry policy. */
     @GridDirectTransient
     private ExpiryPolicy expiryPlc;
@@ -277,22 +274,6 @@ public class IgniteTxEntry implements GridPeerDeployAware, Message {
     }
 
     /**
-     * @return {@code True} if this entry was added in group lock transaction and
-     *      this is not a group lock entry.
-     */
-    public boolean groupLockEntry() {
-        return grpLock;
-    }
-
-    /**
-     * @param grpLock {@code True} if this entry was added in group lock transaction and
-     *      this is not a group lock entry.
-     */
-    public void groupLockEntry(boolean grpLock) {
-        this.grpLock = grpLock;
-    }
-
-    /**
      * @param ctx Context.
      * @return Clean copy of this entry.
      */
@@ -311,7 +292,6 @@ public class IgniteTxEntry implements GridPeerDeployAware, Message {
         cp.ttl = ttl;
         cp.conflictExpireTime = conflictExpireTime;
         cp.explicitVer = explicitVer;
-        cp.grpLock = grpLock;
         cp.conflictVer = conflictVer;
         cp.expiryPlc = expiryPlc;
         cp.flags = flags;
@@ -851,30 +831,24 @@ public class IgniteTxEntry implements GridPeerDeployAware, Message {
                 writer.incrementState();
 
             case 7:
-                if (!writer.writeBoolean("grpLock", grpLock))
-                    return false;
-
-                writer.incrementState();
-
-            case 8:
                 if (!writer.writeMessage("key", key))
                     return false;
 
                 writer.incrementState();
 
-            case 9:
+            case 8:
                 if (!writer.writeByteBuffer("transformClosBytes", transformClosBytes))
                     return false;
 
                 writer.incrementState();
 
-            case 10:
+            case 9:
                 if (!writer.writeLong("ttl", ttl))
                     return false;
 
                 writer.incrementState();
 
-            case 11:
+            case 10:
                 if (!writer.writeMessage("val", val))
                     return false;
 
@@ -950,14 +924,6 @@ public class IgniteTxEntry implements GridPeerDeployAware, Message {
                 reader.incrementState();
 
             case 7:
-                grpLock = reader.readBoolean("grpLock");
-
-                if (!reader.isLastRead())
-                    return false;
-
-                reader.incrementState();
-
-            case 8:
                 key = reader.readMessage("key");
 
                 if (!reader.isLastRead())
@@ -965,7 +931,7 @@ public class IgniteTxEntry implements GridPeerDeployAware, Message {
 
                 reader.incrementState();
 
-            case 9:
+            case 8:
                 transformClosBytes = reader.readByteBuffer("transformClosBytes");
 
                 if (!reader.isLastRead())
@@ -973,7 +939,7 @@ public class IgniteTxEntry implements GridPeerDeployAware, Message {
 
                 reader.incrementState();
 
-            case 10:
+            case 9:
                 ttl = reader.readLong("ttl");
 
                 if (!reader.isLastRead())
@@ -981,7 +947,7 @@ public class IgniteTxEntry implements GridPeerDeployAware, Message {
 
                 reader.incrementState();
 
-            case 11:
+            case 10:
                 val = reader.readMessage("val");
 
                 if (!reader.isLastRead())
@@ -1001,7 +967,7 @@ public class IgniteTxEntry implements GridPeerDeployAware, Message {
 
     /** {@inheritDoc} */
     @Override public byte fieldsCount() {
-        return 12;
+        return 11;
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9433882d/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java
index af75fb8..f466bf2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java
@@ -31,7 +31,6 @@ import org.apache.ignite.internal.util.future.*;
 import org.apache.ignite.internal.util.lang.*;
 import org.apache.ignite.internal.util.typedef.*;
 import org.apache.ignite.internal.util.typedef.internal.*;
-import org.apache.ignite.lang.*;
 import org.jetbrains.annotations.*;
 
 import java.util.*;
@@ -58,9 +57,9 @@ public class IgniteTxHandler {
      * @param req Request.
      * @return Prepare future.
      */
-    public IgniteInternalFuture<IgniteInternalTx> processNearTxPrepareRequest(final UUID nearNodeId,
+    public IgniteInternalFuture<?> processNearTxPrepareRequest(final UUID nearNodeId,
         final GridNearTxPrepareRequest req) {
-        return prepareTx(nearNodeId, null, req, null);
+        return prepareTx(nearNodeId, null, req);
     }
 
     /**
@@ -138,32 +137,28 @@ public class IgniteTxHandler {
      * @param nearNodeId Near node ID that initiated transaction.
      * @param locTx Optional local transaction.
      * @param req Near prepare request.
-     * @param completeCb Completion callback.
      * @return Future for transaction.
      */
-    public IgniteInternalFuture<IgniteInternalTx> prepareTx(
+    public IgniteInternalFuture<GridNearTxPrepareResponse> prepareTx(
         UUID nearNodeId,
         @Nullable GridNearTxLocal locTx,
-        GridNearTxPrepareRequest req,
-        @Nullable IgniteInClosure<GridNearTxPrepareResponse> completeCb
+        GridNearTxPrepareRequest req
     ) {
         assert nearNodeId != null;
         assert req != null;
 
         if (locTx != null) {
-            assert completeCb != null;
-
             if (req.near()) {
                 // Make sure not to provide Near entries to DHT cache.
                 req.cloneEntries();
 
-                return prepareNearTx(nearNodeId, req, completeCb);
+                return prepareNearTx(nearNodeId, req);
             }
             else
-                return prepareColocatedTx(locTx, req, completeCb);
+                return prepareColocatedTx(locTx, req);
         }
         else
-            return prepareNearTx(nearNodeId, req, null);
+            return prepareNearTx(nearNodeId, req);
     }
 
     /**
@@ -171,30 +166,27 @@ public class IgniteTxHandler {
      *
      * @param locTx Local transaction.
      * @param req Near prepare request.
-     * @param completeCb Completion callback.
      * @return Prepare future.
      */
-    private IgniteInternalFuture<IgniteInternalTx> prepareColocatedTx(
+    private IgniteInternalFuture<GridNearTxPrepareResponse> prepareColocatedTx(
         final GridNearTxLocal locTx,
-        final GridNearTxPrepareRequest req,
-        final IgniteInClosure<GridNearTxPrepareResponse> completeCb
+        final GridNearTxPrepareRequest req
     ) {
         IgniteInternalFuture<Object> fut = new GridFinishedFuture<>(); // TODO force preload keys.
 
         return new GridEmbeddedFuture<>(
             fut,
-            new C2<Object, Exception, IgniteInternalFuture<IgniteInternalTx>>() {
-                @Override public IgniteInternalFuture<IgniteInternalTx> apply(Object o, Exception ex) {
+            new C2<Object, Exception, IgniteInternalFuture<GridNearTxPrepareResponse>>() {
+                @Override public IgniteInternalFuture<GridNearTxPrepareResponse> apply(Object o, Exception ex) {
                     if (ex != null)
                         throw new GridClosureException(ex);
 
-                    IgniteInternalFuture<IgniteInternalTx> fut = locTx.prepareAsyncLocal(
+                    IgniteInternalFuture<GridNearTxPrepareResponse> fut = locTx.prepareAsyncLocal(
                         req.reads(),
                         req.writes(),
                         req.transactionNodes(),
                         req.last(),
-                        req.lastBackups(),
-                        completeCb);
+                        req.lastBackups());
 
                     if (locTx.isRollbackOnly())
                         locTx.rollbackAsync();
@@ -202,18 +194,16 @@ public class IgniteTxHandler {
                     return fut;
                 }
             },
-            new C2<IgniteInternalTx, Exception, IgniteInternalTx>() {
-                @Nullable @Override public IgniteInternalTx apply(IgniteInternalTx tx, Exception e) {
+            new C2<GridNearTxPrepareResponse, Exception, GridNearTxPrepareResponse>() {
+                @Nullable @Override public GridNearTxPrepareResponse apply(GridNearTxPrepareResponse res, Exception e) {
                     if (e != null) {
-                        // tx can be null of exception occurred.
-                        if (tx != null)
-                            tx.setRollbackOnly(); // Just in case.
+                        locTx.setRollbackOnly(); // Just in case.
 
                         if (!(e instanceof IgniteTxOptimisticCheckedException))
-                            U.error(log, "Failed to prepare DHT transaction: " + tx, e);
+                            U.error(log, "Failed to prepare transaction: " + locTx, e);
                     }
 
-                    return tx;
+                    return res;
                 }
             }
         );
@@ -224,13 +214,11 @@ public class IgniteTxHandler {
      *
      * @param nearNodeId Near node ID that initiated transaction.
      * @param req Near prepare request.
-     * @param completeCb Completion callback.
      * @return Prepare future.
      */
-    private IgniteInternalFuture<IgniteInternalTx> prepareNearTx(
+    private IgniteInternalFuture<GridNearTxPrepareResponse> prepareNearTx(
         final UUID nearNodeId,
-        final GridNearTxPrepareRequest req,
-        IgniteInClosure<GridNearTxPrepareResponse> completeCb
+        final GridNearTxPrepareRequest req
     ) {
         ClusterNode nearNode = ctx.node(nearNodeId);
 
@@ -283,8 +271,6 @@ public class IgniteTxHandler {
                 req.isInvalidate(),
                 false,
                 req.txSize(),
-                req.groupLockKey(),
-                req.partitionLock(),
                 req.transactionNodes(),
                 req.subjectId(),
                 req.taskNameHash()
@@ -315,7 +301,7 @@ public class IgniteTxHandler {
             if (req.returnValue())
                 tx.needReturnValue(true);
 
-            IgniteInternalFuture<IgniteInternalTx> fut = tx.prepareAsync(
+            IgniteInternalFuture<GridNearTxPrepareResponse> fut = tx.prepareAsync(
                 req.reads(),
                 req.writes(),
                 req.dhtVersions(),
@@ -323,8 +309,7 @@ public class IgniteTxHandler {
                 req.miniId(),
                 req.transactionNodes(),
                 req.last(),
-                req.lastBackups(),
-                completeCb);
+                req.lastBackups());
 
             if (tx.isRollbackOnly()) {
                 try {
@@ -337,8 +322,8 @@ public class IgniteTxHandler {
 
             final GridDhtTxLocal tx0 = tx;
 
-            fut.listen(new CI1<IgniteInternalFuture<IgniteInternalTx>>() {
-                @Override public void apply(IgniteInternalFuture<IgniteInternalTx> txFut) {
+            fut.listen(new CI1<IgniteInternalFuture<?>>() {
+                @Override public void apply(IgniteInternalFuture<?> txFut) {
                     try {
                         txFut.get();
                     }
@@ -354,7 +339,7 @@ public class IgniteTxHandler {
             return fut;
         }
         else
-            return new GridFinishedFuture<>((IgniteInternalTx)null);
+            return new GridFinishedFuture<>((GridNearTxPrepareResponse)null);
     }
 
     /**
@@ -362,7 +347,7 @@ public class IgniteTxHandler {
      * @param res Response.
      */
     private void processNearTxPrepareResponse(UUID nodeId, GridNearTxPrepareResponse res) {
-        GridNearTxPrepareFuture fut = (GridNearTxPrepareFuture)ctx.mvcc()
+        GridNearTxPrepareFutureAdapter fut = (GridNearTxPrepareFutureAdapter)ctx.mvcc()
             .<IgniteInternalTx>future(res.version(), res.futureId());
 
         if (fut == null) {
@@ -399,8 +384,7 @@ public class IgniteTxHandler {
      * @param res Response.
      */
     private void processDhtTxPrepareResponse(UUID nodeId, GridDhtTxPrepareResponse res) {
-        GridDhtTxPrepareFuture fut = (GridDhtTxPrepareFuture)ctx.mvcc().
-            <IgniteInternalTx>future(res.version(), res.futureId());
+        GridDhtTxPrepareFuture fut = (GridDhtTxPrepareFuture)ctx.mvcc().future(res.version(), res.futureId());
 
         if (fut == null) {
             if (log.isDebugEnabled())
@@ -568,8 +552,6 @@ public class IgniteTxHandler {
                             req.isInvalidate(),
                             req.storeEnabled(),
                             req.txSize(),
-                            req.groupLockKey(),
-                            false,
                             null,
                             req.subjectId(),
                             req.taskNameHash()));
@@ -1016,7 +998,6 @@ public class IgniteTxHandler {
                     req.isInvalidate(),
                     req.timeout(),
                     req.writes() != null ? Math.max(req.writes().size(), req.txSize()) : req.txSize(),
-                    req.groupLockKey(),
                     req.nearXidVersion(),
                     req.transactionNodes(),
                     req.subjectId(),
@@ -1150,7 +1131,6 @@ public class IgniteTxHandler {
                     req.timeout(),
                     req.nearWrites(),
                     req.txSize(),
-                    req.groupLockKey(),
                     req.subjectId(),
                     req.taskNameHash()
                 );

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9433882d/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 3c855ec..609108f 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
@@ -86,9 +86,6 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
     /** Base for completed versions. */
     private GridCacheVersion completedBase;
 
-    /** Flag indicating partition lock in group lock transaction. */
-    private boolean partLock;
-
     /** Flag indicating that transformed values should be sent to remote nodes. */
     private boolean sndTransformedVals;
 
@@ -123,8 +120,6 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
      * @param isolation Isolation.
      * @param timeout Timeout.
      * @param txSize Expected transaction size.
-     * @param grpLockKey Group lock key if this is a group-lock transaction.
-     * @param partLock {@code True} if this is a group-lock transaction and lock is acquired for whole partition.
      */
     protected IgniteTxLocalAdapter(
         GridCacheSharedContext cctx,
@@ -139,17 +134,11 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
         boolean invalidate,
         boolean storeEnabled,
         int txSize,
-        @Nullable IgniteTxKey grpLockKey,
-        boolean partLock,
         @Nullable UUID subjId,
         int taskNameHash
     ) {
         super(cctx, xidVer, implicit, implicitSingle, /*local*/true, sys, plc, concurrency, isolation, timeout,
-            invalidate, storeEnabled, txSize, grpLockKey, subjId, taskNameHash);
-
-        assert !partLock || grpLockKey != null;
-
-        this.partLock = partLock;
+            invalidate, storeEnabled, txSize, subjId, taskNameHash);
 
         minVer = xidVer;
     }
@@ -182,11 +171,6 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
     }
 
     /** {@inheritDoc} */
-    @Override public boolean partitionLock() {
-        return partLock;
-    }
-
-    /** {@inheritDoc} */
     @Override public Throwable commitError() {
         return commitErr.get();
     }
@@ -499,7 +483,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
         CacheStoreManager store = store();
 
         if (store != null && store.isWriteThrough() && storeEnabled() &&
-            (!internal() || groupLock()) && (near() || store.isWriteToStoreFromDht())) {
+            !internal() && (near() || store.isWriteToStoreFromDht())) {
             try {
                 if (writeEntries != null) {
                     Map<Object, IgniteBiTuple<Object, GridCacheVersion>> putMap = null;
@@ -679,9 +663,6 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
         if (!empty || colocated())
             cctx.tm().addCommittedTx(this);
 
-        if (groupLock())
-            addGroupTxMapping(writeSet());
-
         if (!empty) {
             batchStoreCommit(writeMap().values());
 
@@ -909,10 +890,6 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
                                             log.debug("Ignoring READ entry when committing: " + txEntry);
                                     }
                                     else {
-                                        assert !groupLock() || txEntry.groupLockEntry() || ownsLock(txEntry.cached()):
-                                            "Transaction does not own lock for group lock entry during  commit [tx=" +
-                                                this + ", txEntry=" + txEntry + ']';
-
                                         if (conflictCtx == null || !conflictCtx.isUseOld()) {
                                             if (txEntry.ttl() != CU.TTL_NOT_CHANGED)
                                                 cached.updateTtl(null, txEntry.ttl());
@@ -927,7 +904,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
                                 // we are not changing obsolete entries.
                                 // (innerSet and innerRemove will throw an exception
                                 // if an entry is obsolete).
-                                if (txEntry.op() != READ && !txEntry.groupLockEntry())
+                                if (txEntry.op() != READ)
                                     checkCommitLocks(cached);
 
                                 // Break out of while loop.
@@ -996,7 +973,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
         else {
             CacheStoreManager store = store();
 
-            if (store != null && (!internal() || groupLock())) {
+            if (store != null && !internal()) {
                 try {
                     store.sessionEnd(this, true);
                 }
@@ -1102,7 +1079,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
                 CacheStoreManager store = store();
 
                 if (store != null && (near() || store.isWriteToStoreFromDht())) {
-                    if (!internal() || groupLock())
+                    if (!internal())
                         store.sessionEnd(this, false);
                 }
             }
@@ -1152,8 +1129,6 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
 
         cacheCtx.checkSecurity(SecurityPermission.CACHE_READ);
 
-        groupLockSanityCheck(cacheCtx, keys);
-
         boolean single = keysCnt == 1;
 
         Collection<KeyCacheObject> lockKeys = null;
@@ -1185,7 +1160,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
                         cacheCtx.addResult(map, key, val, skipVals, keepCacheObjects, deserializePortable, false);
                 }
                 else {
-                    assert txEntry.op() == TRANSFORM || (groupLock() && !txEntry.groupLockEntry());
+                    assert txEntry.op() == TRANSFORM;
 
                     while (true) {
                         try {
@@ -1263,7 +1238,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
 
                         CacheObject val = null;
 
-                        if (!pessimistic() || readCommitted() || groupLock() && !skipVals) {
+                        if (!pessimistic() || readCommitted() && !skipVals) {
                             IgniteCacheExpiryPolicy accessPlc =
                                 optimistic() ? accessPolicy(cacheCtx, txKey, expiryPlc) : null;
 
@@ -1311,8 +1286,6 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
                                 null,
                                 skipStore);
 
-                            if (groupLock())
-                                txEntry.groupLockEntry(true);
 
                             // As optimization, mark as checked immediately
                             // for non-pessimistic if value is not null.
@@ -1527,7 +1500,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
                             nextVer = cctx.versions().next(topologyVersion());
 
                         while (true) {
-                            assert txEntry != null || readCommitted() || groupLock() || skipVals;
+                            assert txEntry != null || readCommitted() || skipVals;
 
                             GridCacheEntryEx e = txEntry == null ? entryEx(cacheCtx, txKey) : txEntry.cached();
 
@@ -1544,8 +1517,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
                                         log.debug("Got removed entry in transaction getAll method " +
                                             "(will try again): " + e);
 
-                                    if (pessimistic() && !readCommitted() && !isRollbackOnly() &&
-                                        (!groupLock() || F.eq(e.key(), groupLockKey()))) {
+                                    if (pessimistic() && !readCommitted() && !isRollbackOnly()) {
                                         U.error(log, "Inconsistent transaction state (entry got removed while " +
                                             "holding lock) [entry=" + e + ", tx=" + IgniteTxLocalAdapter.this + "]");
 
@@ -1563,7 +1535,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
                                 // In pessimistic mode, we should always be able to set.
                                 assert set || !pessimistic();
 
-                                if (readCommitted() || groupLock() || skipVals) {
+                                if (readCommitted() || skipVals) {
                                     cacheCtx.evicts().touch(e, topologyVersion());
 
                                     if (visibleVal != null) {
@@ -1654,7 +1626,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
                 return new GridFinishedFuture<>(retMap);
 
             // Handle locks.
-            if (pessimistic() && !readCommitted() && !groupLock() && !skipVals) {
+            if (pessimistic() && !readCommitted() && !skipVals) {
                 if (expiryPlc == null)
                     expiryPlc = cacheCtx.expiry();
 
@@ -1760,7 +1732,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
                             }
                         }
 
-                        if (!missed.isEmpty() && (cacheCtx.isReplicated() || cacheCtx.isLocal())) {
+                        if (!missed.isEmpty() && cacheCtx.isLocal()) {
                             return checkMissed(cacheCtx,
                                 retMap,
                                 missed,
@@ -1811,7 +1783,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
                 }
             }
             else {
-                assert optimistic() || readCommitted() || groupLock() || skipVals;
+                assert optimistic() || readCommitted() || skipVals;
 
                 final Collection<KeyCacheObject> redos = new ArrayList<>();
 
@@ -2036,8 +2008,6 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
             if (invokeMap != null)
                 transform = true;
 
-            groupLockSanityCheck(cacheCtx, keys);
-
             for (Object key : keys) {
                 if (key == null) {
                     rollback();
@@ -2194,12 +2164,9 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
                             if (!implicit() && readCommitted() && !cacheCtx.offheapTiered())
                                 cacheCtx.evicts().touch(entry, topologyVersion());
 
-                            if (groupLock() && !lockOnly)
-                                txEntry.groupLockEntry(true);
-
                             enlisted.add(cacheKey);
 
-                            if ((!pessimistic() && !implicit()) || (groupLock() && !lockOnly)) {
+                            if (!pessimistic() && !implicit()) {
                                 txEntry.markValid();
 
                                 if (old == null) {
@@ -2644,7 +2611,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
                 null,
                 opCtx != null && opCtx.skipStore());
 
-            if (pessimistic() && !groupLock()) {
+            if (pessimistic()) {
                 // Loose all skipped.
                 final Set<KeyCacheObject> loaded = loadFut.get();
 
@@ -2867,7 +2834,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
             // Acquire locks only after having added operation to the write set.
             // Otherwise, during rollback we will not know whether locks need
             // to be rolled back.
-            if (pessimistic() && !groupLock()) {
+            if (pessimistic()) {
                 // Loose all skipped.
                 final Collection<KeyCacheObject> passedKeys = F.view(enlisted, F0.notIn(loadFut.get()));
 
@@ -2985,108 +2952,6 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
     }
 
     /**
-     * Adds key mapping to transaction.
-     * @param keys Keys to add.
-     */
-    protected void addGroupTxMapping(Collection<IgniteTxKey> keys) {
-        // No-op. This method is overriden in transactions that store key to remote node mapping
-        // for commit.
-    }
-
-    /**
-     * Checks that affinity keys are enlisted in group transaction on start.
-     *
-     * @param cacheCtx Cache context.
-     * @param keys Keys to check.
-     * @throws IgniteCheckedException If sanity check failed.
-     */
-    private <K> void groupLockSanityCheck(GridCacheContext cacheCtx, Iterable<? extends K> keys)
-        throws IgniteCheckedException
-    {
-        if (groupLock() && cctx.kernalContext().config().isCacheSanityCheckEnabled()) {
-            // Note that affinity is called without mapper on purpose.
-            int affinityPart = cacheCtx.config().getAffinity().partition(grpLockKey.key());
-
-            for (K key : keys) {
-                if (partitionLock()) {
-                    int part = cacheCtx.affinity().partition(key);
-
-                    if (affinityPart != part)
-                        throw new IgniteCheckedException("Failed to enlist key into group-lock transaction (given " +
-                            "key does not belong to locked partition) [key=" + key + ", affinityPart=" + affinityPart +
-                            ", part=" + part + ", groupLockKey=" + grpLockKey + ']');
-                }
-                else {
-                    KeyCacheObject cacheKey =
-                        cacheCtx.toCacheKeyObject(cacheCtx.config().getAffinityMapper().affinityKey(key));
-
-                    IgniteTxKey affinityKey = cacheCtx.txKey(cacheKey);
-
-                    if (!grpLockKey.equals(affinityKey))
-                        throw new IgniteCheckedException("Failed to enlist key into group-lock transaction (affinity key was " +
-                            "not enlisted to transaction on start) [key=" + key + ", affinityKey=" + affinityKey +
-                            ", groupLockKey=" + grpLockKey + ']');
-                }
-            }
-        }
-    }
-
-    /**
-     * Performs keys locking for affinity-based group lock transactions.
-     * @return Lock future.
-     */
-    @Override public <K> IgniteInternalFuture<?> groupLockAsync(GridCacheContext cacheCtx, Collection<K> keys) {
-        assert groupLock();
-
-        try {
-            init();
-
-            GridCacheReturn ret = new GridCacheReturn(localResult(), false);
-
-            Collection<KeyCacheObject> enlisted = new ArrayList<>();
-
-            Set<KeyCacheObject> skipped = enlistWrite(
-                cacheCtx,
-                keys,
-                /** cached entry */null,
-                /** expiry - leave unchanged */null,
-                /** implicit */false,
-                /** lookup map */null,
-                /** invoke map */null,
-                /** invoke arguments */null,
-                /** retval */false,
-                /** lock only */true,
-                CU.empty0(),
-                ret,
-                enlisted,
-                null,
-                null,
-                cacheCtx.skipStore()
-            ).get();
-
-            // No keys should be skipped with empty filter.
-            assert F.isEmpty(skipped);
-
-            // Lock group key in pessimistic mode only.
-            return pessimistic() ?
-                cacheCtx.cache().txLockAsync(enlisted,
-                    lockTimeout(),
-                    this,
-                    false,
-                    false,
-                    isolation,
-                    isInvalidate(),
-                    -1L) :
-                new GridFinishedFuture<>();
-        }
-        catch (IgniteCheckedException e) {
-            setRollbackOnly();
-
-            return new GridFinishedFuture<Object>(e);
-        }
-    }
-
-    /**
      * Initializes read map.
      *
      * @return {@code True} if transaction was successfully  started.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9433882d/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalEx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalEx.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalEx.java
index 61041e1..14562ab 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalEx.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalEx.java
@@ -58,14 +58,9 @@ public interface IgniteTxLocalEx extends IgniteInternalTx {
     public void userRollback() throws IgniteCheckedException;
 
     /**
-     * @return Group lock entry if this is a group-lock transaction.
-     */
-    @Nullable public IgniteTxEntry groupLockEntry();
-
-    /**
      * @param cacheCtx Cache context.
      * @param keys Keys to get.
-     * @param cached Cached entry if this method is called from entry wrapper.
+     * @param cached Cached entry if this method is called from entry wrapper
      *      Cached entry is passed if and only if there is only one key in collection of keys.
      * @param deserializePortable Deserialize portable flag.
      * @param skipVals Skip values flag.
@@ -144,20 +139,6 @@ public interface IgniteTxLocalEx extends IgniteInternalTx {
         Map<KeyCacheObject, GridCacheVersion> drMap);
 
     /**
-     * Performs keys locking for affinity-based group lock transactions.
-     *
-     * @param cacheCtx Cache context.
-     * @param keys Keys to lock.
-     * @return Lock future.
-     */
-    public <K> IgniteInternalFuture<?> groupLockAsync(GridCacheContext cacheCtx, Collection<K> keys);
-
-    /**
-     * @return {@code True} if keys from the same partition are allowed to be enlisted in group-lock transaction.
-     */
-    public boolean partitionLock();
-
-    /**
      * @return Return value for
      */
     public GridCacheReturn implicitSingleResult();

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9433882d/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
index 8a1d490..8e95a5d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
@@ -347,8 +347,6 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter {
      * @param isolation Isolation.
      * @param timeout transaction timeout.
      * @param txSize Expected transaction size.
-     * @param grpLockKey Group lock key if this is a group-lock transaction.
-     * @param partLock {@code True} if partition is locked.
      * @return New transaction.
      */
     public IgniteTxLocalAdapter newTx(
@@ -359,9 +357,7 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter {
         TransactionIsolation isolation,
         long timeout,
         boolean storeEnabled,
-        int txSize,
-        @Nullable IgniteTxKey grpLockKey,
-        boolean partLock) {
+        int txSize) {
         assert sysCacheCtx == null || sysCacheCtx.systemTx();
 
         UUID subjId = null; // TODO GG-9141 how to get subj ID?
@@ -379,8 +375,6 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter {
             timeout,
             storeEnabled,
             txSize,
-            grpLockKey,
-            partLock,
             subjId,
             taskNameHash);
 
@@ -1207,13 +1201,10 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter {
             cctx.kernalContext().dataStructures().onTxCommitted(tx);
 
             // 4. Unlock write resources.
-            if (tx.groupLock())
-                unlockGroupLocks(tx);
-            else
-                unlockMultiple(tx, tx.writeEntries());
+            unlockMultiple(tx, tx.writeEntries());
 
             // 5. For pessimistic transaction, unlock read resources if required.
-            if (tx.pessimistic() && !tx.readCommitted() && !tx.groupLock())
+            if (tx.pessimistic() && !tx.readCommitted())
                 unlockMultiple(tx, tx.readEntries());
 
             // 6. Notify evictions.
@@ -1441,7 +1432,7 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter {
      * @param tx Transaction to notify evictions for.
      */
     private void notifyEvitions(IgniteInternalTx tx) {
-        if (tx.internal() && !tx.groupLock())
+        if (tx.internal())
             return;
 
         for (IgniteTxEntry txEntry : tx.allEntries())
@@ -1617,51 +1608,6 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter {
     }
 
     /**
-     * Unlocks entries locked by group transaction.
-     *
-     * @param txx Transaction.
-     */
-    @SuppressWarnings("unchecked")
-    private void unlockGroupLocks(IgniteInternalTx txx) {
-        IgniteTxKey grpLockKey = txx.groupLockKey();
-
-        assert grpLockKey != null;
-
-        if (grpLockKey == null)
-            return;
-
-        IgniteTxEntry txEntry = txx.entry(grpLockKey);
-
-        assert txEntry != null || (txx.near() && !txx.local());
-
-        if (txEntry != null) {
-            GridCacheContext cacheCtx = txEntry.context();
-
-            // Group-locked entries must be locked.
-            while (true) {
-                try {
-                    GridCacheEntryEx entry = txEntry.cached();
-
-                    assert entry != null;
-
-                    entry.txUnlock(txx);
-
-                    break;
-                }
-                catch (GridCacheEntryRemovedException ignored) {
-                    if (log.isDebugEnabled())
-                        log.debug("Got removed entry in TM unlockGroupLocks(..) method (will retry): " + txEntry);
-
-                    GridCacheAdapter cache = cacheCtx.cache();
-
-                    // Renew cache entry.
-                    txEntry.cached(cache.entryEx(txEntry.key()));
-                }
-            }
-        }
-    }
-
-    /**
      * @param tx Owning transaction.
      * @param entries Entries to unlock.
      */
@@ -1816,7 +1762,7 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter {
             if (nearVer.equals(tx.nearXidVersion())) {
                 TransactionState state = tx.state();
 
-                IgniteInternalFuture<IgniteInternalTx> prepFut = tx.currentPrepareFuture();
+                IgniteInternalFuture<?> prepFut = tx.currentPrepareFuture();
 
                 if (prepFut != null && !prepFut.isDone()) {
                     if (log.isDebugEnabled())
@@ -1828,8 +1774,8 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter {
 
                     final Collection<GridCacheVersion> processedVers0 = processedVers;
 
-                    prepFut.listen(new CI1<IgniteInternalFuture<IgniteInternalTx>>() {
-                        @Override public void apply(IgniteInternalFuture<IgniteInternalTx> prepFut) {
+                    prepFut.listen(new CI1<IgniteInternalFuture<?>>() {
+                        @Override public void apply(IgniteInternalFuture<?> prepFut) {
                             if (log.isDebugEnabled())
                                 log.debug("Transaction prepare future finished: " + tx);
 
@@ -2029,11 +1975,11 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter {
                             if (tx.state() == PREPARED)
                                 commitIfPrepared(tx);
                             else {
-                                IgniteInternalFuture<IgniteInternalTx> prepFut = tx.currentPrepareFuture();
+                                IgniteInternalFuture<?> prepFut = tx.currentPrepareFuture();
 
                                 if (prepFut != null) {
-                                    prepFut.listen(new CI1<IgniteInternalFuture<IgniteInternalTx>>() {
-                                        @Override public void apply(IgniteInternalFuture<IgniteInternalTx> fut) {
+                                    prepFut.listen(new CI1<IgniteInternalFuture<?>>() {
+                                        @Override public void apply(IgniteInternalFuture<?> fut) {
                                             if (tx.state() == PREPARED)
                                                 commitIfPrepared(tx);
                                             else if (tx.setRollbackOnly())

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9433882d/modules/core/src/main/java/org/apache/ignite/internal/processors/resource/GridResourceField.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/resource/GridResourceField.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/resource/GridResourceField.java
index 6b921f4..fed7ebd 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/resource/GridResourceField.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/resource/GridResourceField.java
@@ -22,6 +22,7 @@ import org.jetbrains.annotations.*;
 
 import java.lang.annotation.*;
 import java.lang.reflect.*;
+import java.util.*;
 
 /**
  * Wrapper for data where resource should be injected.
@@ -43,10 +44,7 @@ class GridResourceField {
      * @param field Field where resource should be injected.
      * @param ann Resource annotation.
      */
-    GridResourceField(Field field, @Nullable Annotation ann) {
-        assert field != null;
-        assert ann != null || GridResourceUtils.mayRequireResources(field);
-
+    GridResourceField(@NotNull Field field, @NotNull Annotation ann) {
         this.field = field;
         this.ann = ann;
 
@@ -78,6 +76,16 @@ class GridResourceField {
         return ann == null;
     }
 
+    /**
+     * @param c Closure.
+     */
+    public static GridResourceField[] toArray(Collection<GridResourceField> c) {
+        if (c.isEmpty())
+            return EMPTY_ARRAY;
+
+        return c.toArray(new GridResourceField[c.size()]);
+    }
+
     /** {@inheritDoc} */
     @Override public String toString() {
         return S.toString(GridResourceField.class, this);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9433882d/modules/core/src/main/java/org/apache/ignite/internal/processors/resource/GridResourceIoc.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/resource/GridResourceIoc.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/resource/GridResourceIoc.java
index 8410e71..1e85ecd 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/resource/GridResourceIoc.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/resource/GridResourceIoc.java
@@ -21,6 +21,7 @@ import org.apache.ignite.*;
 import org.apache.ignite.internal.managers.deployment.*;
 import org.apache.ignite.internal.util.*;
 import org.apache.ignite.internal.util.typedef.*;
+import org.apache.ignite.internal.util.typedef.internal.*;
 import org.jetbrains.annotations.*;
 import org.jsr166.*;
 
@@ -38,20 +39,8 @@ class GridResourceIoc {
     private final ConcurrentMap<ClassLoader, Set<Class<?>>> taskMap =
         new ConcurrentHashMap8<>();
 
-    /** Field cache. */
-    private final ConcurrentMap<Class<?>, ConcurrentMap<Class<? extends Annotation>, GridResourceField[]>> fieldCache =
-        new ConcurrentHashMap8<>();
-
-    /** Method cache. */
-    private final ConcurrentMap<Class<?>, ConcurrentMap<Class<? extends Annotation>, GridResourceMethod[]>> mtdCache =
-        new ConcurrentHashMap8<>();
-
-    /**
-     * Cache for classes that do not require injection with some annotation.
-     * Maps annotation classes to set a set of target classes to skip.
-     */
-    private final ConcurrentMap<Class<? extends Annotation>, Set<Class<?>>> skipCache =
-        new ConcurrentHashMap8<>();
+    /** Class descriptors cache. */
+    private final ConcurrentMap<Class<?>, ClassDescriptor> clsDescs = new ConcurrentHashMap8<>();
 
     /** */
     private final ConcurrentMap<Class<?>, Class<? extends Annotation>[]> annCache =
@@ -64,18 +53,8 @@ class GridResourceIoc {
         Set<Class<?>> clss = taskMap.remove(ldr);
 
         if (clss != null) {
-            fieldCache.keySet().removeAll(clss);
-            mtdCache.keySet().removeAll(clss);
-
-            for (Map.Entry<Class<? extends Annotation>, Set<Class<?>>> e : skipCache.entrySet()) {
-                Set<Class<?>> skipClss = e.getValue();
-
-                if (skipClss != null)
-                    e.getValue().removeAll(clss);
-            }
-
-            for (Class<?> cls : clss)
-                annCache.remove(cls);
+            clsDescs.keySet().removeAll(clss);
+            annCache.keySet().removeAll(clss);
         }
     }
 
@@ -84,8 +63,8 @@ class GridResourceIoc {
      */
     void undeployAll() {
         taskMap.clear();
-        mtdCache.clear();
-        fieldCache.clear();
+        clsDescs.clear();
+        annCache.clear();
     }
 
     /**
@@ -107,15 +86,26 @@ class GridResourceIoc {
         @Nullable Class<?> depCls)
         throws IgniteCheckedException
     {
-        assert target != null;
-        assert annCls != null;
-        assert injector != null;
+        return injectInternal(target, annCls, injector, dep, depCls, null);
+    }
 
-        if (isAnnotationPresent(target, annCls, dep))
-            // Use identity hash set to compare via referential equality.
-            return injectInternal(target, annCls, injector, dep, depCls, new GridLeanIdentitySet<>());
+    /**
+     * @param cls Class.
+     */
+    private ClassDescriptor descriptor(@Nullable GridDeployment dep, Class<?> cls) {
+        ClassDescriptor res = clsDescs.get(cls);
 
-        return false;
+        if (res == null) {
+            if (dep != null) {
+                Set<Class<?>> classes = F.addIfAbsent(taskMap, dep.classLoader(), F.<Class<?>>newCSet());
+
+                classes.add(cls);
+            }
+
+            res = F.addIfAbsent(clsDescs, cls, new ClassDescriptor(cls));
+        }
+
+        return res;
     }
 
     /**
@@ -133,73 +123,54 @@ class GridResourceIoc {
         GridResourceInjector injector,
         @Nullable GridDeployment dep,
         @Nullable Class<?> depCls,
-        Set<Object> checkedObjs)
+        @Nullable Set<Object> checkedObjs)
         throws IgniteCheckedException
     {
-        assert target != null;
-        assert annCls != null;
-        assert injector != null;
-        assert checkedObjs != null;
-
         Class<?> targetCls = target.getClass();
 
-        Set<Class<?>> skipClss = skipCache.get(annCls);
+        ClassDescriptor descr = descriptor(dep, targetCls);
 
-        // Skip this class if it does not need to be injected.
-        if (skipClss != null && skipClss.contains(targetCls))
-            return false;
+        T2<GridResourceField[], GridResourceMethod[]> annotatedMembers = descr.annotatedMembers(annCls);
 
-        // Check if already inspected to avoid indefinite recursion.
-        if (!checkedObjs.add(target))
+        if (descr.recursiveFields().length == 0 && annotatedMembers == null)
             return false;
 
-        int annCnt = 0;
+        if (checkedObjs == null && descr.recursiveFields().length > 0)
+            checkedObjs = new GridLeanIdentitySet<>();
 
-        boolean injected = false;
+        if (checkedObjs != null && !checkedObjs.add(target))
+            return false;
 
-        for (GridResourceField field : getFieldsWithAnnotation(dep, targetCls, annCls)) {
-            if (field.processFieldValue()) {
-                Field f = field.getField();
+        boolean injected = false;
 
-                try {
-                    Object obj = f.get(target);
+        for (Field field : descr.recursiveFields()) {
+            try {
+                Object obj = field.get(target);
 
-                    if (obj != null) {
-                        // Recursion.
-                        boolean injected0 = injectInternal(obj, annCls, injector, dep, depCls, checkedObjs);
+                if (obj != null) {
+                    assert checkedObjs != null;
 
-                        injected |= injected0;
-                    }
-                }
-                catch (IllegalAccessException e) {
-                    throw new IgniteCheckedException("Failed to inject resource [field=" + f.getName() +
-                        ", target=" + target + ']', e);
+                    injected |= injectInternal(obj, annCls, injector, dep, depCls, checkedObjs);
                 }
             }
-            else {
-                injector.inject(field, target, depCls, dep);
-
-                injected = true;
+            catch (IllegalAccessException e) {
+                throw new IgniteCheckedException("Failed to inject resource [field=" + field.getName() +
+                    ", target=" + target + ']', e);
             }
-
-            annCnt++;
         }
 
-        for (GridResourceMethod mtd : getMethodsWithAnnotation(dep, targetCls, annCls)) {
-            injector.inject(mtd, target, depCls, dep);
-
-            injected = true;
-
-            annCnt++;
-        }
+        if (annotatedMembers != null) {
+            for (GridResourceField field : annotatedMembers.get1()) {
+                injector.inject(field, target, depCls, dep);
 
-        if (annCnt == 0) {
-            if (skipClss == null)
-                skipClss = F.addIfAbsent(skipCache, annCls, F.<Class<?>>newCSet());
+                injected = true;
+            }
 
-            assert skipClss != null;
+            for (GridResourceMethod mtd : annotatedMembers.get2()) {
+                injector.inject(mtd, target, depCls, dep);
 
-            skipClss.add(targetCls);
+                injected = true;
+            }
         }
 
         return injected;
@@ -217,29 +188,9 @@ class GridResourceIoc {
         assert target != null;
         assert annCls != null;
 
-        Class<?> targetCls = target.getClass();
-
-        Set<Class<?>> skipClss = skipCache.get(annCls);
-
-        if (skipClss != null && skipClss.contains(targetCls))
-            return false;
-
-        GridResourceField[] fields = getFieldsWithAnnotation(dep, targetCls, annCls);
-
-        if (fields.length > 0)
-            return true;
+        ClassDescriptor desc = descriptor(dep, target.getClass());
 
-        GridResourceMethod[] mtds = getMethodsWithAnnotation(dep, targetCls, annCls);
-
-        if (mtds.length > 0)
-            return true;
-
-        if (skipClss == null)
-            skipClss = F.addIfAbsent(skipCache, annCls, F.<Class<?>>newCSet());
-
-        skipClss.add(targetCls);
-
-        return false;
+        return desc.recursiveFields().length > 0 || desc.annotatedMembers(annCls) != null;
     }
 
     /**
@@ -260,17 +211,14 @@ class GridResourceIoc {
         Class<? extends Annotation>[] res = annCache.get(cls);
 
         if (res == null) {
-            Collection<Class<? extends Annotation>> res0 =
-                new HashSet<>(annClss.size(), 1.0f);
+            Collection<Class<? extends Annotation>> res0 = new ArrayList<>();
 
             for (Class<? extends Annotation> annCls : annClss) {
                 if (isAnnotationPresent(target, annCls, dep))
                     res0.add(annCls);
             }
 
-            res = new Class[res0.size()];
-
-            res0.toArray(res);
+            res = res0.toArray(new Class[res0.size()]);
 
             annCache.putIfAbsent(cls, res);
         }
@@ -279,36 +227,6 @@ class GridResourceIoc {
     }
 
     /**
-     * For tests only.
-     *
-     * @param cls Class for test.
-     * @return {@code true} if cached, {@code false} otherwise.
-     */
-    boolean isCached(Class<?> cls) {
-        return isCached(cls.getName());
-    }
-
-    /**
-     * For tests only.
-     *
-     * @param clsName Class for test.
-     * @return {@code true} if cached, {@code false} otherwise.
-     */
-    boolean isCached(String clsName) {
-        for (Class<?> aClass : fieldCache.keySet()) {
-            if (aClass.getName().equals(clsName))
-                return true;
-        }
-
-        for (Class<?> aClass : mtdCache.keySet()) {
-            if (aClass.getName().equals(clsName))
-                return true;
-        }
-
-        return false;
-    }
-
-    /**
      * Gets set of methods with given annotation.
      *
      * @param dep Deployment.
@@ -318,156 +236,111 @@ class GridResourceIoc {
      */
     GridResourceMethod[] getMethodsWithAnnotation(@Nullable GridDeployment dep, Class<?> cls,
         Class<? extends Annotation> annCls) {
-        GridResourceMethod[] mtds = getMethodsFromCache(cls, annCls);
+        ClassDescriptor desc = descriptor(dep, cls);
 
-        if (mtds == null) {
-            List<GridResourceMethod> mtdsList = new ArrayList<>();
-
-            for (Class cls0 = cls; !cls0.equals(Object.class); cls0 = cls0.getSuperclass()) {
-                for (Method mtd : cls0.getDeclaredMethods()) {
-                    Annotation ann = mtd.getAnnotation(annCls);
-
-                    if (ann != null)
-                        mtdsList.add(new GridResourceMethod(mtd, ann));
-                }
-            }
+        T2<GridResourceField[], GridResourceMethod[]> t2 = desc.annotatedMembers(annCls);
 
-            if (mtdsList.isEmpty())
-                mtds = GridResourceMethod.EMPTY_ARRAY;
-            else
-                mtds = mtdsList.toArray(new GridResourceMethod[mtdsList.size()]);
-
-            cacheMethods(dep, cls, annCls, mtds);
-        }
+        return t2 == null ? GridResourceMethod.EMPTY_ARRAY : t2.get2();
+    }
 
-        return mtds;
+    /** {@inheritDoc} */
+    public void printMemoryStats() {
+        X.println(">>>   taskMapSize: " + taskMap.size());
+        X.println(">>>   classDescriptorsCacheSize: " + clsDescs.size());
     }
 
     /**
-     * Gets all entries from the specified class or its super-classes that have
-     * been annotated with annotation provided.
      *
-     * @param cls Class in which search for methods.
-     * @param dep Deployment.
-     * @param annCls Annotation.
-     * @return Set of entries with given annotations.
      */
-    private GridResourceField[] getFieldsWithAnnotation(@Nullable GridDeployment dep, Class<?> cls,
-        Class<? extends Annotation> annCls) {
-        GridResourceField[] fields = getFieldsFromCache(cls, annCls);
+    private static class ClassDescriptor {
+        /** */
+        private final Field[] recursiveFields;
+
+        /** */
+        private final Map<Class<? extends Annotation>, T2<GridResourceField[], GridResourceMethod[]>> annMap;
+
+        /**
+         * @param cls Class.
+         */
+        ClassDescriptor(Class<?> cls) {
+            Map<Class<? extends Annotation>, T2<List<GridResourceField>, List<GridResourceMethod>>> annMap
+                = new HashMap<>();
 
-        if (fields == null) {
-            List<GridResourceField> fieldsList = new ArrayList<>();
+            List<Field> recursiveFieldsList = new ArrayList<>();
 
             boolean allowImplicitInjection = !GridNoImplicitInjection.class.isAssignableFrom(cls);
 
             for (Class cls0 = cls; !cls0.equals(Object.class); cls0 = cls0.getSuperclass()) {
                 for (Field field : cls0.getDeclaredFields()) {
-                    Annotation ann = field.getAnnotation(annCls);
-
-                    if (ann != null)
-                        fieldsList.add(new GridResourceField(field, ann));
-                    else if (allowImplicitInjection && GridResourceUtils.mayRequireResources(field)) {
-                        // Account for anonymous inner classes.
-                        fieldsList.add(new GridResourceField(field, null));
-                    }
-                }
-            }
-
-            if (fieldsList.isEmpty())
-                fields = GridResourceField.EMPTY_ARRAY;
-            else
-                fields = fieldsList.toArray(new GridResourceField[fieldsList.size()]);
+                    Annotation[] fieldAnns = field.getAnnotations();
 
-            cacheFields(dep, cls, annCls, fields);
-        }
+                    for (Annotation ann : fieldAnns) {
+                        T2<List<GridResourceField>, List<GridResourceMethod>> t2 = annMap.get(ann.annotationType());
 
-        return fields;
-    }
+                        if (t2 == null) {
+                            t2 = new T2<List<GridResourceField>, List<GridResourceMethod>>(
+                                new ArrayList<GridResourceField>(),
+                                new ArrayList<GridResourceMethod>());
 
-    /**
-     * Gets all fields for a given class with given annotation from cache.
-     *
-     * @param cls Class to get fields from.
-     * @param annCls Annotation class for fields.
-     * @return List of fields with given annotation, possibly {@code null}.
-     */
-    @Nullable private GridResourceField[] getFieldsFromCache(Class<?> cls, Class<? extends Annotation> annCls) {
-        Map<Class<? extends Annotation>, GridResourceField[]> annCache = fieldCache.get(cls);
+                            annMap.put(ann.annotationType(), t2);
+                        }
 
-        return annCache != null ? annCache.get(annCls) : null;
-    }
-
-    /**
-     * Caches list of fields with given annotation from given class.
-     *
-     * @param cls Class the fields belong to.
-     * @param dep Deployment.
-     * @param annCls Annotation class for the fields.
-     * @param fields Fields to cache.
-     */
-    private void cacheFields(@Nullable GridDeployment dep, Class<?> cls, Class<? extends Annotation> annCls,
-        GridResourceField[] fields) {
-        if (dep != null) {
-            Set<Class<?>> classes = F.addIfAbsent(taskMap, dep.classLoader(), F.<Class<?>>newCSet());
+                        t2.get1().add(new GridResourceField(field, ann));
+                    }
 
-            assert classes != null;
+                    if (allowImplicitInjection
+                        && fieldAnns.length == 0
+                        && GridResourceUtils.mayRequireResources(field)) {
+                        field.setAccessible(true);
 
-            classes.add(cls);
-        }
+                        // Account for anonymous inner classes.
+                        recursiveFieldsList.add(field);
+                    }
+                }
 
-        Map<Class<? extends Annotation>, GridResourceField[]> rsrcFields =
-            F.addIfAbsent(fieldCache, cls, F.<Class<? extends Annotation>, GridResourceField[]>newCMap());
+                for (Method mtd : cls0.getDeclaredMethods()) {
+                    for (Annotation ann : mtd.getAnnotations()) {
+                        T2<List<GridResourceField>, List<GridResourceMethod>> t2 = annMap.get(ann.annotationType());
 
-        assert rsrcFields != null;
+                        if (t2 == null) {
+                            t2 = new T2<List<GridResourceField>, List<GridResourceMethod>>(
+                                new ArrayList<GridResourceField>(),
+                                new ArrayList<GridResourceMethod>());
 
-        rsrcFields.put(annCls, fields);
-    }
+                            annMap.put(ann.annotationType(), t2);
+                        }
 
-    /**
-     * Gets all methods for a given class with given annotation from cache.
-     *
-     * @param cls Class to get methods from.
-     * @param annCls Annotation class for fields.
-     * @return List of methods with given annotation, possibly {@code null}.
-     */
-    @Nullable private GridResourceMethod[] getMethodsFromCache(Class<?> cls, Class<? extends Annotation> annCls) {
-        Map<Class<? extends Annotation>, GridResourceMethod[]> annCache = mtdCache.get(cls);
+                        t2.get2().add(new GridResourceMethod(mtd, ann));
+                    }
+                }
+            }
 
-        return annCache != null ? annCache.get(annCls) : null;
-    }
+            recursiveFields = recursiveFieldsList.isEmpty() ? U.EMPTY_FIELDS
+                : recursiveFieldsList.toArray(new Field[recursiveFieldsList.size()]);
 
-    /**
-     * Caches list of methods with given annotation from given class.
-     *
-     * @param rsrcCls Class the fields belong to.
-     * @param dep Deployment.
-     * @param annCls Annotation class for the fields.
-     * @param mtds Methods to cache.
-     */
-    private void cacheMethods(@Nullable GridDeployment dep, Class<?> rsrcCls, Class<? extends Annotation> annCls,
-        GridResourceMethod[] mtds) {
-        if (dep != null) {
-            Set<Class<?>> classes = F.addIfAbsent(taskMap, dep.classLoader(), F.<Class<?>>newCSet());
+            this.annMap = IgniteUtils.limitedMap(annMap.size());
 
-            assert classes != null;
+            for (Map.Entry<Class<? extends Annotation>, T2<List<GridResourceField>, List<GridResourceMethod>>> entry
+                : annMap.entrySet()) {
+                GridResourceField[] fields = GridResourceField.toArray(entry.getValue().get1());
+                GridResourceMethod[] mtds = GridResourceMethod.toArray(entry.getValue().get2());
 
-            classes.add(rsrcCls);
+                this.annMap.put(entry.getKey(), new T2<>(fields, mtds));
+            }
         }
 
-        Map<Class<? extends Annotation>, GridResourceMethod[]> rsrcMtds = F.addIfAbsent(mtdCache,
-            rsrcCls, F.<Class<? extends Annotation>, GridResourceMethod[]>newCMap());
-
-        assert rsrcMtds != null;
-
-        rsrcMtds.put(annCls, mtds);
-    }
+        /**
+         * @return Recursive fields.
+         */
+        public Field[] recursiveFields() {
+            return recursiveFields;
+        }
 
-    /** {@inheritDoc} */
-    public void printMemoryStats() {
-        X.println(">>>   taskMapSize: " + taskMap.size());
-        X.println(">>>   fieldCacheSize: " + fieldCache.size());
-        X.println(">>>   mtdCacheSize: " + mtdCache.size());
-        X.println(">>>   skipCacheSize: " + skipCache.size());
+        /**
+         * @return Fields.
+         */
+        @Nullable public T2<GridResourceField[], GridResourceMethod[]> annotatedMembers(Class<? extends Annotation> annCls) {
+            return annMap.get(annCls);
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9433882d/modules/core/src/main/java/org/apache/ignite/internal/processors/resource/GridResourceMethod.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/resource/GridResourceMethod.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/resource/GridResourceMethod.java
index aba9405..ad08a40 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/resource/GridResourceMethod.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/resource/GridResourceMethod.java
@@ -21,6 +21,7 @@ import org.apache.ignite.internal.util.typedef.internal.*;
 
 import java.lang.annotation.*;
 import java.lang.reflect.*;
+import java.util.*;
 
 /**
  * Wrapper for data where resource should be injected.
@@ -48,6 +49,8 @@ class GridResourceMethod {
 
         this.mtd = mtd;
         this.ann = ann;
+
+        mtd.setAccessible(true);
     }
 
     /**
@@ -68,6 +71,16 @@ class GridResourceMethod {
         return ann;
     }
 
+    /**
+     * @param c Closure.
+     */
+    public static GridResourceMethod[] toArray(Collection<GridResourceMethod> c) {
+        if (c.isEmpty())
+            return EMPTY_ARRAY;
+
+        return c.toArray(new GridResourceMethod[c.size()]);
+    }
+
     /** {@inheritDoc} */
     @Override public String toString() {
         return S.toString(GridResourceMethod.class, this);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9433882d/modules/core/src/main/java/org/apache/ignite/internal/processors/resource/GridResourceProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/resource/GridResourceProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/resource/GridResourceProcessor.java
index f08a287..f5ba492 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/resource/GridResourceProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/resource/GridResourceProcessor.java
@@ -23,7 +23,6 @@ import org.apache.ignite.compute.*;
 import org.apache.ignite.internal.*;
 import org.apache.ignite.internal.managers.deployment.*;
 import org.apache.ignite.internal.processors.*;
-import org.apache.ignite.internal.util.lang.*;
 import org.apache.ignite.internal.util.typedef.*;
 import org.apache.ignite.lifecycle.*;
 import org.apache.ignite.resources.*;
@@ -147,8 +146,8 @@ public class GridResourceProcessor extends GridProcessorAdapter {
                 Method mtd = rsrcMtd.getMethod();
 
                 try {
-                    mtd.setAccessible(true);
-
+                    // No need to call mtd.setAccessible(true);
+                    // It has been called in GridResourceMethod constructor.
                     mtd.invoke(target);
                 }
                 catch (IllegalArgumentException | InvocationTargetException | IllegalAccessException e) {
@@ -278,7 +277,7 @@ public class GridResourceProcessor extends GridProcessorAdapter {
             log.debug("Injecting resources: " + job);
 
         // Unwrap Proxy object.
-        Object obj = unwrapTarget(unwrapJob(job));
+        Object obj = unwrapTarget(job);
 
         injectToJob(dep, taskCls, obj, ses, jobCtx);
 
@@ -329,19 +328,6 @@ public class GridResourceProcessor extends GridProcessorAdapter {
     }
 
     /**
-     * Gets rid of job wrapper, if any.
-     *
-     * @param job Job to unwrap.
-     * @return Unwrapped job.
-     */
-    private ComputeJob unwrapJob(ComputeJob job) {
-        if (job instanceof GridComputeJobWrapper)
-            return ((GridComputeJobWrapper)job).wrappedJob();
-
-        return job;
-    }
-
-    /**
      * Injects held resources into given grid task.
      *
      * @param dep Deployed class.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9433882d/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
index 2ab8e0a..80fcbb0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
@@ -109,10 +109,13 @@ public abstract class IgniteUtils {
     private static final int[] GRID_EVTS;
 
     /** Empty integers array. */
-    private static final int[] EMPTY_INTS = new int[0];
+    public static final int[] EMPTY_INTS = new int[0];
 
     /** Empty  longs. */
-    private static final long[] EMPTY_LONGS = new long[0];
+    public static final long[] EMPTY_LONGS = new long[0];
+
+    /** Empty  longs. */
+    public static final Field[] EMPTY_FIELDS = new Field[0];
 
     /** System line separator. */
     private static final String NL = System.getProperty("line.separator");
@@ -8856,6 +8859,21 @@ public abstract class IgniteUtils {
     }
 
     /**
+     * Creates new map that limited by size.
+     *
+     * @param limit Limit for size.
+     */
+    public static <K, V> Map<K, V> limitedMap(int limit) {
+        if (limit == 0)
+            return Collections.emptyMap();
+
+        if (limit < 5)
+            return new GridLeanMap<>(limit);
+
+        return new HashMap<>(capacity(limit), 0.75f);
+    }
+
+    /**
      * Returns comparator that sorts remote node addresses. If remote node resides on the same host, then put
      * loopback addresses first, last otherwise.
      *

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9433882d/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridComputeJobWrapper.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridComputeJobWrapper.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridComputeJobWrapper.java
deleted file mode 100644
index 82c0078..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridComputeJobWrapper.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.util.lang;
-
-import org.apache.ignite.compute.*;
-import org.apache.ignite.internal.util.typedef.internal.*;
-import org.jetbrains.annotations.*;
-
-import java.util.concurrent.*;
-
-/**
- * Convenient wrapper for grid job. It allows to create a job clone in cases when the same
- * job needs to be cloned to multiple grid nodes during mapping phase of task execution.
- */
-public class GridComputeJobWrapper implements ComputeJob, Callable<Object>,
-    GridPeerDeployAware {
-    /** */
-    private static final long serialVersionUID = 0L;
-
-    /** */
-    private final ComputeJob job;
-
-    /** Peer deploy aware class. */
-    private transient volatile GridPeerDeployAware p;
-
-    /**
-     * Creates a wrapper with given grid {@code job}.
-     *
-     * @param job Job to wrap.
-     */
-    public GridComputeJobWrapper(ComputeJob job) {
-        A.notNull(job, "job");
-
-        this.job = job;
-    }
-
-    /**
-     * Gets wrapped job.
-     *
-     * @return Wrapped job.
-     */
-    public ComputeJob wrappedJob() {
-        return job;
-    }
-
-    /** {@inheritDoc} */
-    @Nullable @Override public final Object call() throws Exception {
-        return execute();
-    }
-
-    /** {@inheritDoc} */
-    @Override public Class<?> deployClass() {
-        if (p == null)
-            p = U.detectPeerDeployAware(this);
-
-        return p.deployClass();
-    }
-
-    /** {@inheritDoc} */
-    @Override public ClassLoader classLoader() {
-        if (p == null)
-            p = U.detectPeerDeployAware(this);
-
-        return p.classLoader();
-    }
-
-    /** {@inheritDoc} */
-    @Override public void cancel() {
-        job.cancel();
-    }
-
-    /** {@inheritDoc} */
-    @Override public Object execute() {
-        return job.execute();
-    }
-
-    /** {@inheritDoc} */
-    @Override public String toString() {
-        return S.toString(GridComputeJobWrapper.class, this);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9433882d/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridBufferedParser.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridBufferedParser.java b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridBufferedParser.java
index 3f81dc4..a03d2c8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridBufferedParser.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridBufferedParser.java
@@ -18,7 +18,6 @@
 package org.apache.ignite.internal.util.nio;
 
 import org.apache.ignite.*;
-import org.apache.ignite.internal.util.typedef.internal.*;
 
 import java.io.*;
 import java.nio.*;
@@ -33,9 +32,6 @@ import java.nio.*;
  *     | MSG_SIZE  |   MESSAGE  | MSG_SIZE  |   MESSAGE  |
  *     +--+--+--+--+--+--+...+--+--+--+--+--+--+--+...+--+
  * </pre>
- * <p>
- * It expects that first 4 bytes in stream are {@link U#IGNITE_HEADER}. If beginning of a stream,
- * isn't equal to these bytes than exception will be thrown.
  */
 public class GridBufferedParser implements GridNioParser {
     /** Buffer metadata key. */

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9433882d/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridDelimitedParser.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridDelimitedParser.java b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridDelimitedParser.java
new file mode 100644
index 0000000..256597c
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridDelimitedParser.java
@@ -0,0 +1,91 @@
+/*
+ * 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.util.nio;
+
+import org.apache.ignite.*;
+
+import java.io.*;
+import java.nio.*;
+
+/**
+ * This class implements stream parser based on {@link GridNioDelimitedBuffer}.
+ * <p>
+ * The rule for this parser is that every message sent over the stream is appended with
+ * delimiter (bytes array). So, the stream structure is as follows:
+ * <pre>
+ *     +--+--+...+--+--+--+--+--+--+--+...+--+--+--+--+--+-
+ *     |   MESSAGE  | DELIMITER  |  MESSAGE  | DELIMITER  |
+ *     +--+--+...+--+--+--+--+--+--+--+...+--+--+--+--+--+-
+ * </pre>
+ */
+public class GridDelimitedParser implements GridNioParser {
+    /** Buffer metadata key. */
+    private static final int BUF_META_KEY = GridNioSessionMetaKey.nextUniqueKey();
+
+    /** Delimiter. */
+    private final byte[] delim;
+
+    /** Direct buffer. */
+    private final boolean directBuf;
+
+    /**
+     * @param delim Delimiter.
+     * @param directBuf Direct buffer.
+     */
+    public GridDelimitedParser(byte[] delim, boolean directBuf) {
+        this.delim = delim;
+        this.directBuf = directBuf;
+    }
+
+    /** {@inheritDoc} */
+    @Override public byte[] decode(GridNioSession ses, ByteBuffer buf) throws IOException, IgniteCheckedException {
+        GridNioDelimitedBuffer nioBuf = ses.meta(BUF_META_KEY);
+
+        // Decode for a given session is called per one thread, so there should not be any concurrency issues.
+        // However, we make some additional checks.
+        if (nioBuf == null) {
+            nioBuf = new GridNioDelimitedBuffer(delim);
+
+            GridNioDelimitedBuffer old = ses.addMeta(BUF_META_KEY, nioBuf);
+
+            assert old == null;
+        }
+
+        return nioBuf.read(buf);
+    }
+
+    /** {@inheritDoc} */
+    @Override public ByteBuffer encode(GridNioSession ses, Object msg) throws IOException, IgniteCheckedException {
+        byte[] msg0 = (byte[])msg;
+
+        int cap = msg0.length + delim.length;
+        ByteBuffer res = directBuf ? ByteBuffer.allocateDirect(cap) : ByteBuffer.allocate(cap);
+
+        res.put(msg0);
+        res.put(delim);
+
+        res.flip();
+
+        return res;
+    }
+
+    /** {@inheritDoc} */
+    @Override public String toString() {
+        return this.getClass().getSimpleName();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9433882d/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioDelimitedBuffer.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioDelimitedBuffer.java b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioDelimitedBuffer.java
new file mode 100644
index 0000000..2b764ec
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioDelimitedBuffer.java
@@ -0,0 +1,106 @@
+/*
+ * 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.util.nio;
+
+import org.jetbrains.annotations.*;
+
+import java.nio.*;
+import java.util.*;
+
+/**
+ * Buffer with message delimiter support.
+ */
+public class GridNioDelimitedBuffer {
+    /** Delimiter. */
+    private final byte[] delim;
+
+    /** Data. */
+    private byte[] data = new byte[16384];
+
+    /** Count. */
+    private int cnt;
+
+    /** Index. */
+    private int idx;
+
+    /**
+     * @param delim Delimiter.
+     */
+    public GridNioDelimitedBuffer(byte[] delim) {
+        assert delim != null;
+        assert delim.length > 0;
+
+        this.delim = delim;
+
+        reset();
+    }
+
+    /**
+     * Resets buffer state.
+     */
+    private void reset() {
+        cnt = 0;
+        idx = 0;
+    }
+
+    /**
+     * @param buf Buffer.
+     * @return Message bytes or {@code null} if message is not fully read yet.
+     */
+    @Nullable public byte[] read(ByteBuffer buf) {
+        while(buf.hasRemaining()) {
+            if (cnt == data.length)
+                data = Arrays.copyOf(data, data.length * 2);
+
+            byte b = buf.get();
+
+            data[cnt++] = b;
+
+            if (b == delim[idx])
+                idx++;
+            else if (idx > 0) {
+                int pos = cnt - idx;
+
+                idx = 0;
+
+                for (int i = pos; i < cnt; i++) {
+                    if (data[pos] == delim[idx]) {
+                        pos++;
+
+                        idx++;
+                    }
+                    else {
+                        pos = cnt - idx;
+
+                        idx = 0;
+                    }
+                }
+            }
+
+            if (idx == delim.length) {
+                byte[] bytes = Arrays.copyOfRange(data, 0, cnt - delim.length);
+
+                reset();
+
+                return bytes;
+            }
+        }
+
+        return null;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9433882d/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
index 2d5c541..fd17791 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
@@ -203,7 +203,7 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter
     public static final int DFLT_ACK_SND_THRESHOLD = 16;
 
     /** Default socket write timeout. */
-    public static final long DFLT_SOCK_WRITE_TIMEOUT = GridNioServer.DFLT_SES_WRITE_TIMEOUT;
+    public static final long DFLT_SOCK_WRITE_TIMEOUT = 200;
 
     /** No-op runnable. */
     private static final IgniteRunnable NOOP = new IgniteRunnable() {



Mime
View raw message