shishkovilja commented on code in PR #12467:
URL: https://github.com/apache/ignite/pull/12467#discussion_r2469927949
##########
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/IgniteDhtPartitionHistorySuppliersMap.java:
##########
@@ -94,15 +95,15 @@ public synchronized void put(UUID nodeId, int grpId, int
partId, long cntr) {
if (map == null)
map = new HashMap<>();
- Map<T2<Integer, Integer>, Long> nodeMap = map.get(nodeId);
+ PartitionReservationsMap nodeMap = map.get(nodeId);
if (nodeMap == null) {
- nodeMap = new HashMap<>();
+ nodeMap = new PartitionReservationsMap(new HashMap<>());
map.put(nodeId, nodeMap);
}
- nodeMap.put(new T2<>(grpId, partId), cntr);
+ nodeMap.put(new GroupPartitionIdPair(grpId, partId), cntr);
Review Comment:
put is safe due to lazy init of inner map.
##########
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/IgniteDhtPartitionHistorySuppliersMap.java:
##########
@@ -94,15 +95,15 @@ public synchronized void put(UUID nodeId, int grpId, int
partId, long cntr) {
if (map == null)
map = new HashMap<>();
- Map<T2<Integer, Integer>, Long> nodeMap = map.get(nodeId);
+ PartitionReservationsMap nodeMap = map.get(nodeId);
Review Comment:
```suggestion
PartitionReservationsMap nodeMap = map.computeIfAbsent(nodeId, k ->
new PartitionReservationsMap());
```
##########
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/IgniteDhtPartitionHistorySuppliersMap.java:
##########
@@ -94,15 +95,15 @@ public synchronized void put(UUID nodeId, int grpId, int
partId, long cntr) {
if (map == null)
map = new HashMap<>();
- Map<T2<Integer, Integer>, Long> nodeMap = map.get(nodeId);
+ PartitionReservationsMap nodeMap = map.get(nodeId);
if (nodeMap == null) {
Review Comment:
if block can be entirely removed.
##########
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/PartitionReservationsMap.java:
##########
@@ -0,0 +1,87 @@
+/*
+ * 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;
+import org.jetbrains.annotations.Nullable;
+
+/** Map for storing GroupPartitionIdPair and their respective history counter
values. */
+public class PartitionReservationsMap implements Message {
+ /** Type code. */
+ public static final short TYPE_CODE = 509;
+
+ /** Mapping between GroupPartitionIdPair objects and their respective
history counter values. */
+ @Order(0)
+ private Map<GroupPartitionIdPair, Long> map;
+
+ /** Default constructor. */
Review Comment:
Constructor can be removed.
##########
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/PartitionReservationsMap.java:
##########
@@ -0,0 +1,87 @@
+/*
+ * 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;
+import org.jetbrains.annotations.Nullable;
+
+/** Map for storing GroupPartitionIdPair and their respective history counter
values. */
+public class PartitionReservationsMap implements Message {
+ /** Type code. */
+ public static final short TYPE_CODE = 509;
+
+ /** Mapping between GroupPartitionIdPair objects and their respective
history counter values. */
+ @Order(0)
+ private Map<GroupPartitionIdPair, Long> map;
+
+ /** Default constructor. */
+ public PartitionReservationsMap() {
+ // No-op.
+ }
+
+ /**
+ * @param map Map.
+ */
+ public PartitionReservationsMap(Map<GroupPartitionIdPair, Long> map) {
Review Comment:
Constructor can be removed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]