Return-Path: X-Original-To: apmail-ignite-commits-archive@minotaur.apache.org Delivered-To: apmail-ignite-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 76F24196D6 for ; Tue, 26 Apr 2016 06:40:11 +0000 (UTC) Received: (qmail 18068 invoked by uid 500); 26 Apr 2016 06:40:11 -0000 Delivered-To: apmail-ignite-commits-archive@ignite.apache.org Received: (qmail 17949 invoked by uid 500); 26 Apr 2016 06:40:11 -0000 Mailing-List: contact commits-help@ignite.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.apache.org Delivered-To: mailing list commits@ignite.apache.org Received: (qmail 17734 invoked by uid 99); 26 Apr 2016 06:40:11 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 26 Apr 2016 06:40:11 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 096ADE2EE7; Tue, 26 Apr 2016 06:40:11 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: vozerov@apache.org To: commits@ignite.apache.org Date: Tue, 26 Apr 2016 06:40:22 -0000 Message-Id: <7f88f23f1f4a486ca6d2f8fdba310c44@git.apache.org> In-Reply-To: <5240ce4bc89f4043a433adbe06936e00@git.apache.org> References: <5240ce4bc89f4043a433adbe06936e00@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [13/15] ignite git commit: Minors. Minors. Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/02fbde0f Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/02fbde0f Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/02fbde0f Branch: refs/heads/ignite-2523-1-dht Commit: 02fbde0f676f2c4677b93c4081d9b8e384d64ddd Parents: 98d23e0 Author: vozerov-gridgain Authored: Tue Apr 26 09:32:10 2016 +0300 Committer: vozerov-gridgain Committed: Tue Apr 26 09:32:10 2016 +0300 ---------------------------------------------------------------------- .../dht/atomic/GridDhtAtomicCache.java | 39 ++++++++------------ .../GridNearAtomicAbstractUpdateRequest.java | 6 +++ .../GridNearAtomicSingleUpdateRequest.java | 7 ++++ .../dht/atomic/GridNearAtomicUpdateRequest.java | 5 +++ .../distributed/near/GridNearAtomicCache.java | 2 +- 5 files changed, 35 insertions(+), 24 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/02fbde0f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java index 34533e9..c48787c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java @@ -1502,9 +1502,7 @@ public class GridDhtAtomicCache extends GridDhtCacheAdapter { GridNearAtomicUpdateResponse res = new GridNearAtomicUpdateResponse(ctx.cacheId(), nodeId, req.futureVersion(), ctx.deploymentEnabled()); - List keys = req.keys(); - - assert !req.returnValue() || (req.operation() == TRANSFORM || keys.size() == 1); + assert !req.returnValue() || (req.operation() == TRANSFORM || req.keysCount() == 1); GridDhtAtomicUpdateFuture dhtFut = null; @@ -1517,7 +1515,7 @@ public class GridDhtAtomicCache extends GridDhtCacheAdapter { try { // If batch store update is enabled, we need to lock all entries. // First, need to acquire locks on cache entries, then check filter. - List locked = lockEntries(keys, req.topologyVersion()); + List locked = lockEntries(req); Collection> deleted = null; @@ -1528,7 +1526,7 @@ public class GridDhtAtomicCache extends GridDhtCacheAdapter { try { if (top.stopping()) { - res.addFailedKeys(keys, new IgniteCheckedException("Failed to perform cache operation " + + res.addFailedKeys(req.keys(), new IgniteCheckedException("Failed to perform cache operation " + "(cache is stopped): " + name())); completionCb.apply(req, res); @@ -1576,7 +1574,7 @@ public class GridDhtAtomicCache extends GridDhtCacheAdapter { GridCacheReturn retVal = null; - if (keys.size() > 1 && // Several keys ... + if (req.keysCount() > 1 && // Several keys ... writeThrough() && !req.skipStore() && // and store is enabled ... !ctx.store().isLocal() && // and this is not local store ... !ctx.dr().receiveEnabled() // and no DR. @@ -1671,7 +1669,7 @@ public class GridDhtAtomicCache extends GridDhtCacheAdapter { // an attempt to use cleaned resources. U.error(log, "Unexpected exception during cache update", e); - res.addFailedKeys(keys, e); + res.addFailedKeys(req.keys(), e); completionCb.apply(req, res); @@ -1684,7 +1682,7 @@ public class GridDhtAtomicCache extends GridDhtCacheAdapter { if (remap) { assert dhtFut == null; - res.remapKeys(keys); + res.remapKeys(req.keys()); completionCb.apply(req, res); } @@ -2155,8 +2153,6 @@ public class GridDhtAtomicCache extends GridDhtCacheAdapter { GridCacheReturn retVal = null; Collection> deleted = null; - List keys = req.keys(); - AffinityTopologyVersion topVer = req.topologyVersion(); boolean checkReaders = hasNear || ctx.discovery().hasNearCache(name(), topVer); @@ -2166,8 +2162,8 @@ public class GridDhtAtomicCache extends GridDhtCacheAdapter { boolean intercept = ctx.config().getInterceptor() != null; // Avoid iterator creation. - for (int i = 0; i < keys.size(); i++) { - KeyCacheObject k = keys.get(i); + for (int i = 0; i < req.keysCount(); i++) { + KeyCacheObject k = req.key(i); GridCacheOperation op = req.operation(); @@ -2302,7 +2298,7 @@ public class GridDhtAtomicCache extends GridDhtCacheAdapter { if (updRes.removeVersion() != null) { if (deleted == null) - deleted = new ArrayList<>(keys.size()); + deleted = new ArrayList<>(req.keysCount()); deleted.add(F.t(entry, updRes.removeVersion())); } @@ -2615,21 +2611,18 @@ public class GridDhtAtomicCache extends GridDhtCacheAdapter { /** * Acquires java-level locks on cache entries. Returns collection of locked entries. * - * @param keys Keys to lock. - * @param topVer Topology version to lock on. + * @param req Request. * @return Collection of locked entries. * @throws GridDhtInvalidPartitionException If entry does not belong to local node. If exception is thrown, * locks are released. */ @SuppressWarnings("ForLoopReplaceableByForEach") - private List lockEntries(List keys, AffinityTopologyVersion topVer) + private List lockEntries(GridNearAtomicAbstractUpdateRequest req) throws GridDhtInvalidPartitionException { - if (keys.size() == 1) { - KeyCacheObject key = keys.get(0); - + if (req.keysCount() == 1) { while (true) { try { - GridDhtCacheEntry entry = entryExx(key, topVer); + GridDhtCacheEntry entry = entryExx(req.key(0), req.topologyVersion()); GridUnsafe.monitorEnter(entry); @@ -2648,12 +2641,12 @@ public class GridDhtAtomicCache extends GridDhtCacheAdapter { } } else { - List locked = new ArrayList<>(keys.size()); + List locked = new ArrayList<>(req.keysCount()); while (true) { - for (KeyCacheObject key : keys) { + for (int i = 0; i < req.keysCount(); i++) { try { - GridDhtCacheEntry entry = entryExx(key, topVer); + GridDhtCacheEntry entry = entryExx(req.key(i), req.topologyVersion()); locked.add(entry); } http://git-wip-us.apache.org/repos/asf/ignite/blob/02fbde0f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicAbstractUpdateRequest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicAbstractUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicAbstractUpdateRequest.java index 84077e5..0af7d88 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicAbstractUpdateRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicAbstractUpdateRequest.java @@ -165,6 +165,12 @@ public abstract class GridNearAtomicAbstractUpdateRequest extends GridCacheMessa public abstract int keysCount(); /** + * @param idx Key index. + * @return Key. + */ + public abstract KeyCacheObject key(int idx); + + /** * @return Values for this update request. */ public abstract List values(); http://git-wip-us.apache.org/repos/asf/ignite/blob/02fbde0f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateRequest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateRequest.java index 745fe02..f3d0c08 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateRequest.java @@ -344,6 +344,13 @@ public class GridNearAtomicSingleUpdateRequest extends GridNearAtomicAbstractUpd } /** {@inheritDoc} */ + @Override public KeyCacheObject key(int idx) { + assert idx == 0; + + return key; + } + + /** {@inheritDoc} */ @Override public List values() { return op == TRANSFORM ? Collections.singletonList(entryProcessor) : Collections.singletonList(val); } http://git-wip-us.apache.org/repos/asf/ignite/blob/02fbde0f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java index 5a99147..5a5d889 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java @@ -408,6 +408,11 @@ public class GridNearAtomicUpdateRequest extends GridNearAtomicAbstractUpdateReq } /** {@inheritDoc} */ + @Override public KeyCacheObject key(int idx) { + return keys.get(idx); + } + + /** {@inheritDoc} */ @Override public List values() { return op == TRANSFORM ? entryProcessors : vals; } http://git-wip-us.apache.org/repos/asf/ignite/blob/02fbde0f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearAtomicCache.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearAtomicCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearAtomicCache.java index bc35edd..ac87ead 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearAtomicCache.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearAtomicCache.java @@ -156,7 +156,7 @@ public class GridNearAtomicCache extends GridNearCacheAdapter { if (F.contains(skipped, i)) continue; - KeyCacheObject key = req.keys().get(i); + KeyCacheObject key = req.key(i); if (F.contains(failed, key)) continue;