denis-chudov commented on code in PR #5092:
URL: https://github.com/apache/ignite-3/pull/5092#discussion_r1961511176


##########
modules/distribution-zones/src/main/java/org/apache/ignite/internal/distributionzones/DistributionZonesUtil.java:
##########
@@ -474,64 +340,78 @@ public static Set<Node> dataNodes(Map<Node, Integer> 
dataNodesMap) {
     }
 
     /**
-     * Returns a map from a set of data nodes. This map has the following 
structure: node is mapped to integer,
-     * integer represents how often node joined or leaved topology. In this 
case, set of nodes is interpreted as nodes
-     * that joined topology, so all mappings will be node -> 1.
+     * Returns a set of data nodes retrieved from data nodes map, which value 
is more than 0.
      *
-     * @param dataNodes Set of data nodes.
-     * @return Returns a map from a set of data nodes.
+     * @param dataNodes Data nodes with attributes set.
+     * @return Returns a set of data nodes retrieved from data nodes with 
attributes set.
      */
-    public static Map<Node, Integer> toDataNodesMap(Set<Node> dataNodes) {
-        Map<Node, Integer> dataNodesMap = new HashMap<>();
-
-        dataNodes.forEach(n -> dataNodesMap.merge(n, 1, Integer::sum));
-
-        return dataNodesMap;
+    public static Set<Node> dataNodes(Set<NodeWithAttributes> dataNodes) {
+        return 
dataNodes.stream().map(NodeWithAttributes::node).collect(toSet());
     }
 
+    /**
+     * Parse the data nodes from bytes.
+     *
+     * @param dataNodesBytes Data nodes bytes.
+     * @param timestamp Timestamp.
+     * @return Set of nodes.
+     */
     @Nullable
-    public static Set<Node> parseDataNodes(byte[] dataNodesBytes) {
-        return dataNodesBytes == null ? null : 
dataNodes(deserializeDataNodesMap(dataNodesBytes));
-    }
+    public static Set<NodeWithAttributes> parseDataNodes(byte[] 
dataNodesBytes, HybridTimestamp timestamp) {
+        if (dataNodesBytes == null) {
+            return null;
+        }
+
+        DataNodesHistory dataNodesHistory = 
DataNodesHistorySerializer.deserialize(dataNodesBytes);
 
-    public static Map<Node, Integer> deserializeDataNodesMap(byte[] bytes) {
-        return DataNodesMapSerializer.deserialize(bytes);
+        return dataNodesHistory.dataNodesForTimestamp(timestamp).getSecond();
     }
 
+    /**
+     * Deserialize the set of nodes with attributes from the given serialized 
bytes.
+     *
+     * @param bytes Serialized set of nodes with attributes.
+     * @return Set of nodes with attributes.
+     */
     public static Set<NodeWithAttributes> deserializeLogicalTopologySet(byte[] 
bytes) {
         return LogicalTopologySetSerializer.deserialize(bytes);
     }
 
-    public static Map<UUID, NodeWithAttributes> 
deserializeNodesAttributes(byte[] bytes) {
+    static Map<UUID, NodeWithAttributes> deserializeNodesAttributes(byte[] 
bytes) {
         return NodesAttributesSerializer.deserialize(bytes);
     }
 
     /**
-     * Returns data nodes from the meta storage entry or empty map if the 
value is null.
+     * Meta storage entries to {@link DataNodeHistoryContext}.
      *
-     * @param dataNodesEntry Meta storage entry with data nodes.
-     * @return Data nodes.
+     * @param entries Entries.
+     * @return DataNodeHistoryContext.
      */
-    static Map<Node, Integer> extractDataNodes(Entry dataNodesEntry) {
-        if (!dataNodesEntry.empty()) {
-            return deserializeDataNodesMap(dataNodesEntry.value());
-        } else {
-            return emptyMap();
+    @Nullable
+    public static DataNodeHistoryContext 
dataNodeHistoryContextFromValues(Collection<Entry> entries) {
+        DataNodesHistory dataNodesHistory = null;
+        DistributionZoneTimer scaleUpTimer = null;
+        DistributionZoneTimer scaleDownTimer = null;
+
+        for (Entry e : entries) {
+            if (e.empty()) {
+                return null;
+            }
+
+            assert e != null && e.key() != null : "Unexpected entry: " + e;
+
+            byte[] v = e.tombstone() ? null : e.value();
+
+            if (new String(e.key(), 
StandardCharsets.UTF_8).startsWith(DISTRIBUTION_ZONE_DATA_NODES_HISTORY_PREFIX))
 {

Review Comment:
   fixed



-- 
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: notifications-unsubscr...@ignite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to