ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akuznet...@apache.org
Subject [1/4] ignite git commit: Add public API check for partitions count.
Date Tue, 14 Jun 2016 02:54:06 GMT
Repository: ignite
Updated Branches:
  refs/heads/master 8e4fc4c32 -> 442bd6190


Add public API check for partitions count.


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

Branch: refs/heads/master
Commit: 80d19f04a793fcf2009985b449ec3f058649ab4e
Parents: 4f8ba17
Author: Alexey Goncharuk <alexey.goncharuk@gmail.com>
Authored: Mon Jun 13 18:17:14 2016 -0700
Committer: Alexey Goncharuk <alexey.goncharuk@gmail.com>
Committed: Mon Jun 13 18:17:14 2016 -0700

----------------------------------------------------------------------
 .../ignite/cache/affinity/fair/FairAffinityFunction.java      | 2 ++
 .../cache/affinity/rendezvous/RendezvousAffinityFunction.java | 2 ++
 .../org/apache/ignite/configuration/CacheConfiguration.java   | 3 +++
 .../ignite/internal/processors/cache/GridCacheProcessor.java  | 4 ++++
 .../cache/distributed/dht/preloader/GridDhtPartitionMap2.java | 7 +++++--
 5 files changed, 16 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/80d19f04/modules/core/src/main/java/org/apache/ignite/cache/affinity/fair/FairAffinityFunction.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/affinity/fair/FairAffinityFunction.java
b/modules/core/src/main/java/org/apache/ignite/cache/affinity/fair/FairAffinityFunction.java
index b6b14ec..105efab 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/affinity/fair/FairAffinityFunction.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/affinity/fair/FairAffinityFunction.java
@@ -198,6 +198,8 @@ public class FairAffinityFunction implements AffinityFunction {
      * @param parts Total number of partitions.
      */
     public void setPartitions(int parts) {
+        A.ensure(parts <= CacheConfiguration.MAX_PARTITIONS_COUNT, "parts <= " + CacheConfiguration.MAX_PARTITIONS_COUNT);
+
         this.parts = parts;
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/80d19f04/modules/core/src/main/java/org/apache/ignite/cache/affinity/rendezvous/RendezvousAffinityFunction.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/affinity/rendezvous/RendezvousAffinityFunction.java
b/modules/core/src/main/java/org/apache/ignite/cache/affinity/rendezvous/RendezvousAffinityFunction.java
index 990eba1..aa8680c 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/affinity/rendezvous/RendezvousAffinityFunction.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/affinity/rendezvous/RendezvousAffinityFunction.java
@@ -222,6 +222,8 @@ public class RendezvousAffinityFunction implements AffinityFunction, Externaliza
      * @param parts Total number of partitions.
      */
     public void setPartitions(int parts) {
+        A.ensure(parts <= CacheConfiguration.MAX_PARTITIONS_COUNT, "parts <= " + CacheConfiguration.MAX_PARTITIONS_COUNT);
+
         this.parts = parts;
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/80d19f04/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
b/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
index 5a234de..3408834 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
@@ -100,6 +100,9 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K,
V> {
     /** */
     private static final long serialVersionUID = 0L;
 
+    /** Maximum number of partitions. */
+    public static final int MAX_PARTITIONS_COUNT = 0x4000;
+
     /** Default size of rebalance thread pool. */
     @Deprecated
     public static final int DFLT_REBALANCE_THREAD_POOL_SIZE = 2;

http://git-wip-us.apache.org/repos/asf/ignite/blob/80d19f04/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
index 6625093..37c3cf1 100755
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
@@ -379,6 +379,10 @@ public class GridCacheProcessor extends GridProcessorAdapter {
             U.warn(log, "AffinityFunction configuration parameter will be ignored for local
cache [cacheName=" +
                 U.maskName(cc.getName()) + ']');
 
+        if (cc.getAffinity().partitions() > CacheConfiguration.MAX_PARTITIONS_COUNT)
+            throw new IgniteCheckedException("Cannot have more than " + CacheConfiguration.MAX_PARTITIONS_COUNT
+
+                " partitions [cacheName=" + cc.getName() + ", partitions=" + cc.getAffinity().partitions()
+ ']');
+
         if (cc.getRebalanceMode() != CacheRebalanceMode.NONE)
             assertParameter(cc.getRebalanceBatchSize() > 0, "rebalanceBatchSize > 0");
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/80d19f04/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionMap2.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionMap2.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionMap2.java
index 54dfb68..15b5a2e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionMap2.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionMap2.java
@@ -25,6 +25,8 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.Set;
 import java.util.UUID;
+
+import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
 import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionState;
 import org.apache.ignite.internal.util.typedef.internal.S;
@@ -196,7 +198,8 @@ public class GridDhtPartitionMap2 implements Comparable<GridDhtPartitionMap2>,
E
         assert updateSeq >= old : "Invalid update sequence [cur=" + old + ", new=" + updateSeq
+ ']';
 
         this.updateSeq = updateSeq;
-        this.top = topVer;
+
+        top = topVer;
 
         return old;
     }
@@ -231,7 +234,7 @@ public class GridDhtPartitionMap2 implements Comparable<GridDhtPartitionMap2>,
E
             int ordinal = entry.getValue().ordinal();
 
             assert ordinal == (ordinal & 0x3);
-            assert entry.getKey() == (entry.getKey() & 0x3FFF);
+            assert entry.getKey() < CacheConfiguration.MAX_PARTITIONS_COUNT : entry.getKey();
 
             int coded = (ordinal << 14) | entry.getKey();
 


Mime
View raw message