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 58D5618B55 for ; Fri, 1 Jan 2016 21:07:29 +0000 (UTC) Received: (qmail 56628 invoked by uid 500); 1 Jan 2016 21:07:29 -0000 Delivered-To: apmail-ignite-commits-archive@ignite.apache.org Received: (qmail 56535 invoked by uid 500); 1 Jan 2016 21:07:29 -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 56523 invoked by uid 99); 1 Jan 2016 21:07:28 -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; Fri, 01 Jan 2016 21:07:28 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id B4595E07F6; Fri, 1 Jan 2016 21:07:28 +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: Fri, 01 Jan 2016 21:07:34 -0000 Message-Id: <3f14606f7dc44c24aba3d300fe9a9a00@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [07/18] ignite git commit: IGNITE-2263: DANGEROUS! Removed view() from GridNearGetFuture. IGNITE-2263: DANGEROUS! Removed view() from GridNearGetFuture. Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/bd31fa69 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/bd31fa69 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/bd31fa69 Branch: refs/heads/ignite-2263 Commit: bd31fa69f9885f2a80a15670d30bdb7f93e6bb54 Parents: 66d2884 Author: thatcoach Authored: Fri Jan 1 16:39:54 2016 +0300 Committer: thatcoach Committed: Fri Jan 1 16:39:54 2016 +0300 ---------------------------------------------------------------------- .../distributed/near/GridNearGetFuture.java | 53 +++++++++++++------- 1 file changed, 35 insertions(+), 18 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/bd31fa69/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java index a121af9..bee376a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java @@ -17,13 +17,6 @@ package org.apache.ignite.internal.processors.cache.distributed.near; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.UUID; -import java.util.concurrent.atomic.AtomicReference; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.IgniteLogger; import org.apache.ignite.cluster.ClusterNode; @@ -58,10 +51,19 @@ import org.apache.ignite.internal.util.typedef.T2; import org.apache.ignite.internal.util.typedef.internal.CU; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.lang.IgnitePredicate; import org.apache.ignite.lang.IgniteUuid; import org.jetbrains.annotations.Nullable; -import static org.apache.ignite.transactions.TransactionIsolation.READ_COMMITTED; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.UUID; +import java.util.concurrent.atomic.AtomicReference; + +import static org.apache.ignite.transactions.TransactionIsolation.*; /** * @@ -243,6 +245,21 @@ public final class GridNearGetFuture extends CacheDistributedGetFutureAdap Map> mapped, final AffinityTopologyVersion topVer ) { + map(keys, F.alwaysTrue(), mapped, topVer); + } + + /** + * @param keys Keys. + * @param pred Predicate. + * @param mapped Mappings to check for duplicates. + * @param topVer Topology version to map on. + */ + private void map( + Collection keys, + IgnitePredicate pred, + Map> mapped, + final AffinityTopologyVersion topVer + ) { Collection affNodes = CU.affinityNodes(cctx, topVer); if (affNodes.isEmpty()) { @@ -263,8 +280,10 @@ public final class GridNearGetFuture extends CacheDistributedGetFutureAdap try { // Assign keys to primary nodes. - for (KeyCacheObject key : keys) - savedEntries = map(key, mappings, topVer, mapped, savedEntries); + for (KeyCacheObject key : keys) { + if (pred.apply(key)) + savedEntries = map(key, mappings, topVer, mapped, savedEntries); + } success = true; } @@ -291,8 +310,6 @@ public final class GridNearGetFuture extends CacheDistributedGetFutureAdap final Map saved = savedEntries != null ? savedEntries : Collections.emptyMap(); - final int keysSize = keys.size(); - // Create mini futures. for (Map.Entry> entry : mappings.entrySet()) { final ClusterNode n = entry.getKey(); @@ -317,10 +334,10 @@ public final class GridNearGetFuture extends CacheDistributedGetFutureAdap final Collection invalidParts = fut.invalidPartitions(); if (!F.isEmpty(invalidParts)) { - Collection remapKeys = new ArrayList<>(keysSize); + Collection remapKeys = new ArrayList<>(keys.size()); for (KeyCacheObject key : keys) { - if (key != null && invalidParts.contains(cctx.affinity().partition(key))) + if (key != null && pred.apply(key) && invalidParts.contains(cctx.affinity().partition(key))) remapKeys.add(key); } @@ -931,11 +948,11 @@ public final class GridNearGetFuture extends CacheDistributedGetFutureAdap log.debug("Remapping mini get future [invalidParts=" + invalidParts + ", fut=" + this + ']'); if (!canRemap) { - map(F.view(keys.keySet(), new P1() { + map(keys.keySet(), new P1() { @Override public boolean apply(KeyCacheObject key) { return invalidParts.contains(cctx.affinity().partition(key)); } - }), F.t(node, keys), topVer); + }, F.t(node, keys), topVer); // It is critical to call onDone after adding futures to compound list. onDone(loadEntries(node.id(), keys.keySet(), res.entries(), savedEntries, topVer)); @@ -951,11 +968,11 @@ public final class GridNearGetFuture extends CacheDistributedGetFutureAdap long readyTopVer = fut.get(); // This will append new futures to compound list. - map(F.view(keys.keySet(), new P1() { + map(keys.keySet(), new P1() { @Override public boolean apply(KeyCacheObject key) { return invalidParts.contains(cctx.affinity().partition(key)); } - }), F.t(node, keys), new AffinityTopologyVersion(readyTopVer)); + }, F.t(node, keys), new AffinityTopologyVersion(readyTopVer)); // It is critical to call onDone after adding futures to compound list. onDone(loadEntries(node.id(), keys.keySet(), res.entries(), savedEntries, topVer));