ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject [10/21] ignite git commit: IGNITE-1833 Fixed Visor backup partitions count logic.
Date Wed, 04 Nov 2015 09:23:40 GMT
IGNITE-1833 Fixed Visor backup partitions count logic.


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

Branch: refs/heads/ignite-1697
Commit: 28e0217f893ed2151092a5e3a9b0b96ee7dec77f
Parents: 747c684
Author: AKuznetsov <akuznetsov@gridgain.com>
Authored: Mon Nov 2 19:34:49 2015 +0700
Committer: AKuznetsov <akuznetsov@gridgain.com>
Committed: Mon Nov 2 19:34:49 2015 +0700

----------------------------------------------------------------------
 .../cache/GridCacheAffinityManager.java           | 18 ++++++++++++++++--
 .../distributed/dht/GridDhtLocalPartition.java    |  8 ++++++++
 .../ignite/internal/visor/cache/VisorCache.java   |  5 +++--
 3 files changed, 27 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/28e0217f/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 4f99ef5..5c43205 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
@@ -262,7 +262,7 @@ public class GridCacheAffinityManager extends GridCacheManagerAdapter
{
      * @param n Node to check.
      * @param part Partition.
      * @param topVer Topology version.
-     * @return {@code True} if checked node is primary for given key.
+     * @return {@code True} if checked node is primary for given partition.
      */
     public boolean primary(ClusterNode n, int part, AffinityTopologyVersion topVer) {
         return F.eq(primary(part, topVer), n);
@@ -294,6 +294,20 @@ public class GridCacheAffinityManager extends GridCacheManagerAdapter
{
     }
 
     /**
+     * @param n Node to check.
+     * @param part Partition.
+     * @param topVer Topology version.
+     * @return {@code True} if checked node is a backup node for given partition.
+     */
+    public boolean backup(ClusterNode n, int part, AffinityTopologyVersion topVer) {
+        List<ClusterNode> nodes = nodes(part, topVer);
+
+        assert !F.isEmpty(nodes);
+
+        return nodes.indexOf(n) > 0;
+    }
+
+    /**
      * @param keys keys.
      * @param topVer Topology version.
      * @return Nodes for the keys.
@@ -370,4 +384,4 @@ public class GridCacheAffinityManager extends GridCacheManagerAdapter
{
     public AffinityTopologyVersion affinityTopologyVersion() {
         return aff.lastVersion();
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/28e0217f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java
index 4f124e6..749d06a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java
@@ -604,6 +604,14 @@ public class GridDhtLocalPartition implements Comparable<GridDhtLocalPartition>,
     }
 
     /**
+     * @param topVer Topology version.
+     * @return {@code True} if local node is backup for this partition.
+     */
+    public boolean backup(AffinityTopologyVersion topVer) {
+        return cctx.affinity().backup(cctx.localNode(), id, topVer);
+    }
+
+    /**
      * Clears values for this partition.
      */
     private void clearAll() {

http://git-wip-us.apache.org/repos/asf/ignite/blob/28e0217f/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCache.java
b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCache.java
index 937121d..111cab8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCache.java
@@ -35,6 +35,7 @@ import org.apache.ignite.internal.processors.cache.GridCacheAdapter;
 import org.apache.ignite.internal.processors.cache.GridCacheEntryEx;
 import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheAdapter;
 import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtLocalPartition;
+import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionState;
 import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionTopology;
 import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionMap;
 import org.apache.ignite.internal.processors.cache.distributed.near.GridNearCacheAdapter;
@@ -171,7 +172,7 @@ public class VisorCache implements Serializable {
                     // Pass -1 as topology version in order not to wait for topology version.
                     if (part.primary(AffinityTopologyVersion.NONE))
                         primaryPartitions.add(new IgnitePair<>(p, sz));
-                    else
+                    else if (part.state() == GridDhtPartitionState.OWNING && part.backup(AffinityTopologyVersion.NONE))
                         backupPartitions.add(new IgnitePair<>(p, sz));
                 }
             }
@@ -406,4 +407,4 @@ public class VisorCache implements Serializable {
     @Override public String toString() {
         return S.toString(VisorCache.class, this);
     }
-}
\ No newline at end of file
+}


Mime
View raw message