ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject ignite git commit: IGNITE-2508: Quick and dirty POC.
Date Mon, 01 Feb 2016 13:48:30 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-2508 [created] 14e837c6b


IGNITE-2508: Quick and dirty POC.


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/14e837c6
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/14e837c6
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/14e837c6

Branch: refs/heads/ignite-2508
Commit: 14e837c6b1d8d36b8787e15e91264cb02539d771
Parents: c3b83fe
Author: vozerov-gridgain <vozerov@gridgain.com>
Authored: Mon Feb 1 16:48:22 2016 +0300
Committer: vozerov-gridgain <vozerov@gridgain.com>
Committed: Mon Feb 1 16:48:22 2016 +0300

----------------------------------------------------------------------
 .../affinity/GridAffinityAssignment.java        | 31 ++++++++++++++++++++
 .../affinity/GridAffinityAssignmentCache.java   | 13 ++++++++
 .../cache/GridCacheAffinityManager.java         | 18 ++++++++++++
 .../dht/GridDhtPartitionTopologyImpl.java       |  3 +-
 4 files changed, 63 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/14e837c6/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignment.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignment.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignment.java
index 810843c..ad37ad8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignment.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignment.java
@@ -18,6 +18,7 @@
 package org.apache.ignite.internal.processors.affinity;
 
 import java.io.Serializable;
+import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -47,6 +48,9 @@ class GridAffinityAssignment implements Serializable {
     /** Map of backup node partitions. */
     private final Map<UUID, Set<Integer>> backup;
 
+    /** Assignment node IDs */
+    private transient volatile List<HashSet<UUID>> assignmentIds;
+
     /**
      * Constructs cached affinity calculations item.
      *
@@ -112,6 +116,33 @@ class GridAffinityAssignment implements Serializable {
     }
 
     /**
+     * Get affinity node IDs for partition.
+     *
+     * @param part Partition.
+     * @return Affinity nodes IDs.
+     */
+    public HashSet<UUID> getIds(int part) {
+        List<HashSet<UUID>> ids = assignmentIds;
+
+        if (ids == null) {
+            ids = new ArrayList<>();
+
+            for (List<ClusterNode> a : assignment) {
+                HashSet<UUID> partIds = new HashSet<>();
+
+                for (ClusterNode n : a)
+                    partIds.add(n.id());
+
+                ids.add(partIds);
+            }
+
+            assignmentIds = ids;
+        }
+
+        return ids.get(part);
+    }
+
+    /**
      * Get primary partitions for specified node ID.
      *
      * @param nodeId Node ID to get primary partitions for.

http://git-wip-us.apache.org/repos/asf/ignite/blob/14e837c6/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java
index d728927..0b09eea 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java
@@ -19,6 +19,7 @@ package org.apache.ignite.internal.processors.affinity;
 
 import java.util.ArrayList;
 import java.util.Collections;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -389,6 +390,18 @@ public class GridAffinityAssignmentCache {
     }
 
     /**
+     * Gets affinity nodes IDs for specified partition.
+     *
+     * @param part Partition.
+     * @param topVer Topology version.
+     * @return Affinity nodes.
+     */
+    public HashSet<UUID> nodesIds(int part, AffinityTopologyVersion topVer) {
+        // Resolve cached affinity nodes.
+        return cachedAffinity(topVer).getIds(part);
+    }
+
+    /**
      * Get primary partitions for specified node ID.
      *
      * @param nodeId Node ID to get primary partitions for.

http://git-wip-us.apache.org/repos/asf/ignite/blob/14e837c6/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityManager.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityManager.java
index 375219a..de0fa2d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityManager.java
@@ -19,6 +19,7 @@ package org.apache.ignite.internal.processors.cache;
 
 import java.util.Collection;
 import java.util.Collections;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 import java.util.UUID;
@@ -246,6 +247,23 @@ public class GridCacheAffinityManager extends GridCacheManagerAdapter
{
     }
 
     /**
+     * @param part Partition.
+     * @param topVer Topology version.
+     * @return Affinity node IDs.
+     */
+    public HashSet<UUID> nodesIds(int part, AffinityTopologyVersion topVer) {
+        if (cctx.isLocal())
+            topVer = new AffinityTopologyVersion(1);
+
+        GridAffinityAssignmentCache aff0 = aff;
+
+        if (aff0 == null)
+            throw new IgniteException(FAILED_TO_FIND_CACHE_ERR_MSG + cctx.name());
+
+        return aff0.nodesIds(part, topVer);
+    }
+
+    /**
      * @param key Key to check.
      * @param topVer Topology version.
      * @return Primary node for given key.

http://git-wip-us.apache.org/repos/asf/ignite/blob/14e837c6/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java
index 2ab8a12..6e5e47f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java
@@ -694,6 +694,7 @@ class GridDhtPartitionTopologyImpl implements GridDhtPartitionTopology
{
     /** {@inheritDoc} */
     @Override public Collection<ClusterNode> nodes(int p, AffinityTopologyVersion topVer)
{
         Collection<ClusterNode> affNodes = cctx.affinity().nodes(p, topVer);
+        HashSet<UUID> affIds = cctx.affinity().nodesIds(p, topVer);
 
         lock.readLock().lock();
 
@@ -708,8 +709,6 @@ class GridDhtPartitionTopologyImpl implements GridDhtPartitionTopology
{
             Collection<UUID> nodeIds = part2node.get(p);
 
             if (!F.isEmpty(nodeIds)) {
-                Collection<UUID> affIds = new HashSet<>(F.viewReadOnly(affNodes,
F.node2id()));
-
                 for (UUID nodeId : nodeIds) {
                     if (!affIds.contains(nodeId) && hasState(p, nodeId, OWNING, MOVING,
RENTING)) {
                         ClusterNode n = cctx.discovery().node(nodeId);


Mime
View raw message