You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vo...@apache.org on 2016/01/01 22:07:38 UTC
[11/18] ignite git commit: IGNITE-2263: DANGEROUS! view() to first()
in GridDhtForceKeysFuture.
IGNITE-2263: DANGEROUS! view() to first() in GridDhtForceKeysFuture.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/2aed6aef
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/2aed6aef
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/2aed6aef
Branch: refs/heads/ignite-2263
Commit: 2aed6aeff546cd6fcab5baede5ab1cb499b513df
Parents: 5be6f6a
Author: thatcoach <pp...@list.ru>
Authored: Fri Jan 1 17:03:45 2016 +0300
Committer: thatcoach <pp...@list.ru>
Committed: Fri Jan 1 17:03:45 2016 +0300
----------------------------------------------------------------------
.../dht/preloader/GridDhtForceKeysFuture.java | 35 +++++++++-----------
.../ignite/internal/util/lang/GridFunc.java | 19 +++++++++++
2 files changed, 35 insertions(+), 19 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/2aed6aef/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysFuture.java
index 6b03131..dcae189 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysFuture.java
@@ -17,16 +17,6 @@
package org.apache.ignite.internal.processors.cache.distributed.dht.preloader;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.UUID;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.atomic.AtomicReference;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteLogger;
import org.apache.ignite.cluster.ClusterNode;
@@ -54,14 +44,21 @@ import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteUuid;
import org.jetbrains.annotations.Nullable;
-import static java.util.concurrent.TimeUnit.MILLISECONDS;
-import static org.apache.ignite.events.EventType.EVT_CACHE_REBALANCE_OBJECT_LOADED;
-import static org.apache.ignite.events.EventType.EVT_NODE_FAILED;
-import static org.apache.ignite.events.EventType.EVT_NODE_LEFT;
-import static org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionState.MOVING;
-import static org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionState.OWNING;
-import static org.apache.ignite.internal.processors.dr.GridDrType.DR_NONE;
-import static org.apache.ignite.internal.processors.dr.GridDrType.DR_PRELOAD;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicReference;
+
+import static java.util.concurrent.TimeUnit.*;
+import static org.apache.ignite.events.EventType.*;
+import static org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionState.*;
+import static org.apache.ignite.internal.processors.dr.GridDrType.*;
/**
* Force keys request future.
@@ -360,7 +357,7 @@ public final class GridDhtForceKeysFuture<K, V> extends GridCompoundFuture<Objec
assert pick != null;
if (!cctx.rebalanceEnabled() && loc.id().equals(pick.id()))
- pick = F.first(F.view(owners, F.remoteNodes(loc.id())));
+ pick = F.first(owners, F.remoteNodes(loc.id()));
if (pick == null) {
if (log.isDebugEnabled())
http://git-wip-us.apache.org/repos/asf/ignite/blob/2aed6aef/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
index 323a2a6..96fbf47 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridFunc.java
@@ -2198,6 +2198,25 @@ public class GridFunc {
}
/**
+ * Get the very first element in the collection which passes provided predicate.
+ *
+ * @param c Collection.
+ * @param pred Predicate.
+ * @return First element or {@code null}.
+ */
+ public static <T> T first(@Nullable Iterable<? extends T> c, IgnitePredicate<? super T> pred) {
+ if (c == null)
+ return null;
+
+ for (T next : c) {
+ if (pred.apply(next))
+ return next;
+ }
+
+ return null;
+ }
+
+ /**
* Gets first element from given list or returns {@code null} if list is empty.
*
* @param list List.