ibessonov commented on code in PR #3614:
URL: https://github.com/apache/ignite-3/pull/3614#discussion_r1570238336


##########
modules/table/src/main/java/org/apache/ignite/internal/table/distributed/disaster/DisasterRecoveryManager.java:
##########
@@ -357,36 +402,94 @@ private static LocalPartitionStateEnum convertState(State 
nodeState) {
 
             default:
                 // Unrecognized state, better safe than sorry.
-                return LocalPartitionStateEnum.BROKEN;
+                return BROKEN;
         }
     }
 
     /**
      * Replaces some healthy states with a {@link 
LocalPartitionStateEnum#CATCHING_UP},it can only be done once the state of all 
peers is
      * known.
      */
-    private Map<TablePartitionId, Map<String, LocalPartitionState>> normalize(
-            Map<TablePartitionId, Map<String, LocalPartitionState>> result
+    private static Map<TablePartitionId, Map<String, LocalPartitionState>> 
normalizeLocal(
+            Map<TablePartitionId, Map<String, LocalPartitionStateMessage>> 
result,
+            Catalog catalog
     ) {
         return 
result.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, entry -> 
{
-            Map<String, LocalPartitionState> map = entry.getValue();
+            TablePartitionId tablePartitionId = entry.getKey();
+            Map<String, LocalPartitionStateMessage> map = entry.getValue();
 
             // noinspection OptionalGetWithoutIsPresent
-            long maxLogIndex = 
map.values().stream().mapToLong(LocalPartitionState::logIndex).max().getAsLong();
+            long maxLogIndex = 
map.values().stream().mapToLong(LocalPartitionStateMessage::logIndex).max().getAsLong();
 
             return 
map.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, entry2 -> {
-                LocalPartitionState state = entry2.getValue();
+                LocalPartitionStateMessage stateMsg = entry2.getValue();
 
-                if (state.state() != LocalPartitionStateEnum.HEALTHY || 
maxLogIndex - state.logIndex() < CATCH_UP_THRESHOLD) {
-                    return state;
+                LocalPartitionStateEnum stateEnum = stateMsg.state();
+
+                if (stateMsg.state() == HEALTHY && maxLogIndex - 
stateMsg.logIndex() >= CATCH_UP_THRESHOLD) {
+                    stateEnum = CATCHING_UP;
                 }
 
-                return MSG_FACTORY.localPartitionState()
-                        .state(LocalPartitionStateEnum.CATCHING_UP)
-                        .partitionId(state.partitionId())
-                        .logIndex(state.logIndex())
-                        .build();
+                CatalogTableDescriptor tableDescriptor = 
catalog.table(tablePartitionId.tableId());
+                return new LocalPartitionState(tableDescriptor.name(), 
tablePartitionId.partitionId(), stateEnum);
             }));
         }));
     }
+
+    private static Map<TablePartitionId, GlobalPartitionState> normalizeGlobal(
+            Map<TablePartitionId, Map<String, LocalPartitionState>> 
localResult,
+            Catalog catalog
+    ) {
+        Map<Integer, Integer> tableIdToPartitions = new HashMap<>();
+
+        Map<TablePartitionId, GlobalPartitionState> result = 
localResult.entrySet().stream()
+                .collect(Collectors.toMap(Map.Entry::getKey, entry -> {
+                    TablePartitionId tablePartitionId = entry.getKey();
+                    Map<String, LocalPartitionState> map = entry.getValue();
+
+                    int zoneId = 
catalog.table(tablePartitionId.tableId()).zoneId();

Review Comment:
   After a second thought - not necessarily. It's not clear what we should do 
with deleted tables, that might cause some issues. I'll do something, and 
probably create a TODO for further actions.
   OK, we're skipping tables that are not in that specific catalog version, so 
everything's ok. Historical data is simply ignored, that's a matter of future 
improvements



##########
modules/table/src/main/java/org/apache/ignite/internal/table/distributed/disaster/DisasterRecoveryManager.java:
##########
@@ -357,36 +402,94 @@ private static LocalPartitionStateEnum convertState(State 
nodeState) {
 
             default:
                 // Unrecognized state, better safe than sorry.
-                return LocalPartitionStateEnum.BROKEN;
+                return BROKEN;
         }
     }
 
     /**
      * Replaces some healthy states with a {@link 
LocalPartitionStateEnum#CATCHING_UP},it can only be done once the state of all 
peers is
      * known.
      */
-    private Map<TablePartitionId, Map<String, LocalPartitionState>> normalize(
-            Map<TablePartitionId, Map<String, LocalPartitionState>> result
+    private static Map<TablePartitionId, Map<String, LocalPartitionState>> 
normalizeLocal(
+            Map<TablePartitionId, Map<String, LocalPartitionStateMessage>> 
result,
+            Catalog catalog
     ) {
         return 
result.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, entry -> 
{
-            Map<String, LocalPartitionState> map = entry.getValue();
+            TablePartitionId tablePartitionId = entry.getKey();
+            Map<String, LocalPartitionStateMessage> map = entry.getValue();
 
             // noinspection OptionalGetWithoutIsPresent
-            long maxLogIndex = 
map.values().stream().mapToLong(LocalPartitionState::logIndex).max().getAsLong();
+            long maxLogIndex = 
map.values().stream().mapToLong(LocalPartitionStateMessage::logIndex).max().getAsLong();
 
             return 
map.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, entry2 -> {
-                LocalPartitionState state = entry2.getValue();
+                LocalPartitionStateMessage stateMsg = entry2.getValue();
 
-                if (state.state() != LocalPartitionStateEnum.HEALTHY || 
maxLogIndex - state.logIndex() < CATCH_UP_THRESHOLD) {
-                    return state;
+                LocalPartitionStateEnum stateEnum = stateMsg.state();
+
+                if (stateMsg.state() == HEALTHY && maxLogIndex - 
stateMsg.logIndex() >= CATCH_UP_THRESHOLD) {
+                    stateEnum = CATCHING_UP;
                 }
 
-                return MSG_FACTORY.localPartitionState()
-                        .state(LocalPartitionStateEnum.CATCHING_UP)
-                        .partitionId(state.partitionId())
-                        .logIndex(state.logIndex())
-                        .build();
+                CatalogTableDescriptor tableDescriptor = 
catalog.table(tablePartitionId.tableId());
+                return new LocalPartitionState(tableDescriptor.name(), 
tablePartitionId.partitionId(), stateEnum);
             }));
         }));
     }
+
+    private static Map<TablePartitionId, GlobalPartitionState> normalizeGlobal(
+            Map<TablePartitionId, Map<String, LocalPartitionState>> 
localResult,
+            Catalog catalog
+    ) {
+        Map<Integer, Integer> tableIdToPartitions = new HashMap<>();
+
+        Map<TablePartitionId, GlobalPartitionState> result = 
localResult.entrySet().stream()
+                .collect(Collectors.toMap(Map.Entry::getKey, entry -> {
+                    TablePartitionId tablePartitionId = entry.getKey();
+                    Map<String, LocalPartitionState> map = entry.getValue();
+
+                    int zoneId = 
catalog.table(tablePartitionId.tableId()).zoneId();

Review Comment:
   After a second thought - not necessarily. It's not clear what we should do 
with deleted tables, that might cause some issues. I'll do something, and 
probably create a TODO for further actions.
   EDIT: OK, we're skipping tables that are not in that specific catalog 
version, so everything's ok. Historical data is simply ignored, that's a matter 
of future improvements



-- 
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]

Reply via email to