diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessageFactory.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessageFactory.java index e97b2ad3517ca..5ca6b39adcc84 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessageFactory.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessageFactory.java @@ -189,8 +189,6 @@ import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GroupPartitionIdPairSerializer; import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.IgniteDhtDemandedPartitionsMap; import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.IgniteDhtDemandedPartitionsMapSerializer; -import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.IgniteDhtPartitionCountersMap; -import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.IgniteDhtPartitionCountersMapSerializer; import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.IgniteDhtPartitionHistorySuppliersMap; import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.IgniteDhtPartitionHistorySuppliersMapSerializer; import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.IgniteDhtPartitionsToReloadMap; @@ -550,8 +548,6 @@ public GridIoMessageFactory(Marshaller marsh, ClassLoader clsLdr) { new BinaryMetadataVersionInfoSerializer()); factory.register(506, CachePartitionFullCountersMap::new, new CachePartitionFullCountersMapSerializer()); - factory.register(507, IgniteDhtPartitionCountersMap::new, - new IgniteDhtPartitionCountersMapSerializer()); factory.register(508, GroupPartitionIdPair::new, new GroupPartitionIdPairSerializer()); factory.register(510, IgniteDhtPartitionHistorySuppliersMap::new, new IgniteDhtPartitionHistorySuppliersMapSerializer()); 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 9ee1835e1a913..cffd9805dcf26 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 @@ -71,7 +71,7 @@ public class GridDhtPartitionsFullMessage extends GridDhtPartitionsAbstractMessa @Order(2) @Compress @GridToStringInclude - IgniteDhtPartitionCountersMap partCntrs; + Map partCntrs; /** Partitions history suppliers. */ @Order(3) @@ -127,6 +127,9 @@ public class GridDhtPartitionsFullMessage extends GridDhtPartitionsAbstractMessa @GridToStringExclude Map lostParts; + /** Mutex. */ + private final Object mux = new Object(); + /** * Empty constructor. */ @@ -278,10 +281,13 @@ public void addFullPartitionsMap(int grpId, GridDhtPartitionFullMap fullMap, @Nu * @param cntrMap Partition update counters. */ public void addPartitionUpdateCounters(int grpId, CachePartitionFullCountersMap cntrMap) { - if (partCntrs == null) - partCntrs = new IgniteDhtPartitionCountersMap(); + synchronized (mux) { + if (partCntrs == null) + partCntrs = new HashMap<>(); - partCntrs.putIfAbsent(grpId, cntrMap); + if (!partCntrs.containsKey(grpId)) + partCntrs.put(grpId, cntrMap); + } } /** @@ -319,7 +325,9 @@ public void addLostPartitions(int grpId, Collection lostParts) { * @return Partition update counters. */ public CachePartitionFullCountersMap partitionUpdateCounters(int grpId) { - return partCntrs == null ? null : partCntrs.get(grpId); + synchronized (mux) { + return partCntrs == null ? null : partCntrs.get(grpId); + } } /** @@ -442,7 +450,7 @@ public void topologyVersion(AffinityTopologyVersion topVer) { parts = new HashMap<>(); if (partCntrs == null) - partCntrs = new IgniteDhtPartitionCountersMap(); + partCntrs = new HashMap<>(); if (partHistSuppliers == null) partHistSuppliers = new IgniteDhtPartitionHistorySuppliersMap(); 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 deleted file mode 100644 index 62d964d682bf3..0000000000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/IgniteDhtPartitionCountersMap.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.ignite.internal.processors.cache.distributed.dht.preloader; - -import java.util.HashMap; -import java.util.Map; -import org.apache.ignite.internal.Order; -import org.apache.ignite.plugin.extensions.communication.Message; - -/** - * Partition counters map. - */ -public class IgniteDhtPartitionCountersMap implements Message { - /** */ - @Order(0) - Map map; - - /** - * @param cacheId Cache ID. - * @param cntrMap Counters map. - */ - public synchronized void putIfAbsent(int cacheId, CachePartitionFullCountersMap cntrMap) { - if (map == null) - map = new HashMap<>(); - - if (!map.containsKey(cacheId)) - map.put(cacheId, cntrMap); - } - - /** - * @param cacheId Cache ID. - * @return Counters map. - */ - public synchronized CachePartitionFullCountersMap get(int cacheId) { - if (map == null) - return null; - - CachePartitionFullCountersMap cntrMap = map.get(cacheId); - - return cntrMap; - } - -} diff --git a/modules/core/src/main/resources/META-INF/classnames.properties b/modules/core/src/main/resources/META-INF/classnames.properties index f16695c2d12b8..5268663d0da9d 100644 --- a/modules/core/src/main/resources/META-INF/classnames.properties +++ b/modules/core/src/main/resources/META-INF/classnames.properties @@ -1192,7 +1192,6 @@ org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPre org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPreloader$2 org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPreloaderAssignments org.apache.ignite.internal.processors.cache.distributed.dht.preloader.IgniteDhtDemandedPartitionsMap -org.apache.ignite.internal.processors.cache.distributed.dht.preloader.IgniteDhtPartitionCountersMap org.apache.ignite.internal.processors.cache.distributed.dht.preloader.IgniteDhtPartitionHistorySuppliersMap org.apache.ignite.internal.processors.cache.distributed.dht.preloader.IgniteDhtPartitionsToReloadMap org.apache.ignite.internal.processors.cache.distributed.dht.preloader.IgniteHistoricalIterator diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheExchangeMessageDuplicatedStateTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheExchangeMessageDuplicatedStateTest.java index abbb726906699..a14322a886a41 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheExchangeMessageDuplicatedStateTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheExchangeMessageDuplicatedStateTest.java @@ -229,8 +229,7 @@ private void checkFullMessage(GridDhtPartitionsFullMessage msg) { assertFalse(dupPartsData.containsKey(CU.cacheId(AFF3_CACHE1))); - Map partCntrs = - getFieldValue(getFieldValue(msg, "partCntrs"), "map"); + Map partCntrs = getFieldValue(msg, "partCntrs"); if (partCntrs != null) { for (CachePartitionFullCountersMap cntrs : partCntrs.values()) {