You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ag...@apache.org on 2017/08/07 16:14:55 UTC

ignite git commit: IGNITE-5872 - Fixed NPE

Repository: ignite
Updated Branches:
  refs/heads/ignite-5872 2874f75e1 -> ee6f76965


IGNITE-5872 - Fixed NPE


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

Branch: refs/heads/ignite-5872
Commit: ee6f769651777abd309e9a5d1932d45babe2e9d9
Parents: 2874f75
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Mon Aug 7 19:14:43 2017 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Mon Aug 7 19:14:43 2017 +0300

----------------------------------------------------------------------
 .../GridCachePartitionExchangeManager.java      | 20 +++++++++-----------
 .../dht/GridClientPartitionTopology.java        |  6 +++++-
 .../CachePartitionFullCountersMap.java          | 10 ----------
 .../preloader/GridDhtPartitionsFullMessage.java |  4 +---
 .../IgniteDhtPartitionCountersMap.java          |  6 ++----
 5 files changed, 17 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/ee6f7696/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
index e18eb55..12b313a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
@@ -668,23 +668,21 @@ public class GridCachePartitionExchangeManager<K, V> extends GridCacheSharedMana
         if (top != null)
             return top;
 
-        Object affKey = null;
-
         CacheGroupDescriptor grpDesc = cctx.cache().cacheGroupDescriptors().get(grpId);
 
-        if (grpDesc != null) {
-            CacheConfiguration<?, ?> ccfg = grpDesc.config();
+        assert grpDesc != null;
 
-            AffinityFunction aff = ccfg.getAffinity();
+        CacheConfiguration<?, ?> ccfg = grpDesc.config();
 
-            affKey = cctx.kernalContext().affinity().similaryAffinityKey(aff,
-                ccfg.getNodeFilter(),
-                ccfg.getBackups(),
-                aff.partitions());
-        }
+        AffinityFunction aff = ccfg.getAffinity();
+
+        Object affKey = cctx.kernalContext().affinity().similaryAffinityKey(aff,
+            ccfg.getNodeFilter(),
+            ccfg.getBackups(),
+            aff.partitions());
 
         GridClientPartitionTopology old = clientTops.putIfAbsent(grpId,
-            top = new GridClientPartitionTopology(cctx, grpId, exchFut, affKey));
+            top = new GridClientPartitionTopology(cctx, grpId, exchFut, aff.partitions(), affKey));
 
         return old != null ? old : top;
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee6f7696/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridClientPartitionTopology.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridClientPartitionTopology.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridClientPartitionTopology.java
index cf45120..6448f69 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridClientPartitionTopology.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridClientPartitionTopology.java
@@ -105,7 +105,7 @@ public class GridClientPartitionTopology implements GridDhtPartitionTopology {
     private final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
 
     /** Partition update counters. */
-    private CachePartitionFullCountersMap cntrMap = new CachePartitionFullCountersMap();
+    private CachePartitionFullCountersMap cntrMap;
 
     /** */
     private final Object similarAffKey;
@@ -117,12 +117,14 @@ public class GridClientPartitionTopology implements GridDhtPartitionTopology {
      * @param cctx Context.
      * @param grpId Group ID.
      * @param exchFut Exchange ID.
+     * @param parts Number of partitions in the group.
      * @param similarAffKey Key to find caches with similar affinity.
      */
     public GridClientPartitionTopology(
         GridCacheSharedContext cctx,
         int grpId,
         GridDhtPartitionsExchangeFuture exchFut,
+        int parts,
         Object similarAffKey
     ) {
         this.cctx = cctx;
@@ -138,6 +140,8 @@ public class GridClientPartitionTopology implements GridDhtPartitionTopology {
         lock.writeLock().lock();
 
         try {
+            cntrMap = new CachePartitionFullCountersMap(parts);
+
             beforeExchange0(cctx.localNode(), exchFut);
         }
         finally {

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee6f7696/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/CachePartitionFullCountersMap.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/CachePartitionFullCountersMap.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/CachePartitionFullCountersMap.java
index 543ca1b..1384a55 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/CachePartitionFullCountersMap.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/CachePartitionFullCountersMap.java
@@ -28,22 +28,12 @@ public class CachePartitionFullCountersMap implements Serializable {
     private static final long serialVersionUID = 0L;
 
     /** */
-    public static final CachePartitionFullCountersMap EMPTY = new CachePartitionFullCountersMap();
-
-    /** */
     private long[] initialUpdCntrs;
 
     /** */
     private long[] updCntrs;
 
     /**
-     *
-     */
-    public CachePartitionFullCountersMap() {
-        // Empty map.
-    }
-
-    /**
      * @param other Map to copy.
      */
     public CachePartitionFullCountersMap(CachePartitionFullCountersMap other) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee6f7696/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java
index ef3a58f..5f415e2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java
@@ -198,9 +198,7 @@ public class GridDhtPartitionsFullMessage extends GridDhtPartitionsAbstractMessa
      * @return Partition update counters.
      */
     public CachePartitionFullCountersMap partitionUpdateCounters(int grpId) {
-        CachePartitionFullCountersMap res = partCntrs == null ? null : partCntrs.get(grpId);
-
-        return res != null ? res : CachePartitionFullCountersMap.EMPTY;
+        return partCntrs == null ? null : partCntrs.get(grpId);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee6f7696/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/IgniteDhtPartitionCountersMap.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/IgniteDhtPartitionCountersMap.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/IgniteDhtPartitionCountersMap.java
index 0124e80..75cfb37 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/IgniteDhtPartitionCountersMap.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/IgniteDhtPartitionCountersMap.java
@@ -22,8 +22,6 @@ import java.io.Serializable;
 import java.util.HashMap;
 import java.util.Map;
 
-import static org.apache.ignite.internal.processors.cache.distributed.dht.preloader.CachePartitionFullCountersMap.EMPTY;
-
 /**
  * Partition counters map.
  */
@@ -52,12 +50,12 @@ public class IgniteDhtPartitionCountersMap implements Serializable {
      */
     public synchronized CachePartitionFullCountersMap get(int cacheId) {
         if (map == null)
-            map = new HashMap<>();
+            return null;
 
         CachePartitionFullCountersMap cntrMap = map.get(cacheId);
 
         if (cntrMap == null)
-            return EMPTY;
+            return null;
 
         return cntrMap;
     }